Sony Arouje

a programmer's log

Archive for April 2016

Aeroponic V3 – controlled by Arduino an overview

with 9 comments

Last couple of months I was building a new version of my Aeroponic controlling system. This time I dropped Raspberry pi and moved to Arduino. One of the reason I moved to Arduino is, it’s a micro controller and has no OS. So the system will not crash, in case of power failures. Raspberry pi is on the other hand runs Linux and frequent power failures might damage the OS. The new system has all the features of my old version, plus some additional features.


I decided to use Arduino Nano, for my development. Nano has a small foot print and can plug into a PCB. I also designed a PCB to hold all the pieces together, will see the PCB shortly.

I went through several iterations of PCB design. Initially I started with onboard relay modules, later I decided to remove on board relay modules and plug external relay modules. The reason to use external relay is, I can change the relays depends on the water pump’s ampere. Also I can easily change relays if it got fried.

Mobile Application: Just like last version I created an Android app to control the system but this time I wrote a native app, previously I used Cordova to build the app.

Communication: Mobile app and Arduino communicates via bluetooth. I used HC-06 bluetooth module. To make the system simple, I skipped WiFi module. May be in later version I can include WiFi or I can use Arduino MKR1000 which has inbuilt WiFi.

Power: The system runs in 12V DC. The board can be powered in two different ways, either connect a 12V power adapter with a standard 2.1mm barrel jack or use a DC converter and supply power via normal screw terminal.


Features of the Controller system

Controlling Water Pump: One of the crucial part of Hydroponic/Aeroponic system is the cycling of water in periodic intervals. A water pump is used to cycle the water. The controller should be able to switch on motor in a particular interval and keep it on for a configured time. Say run motor every 30 mins and keep it on for 3 mins. This settings can be configured from the mobile application.

Nutrient Feeder: In Aeroponic/Hydroponic the fertilizers (called as nutrients) are mixed into the water. In normal scenario we need to add it manually, the system uses two dosage pumps to add nutrients. We can add nutrients two way, either via the mobile app or by manually pressing a button. Through mobile app, we can specify how may ml of nutrients need to mixed to water.

Nutrient Mixer: Used a small wave maker to mix the nutrients while adding it.

Maintain Reservoir Water Level: One of the important thing to consider is, the water pump should not dry run, if it does then ready to buy a new one. In this version, used water level sensors to know the water level. The system used a solenoid valve, which is connected to a water source. When the water level goes down to a set level, system will activate the valve and start filling the reservoir. Once the water reaches a set level, system will switch off the valve.


I spent a lot of time in designing the board and come up with a very simple board with pluggable external relay modules. I am a beginner in PCB and electronics world. I had to spend my nights assembling the system in a bread board to see how each components behave. For me programming is easy but not playing with electronic components. At last I come up with a board design. Next big task was to find a shop to manufacture the prototype board. I was in touch with so many vendors and some never responded. I choose Protocircuits to do the PCB manufacturing.

Snapseed (55) 

Protocircuits manufactured a beautiful board for me. I etched several boards at home but this was awesome. I spend another night to solder the components to the board, see the assembled board below.


Snapseed (53)


Here Arduino and Bluetooth modules are not soldered instead plugged to a female header. External relay modules can be plugged via screw terminals.

About Protocircuits

I had a very good experience with Protocircuits. They are very professional in dealing with me and answering all my queries. I should thank Jeffrey Gladstone, Director Business development for his prompt replies and answering to all my queries. If anyone want to prototype a board, I highly recommend Protocircuits. You can reach them at

Buying Components: I highly recommend to buy any electronic components directly from the market than from any ecom providers. I did a comparison with price in the market and some online electronic shops and the price was very less in market. Take an e.g. of a chip 24LC256, in it cost 100rs for one, from market I bought the same for 40rs. If you are in Bangalore, take a ride to SP Road and I am sure you will get all the components you want.

Written by Sony Arouje

April 23, 2016 at 1:34 am

Posted in .NET

Control AC/DC devices using Arduino

leave a comment »

In forums I could see people asking how to switch on/off devices using Arduino. It’s a very simple approach using a relay module. In this post I will briefly explain how to do that.


Connecting Relay module to Arduino



Most of the relay module runs with 5 or 12v DC. Even if it’s 5v, never connect VCC of relay to Arduino. Always make sure Relay should powered from an external source. Most of the relay need more current (A) than Arduino can supply and might damage your Arduino. In the above diagram I used a battery (it should be a 12v battery, I couldn’t find 12v battery in fritzing) to as power source.

Here the Arduino and the Relay are powered from the battery. If you are powering Arduino separately via USB then remove the wire connecting to VIN of Arduino. Leave the GND connecting to Arduino as it is, all the connected devices needs common ground.

Relay need a trigger to switch on/off the connected device. If we supply high (5v) to INP pin of relay module the connected device will switch on, if we supply low then the device will get switched off. Here I connected D2 to INP pin of the relay. In code if we do digitalWrite to D2 with HIGH, the relay will get activated and LOW will deactivate the relay.

We can control AC or DC device using the relay. As you can see from the above diagram, the Relay is in series to the power supply going to the load. The wiring is very similar to a switch between a load and the power.

Written by Sony Arouje

April 19, 2016 at 4:12 pm

Posted in Arduino

Tagged with , , , , ,

Connect Arduino to external EEPROM

leave a comment »

Arduino has a tiny built in hard drive called EEPROM, in this area we can write data that should be available after power cycles. Unfortunately the size of this built in EEPROM is 512 byte for Atmega168 and 1kb for Atmega328. If our application is dealing with very small amount of data to persist then built in EEPROM is a good choice.

In some scenarios we might need to keep some logging info or any kind of data that needs more than 1kb then we need to go for external EEPROM. For this post I am using 24LC256, it can store 256kb of data. We can connect upto 8 ICs to a single Arduino by changing the voltage in A0, A1 and A2 pins.



Connection to Arduino



Here I connect A0 to A2 to GND and that gives me an address of 0x57.

VSS to GND, VCC to 5v, WP to GND, SCL to A5, SDA to A4

High on WP will disable writing, in my scenario I need to write, so I connect to GND.


Source Code

To deal with EEPROM reading and writing, I used a library called Extended Database Library (EDB). I also used the samples provided along with EDB but with some modifications.


#include <EDB.h> #include <Wire.h> #define disk 0x50 #define TABLE_SIZE 131072 // 1 device struct LogEvent { int id; int temperature; } logEvent; void writer(unsigned long address, byte data) { Wire.beginTransmission(disk); Wire.write((int)(address>>8)); Wire.write((int)(address & 0xFF)); Wire.write(data); Wire.endTransmission(); delay(5); } byte reader(unsigned long address) { byte rdata = 0xFF; Wire.beginTransmission(disk); Wire.write((int)(address>>8)); Wire.write((int)(address & 0xFF)); Wire.endTransmission(); Wire.requestFrom(disk,1); if(Wire.available()) rdata =; return rdata; } EDB db(&writer, &reader); void setup() { Serial.begin(9600); Wire.begin(); randomSeed(analogRead(0)); Serial.println("Creating db..."); EDB_Status result = db.create(2, TABLE_SIZE, (unsigned int)sizeof(logEvent)); if (result != EDB_OK) printError(result); Serial.println("Created db..."); createRecord(1); selectAll(); } void loop() { // put your main code here, to run repeatedly: } void createRecord(int recno) { Serial.println("Creating Records..."); = 1; logEvent.temperature = random(1, 125); EDB_Status result = db.insertRec(recno, EDB_REC logEvent); if (result != EDB_OK) printError(result); Serial.println("DONE"); } void selectAll() { for (int recno = 1; recno <= db.count(); recno++) { EDB_Status result = db.readRec(recno, EDB_REC logEvent); if (result == EDB_OK) { Serial.print("Recno: "); Serial.print(recno); Serial.print(" ID: "); Serial.print(; Serial.print(" Temp: "); Serial.println(logEvent.temperature); } else printError(result); } } void deleteAll() { Serial.print("Truncating table..."); db.clear(); Serial.println("DONE"); } void printError(EDB_Status err) { Serial.print("ERROR: "); switch (err) { case EDB_OUT_OF_RANGE: Serial.println("Recno out of range"); break; case EDB_TABLE_FULL: Serial.println("Table full"); break; case EDB_OK: default: Serial.println("OK"); break; } }



Happy coding…

Written by Sony Arouje

April 14, 2016 at 1:39 am

Posted in Arduino

Tagged with ,

%d bloggers like this: