Automated Aquaponics Project

I purchased an Arduino a few months ago and after doing a few tutorials in my spare time I decided to embark on my project.

Let me first just say that I as an environmental scientist my knowledge of electrical engineering and programming is limited from an educational background, so go easy on me :blush:

My ultimate goal project involves the integration of Arduino with my aquaponics set up (hydroponics combined with aquaculture), which is also a simultaneous work in progress pictured below: I have broccoli, several types of mint, sugar snaps, 3 species of tropical vines, tomato seedlings, lettuce seedlings, squash seedlings, dill, lemon balm, and a few other herbs and plants with economic value; this is mostly an experiment geared at identifying the fastest and best growing plants in this type of system.

As of now, I have a photoresistor that will later turn on a LED array when it gets dark (in its place there is only one LED to show the code works correctly) I have a temperature sensor, and a LCD screen for displaying data. The LD currently displays "lux" as light units, but I have found a photoresistor is far too unprecise for such a measurement (aside from not being necessary, the lux calculation is a bit cumbersome). I am powering this current setup with the 5V and 3.3V onboard pins of the Arduino.

I have plans to make this setup independent of a power supply, so I have purchased a battery case that currently contains 8 1.2v 2,500mAh rechargable cells (also pictured) for a total of 9.6V in the cell. I have no interest in running the arduino as well on battery power yet (don't want to blow it during my learning curve, already blew some LEDs ^o^ and I know I would need more juice) but I have replaced the 5V and 3.3V sources with the battery into the breadboard. However, when I do so my LCD screen goes white and the circuit does not behave (or work for that matter) as before. My initial thought is that since the output of the cells is highly variable (so says my handy meter) I need a capacitor to make up for times that the current drops below the operational threshold. Is this at all correct. If so what would be the appropriate capacity of this capacitor?

I have posted the code below. It is almost 100% "borrowed" code snippets that I have taken from other projects without copywrite protections. I would greatly appreciate productive criticisms with errors and potential inefficiencies. Thanks in advance for everyone's interest and comments!!!!!

/* ------------------------------------------------------------------------------- */

//PhotoResistor Pin Variables
int lightPin = 1; //the analog pin the photoresistor is connected to
//the photoresistor is not calibrated to any units so
//this is simply a raw sensor value (relative light)

//TMP36 Pin Variables
int sensorPin = 0; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures

float temp;
int tempPin = 0;
int ledOut = 9; // LED on Digital Pin 7
int aiValue = 0; // input value
int setPoint = 700; // Trigger value for led out

// LCD Variables
#include <LiquidCrystal.h>

// Connections:
// rs (LCD pin 4) to Arduino pin 12
// rw (LCD pin 5) to Arduino pin 11
// enable (LCD pin 6) to Arduino pin 10
// LCD pin 15 to Arduino pin 13
// LCD pins d4, d5, d6, d7 to Arduino pins 5, 4, 3, 2
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13; // pin 13 will control the backlight

void setup()
{
pinMode(backLight, OUTPUT);
digitalWrite(backLight, HIGH); // turn backlight on. Replace 'HIGH' with 'LOW' to turn it off.
lcd.begin(16,2); // columns, rows. use 16,2 for a 16x2 LCD, etc CHANGE TO APPROPRIATE SIZE
lcd.clear(); // start with a blank screen
lcd.setCursor(0,0); // set cursor to column 0, row 0 (the first row)
lcd.print("Temp:"); // change this text to whatever you like. keep it clean.
lcd.setCursor(0,1); // set cursor to column 0, row 1 (the second row)
lcd.print("Lux:"); // Reads "Lux" to show that corresponding reading is light intensity
lcd.setCursor(10,0); // set cursor to column 0, row 0 (the first row)
lcd.print("F"); // change this text to whatever you like. keep it clean.

// if you have a 4 row LCD, uncomment these lines to write to the bottom rows
// and change the lcd.begin() statement above.
//lcd.setCursor(0,2); // set cursor to column 0, row 2
//lcd.print("Row 3");
//lcd.setCursor(0,3); // set cursor to column 0, row 3
//lcd.print("Row 4");

Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}

void loop()
{
int lightpin = 1; // photoresistor on Analogue Pin 1
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);

// converting that reading to voltage, for 3.3v arduino use 3.3
float voltage = reading * 5.0;
voltage /= 1024.0;

// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)

Serial.print(temperatureC); Serial.println(" degrees C");

// now convert to Fahrenheight
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF); Serial.println(" degrees F");

temp = analogRead(tempPin);
temp = temp * 0.48828125;
lcd.setCursor(5,0); // set temp display to column X , row X
lcd.print(temp); // print the temp

int lightLevel = analogRead(lightPin); //Read the // lightlevel
float lightlevel = (lightlevel / 2.0); //adjust the value 0 to 900 to
lightLevel = map(lightLevel, 0, 900, 0, 255); //span 0 to 255

lightLevel = constrain(lightLevel, 0, 255);//make sure the value is betwween 0 and 255
Serial.println(analogRead(lightPin)); //Write the value of the photoresistor to the serial monitor.
lcd.setCursor(4,1); // set Lux display to column 4, row 1.
lcd.print(analogRead(lightPin)); //Write the value of the photoresistor to the LCD screen.

aiValue = analogRead(lightpin); // Read the analogue input value
if (aiValue < setPoint)
{
digitalWrite(ledOut, HIGH); // It has got dark, turn the LED on.
}
else
{
digitalWrite(ledOut, LOW); // It is light again, turn the LED off.
}
delay(1000); //waiting a second
}

/* ------------------------------------------------------------------------------- */

Board.jpg

boardlcdandextbatt.jpg

I have plans to make this setup independent of a power supply,

Is the tank lighting and pump also independent of a power supply?

I can't really imagine running a hydroponics setup without power.

Those pictures are too small to male out any detail. I can't see the battery setup, or what it is powering.

However, when I do so my LCD screen goes white and the circuit does not behave (or work for that matter) as before.

Which LCD screen? There appear to be 2 LCD screens. The Arduino is capable of powering the LCD from it's regulated 5V supply. Directly powering the LCD with 9 volts doesn't seem like a good idea to me, unless the idea is to make the LCD suffer the same fate as the LEDs.

I just signed up for an account today to ask the same question (put a screen on my automated aquaponics setup) and I did a search first and found this post. I couldn't believe my luck that you are trying to use a screen too to automate aquaponics. I don't have an electrical background either so I bought the early edition of an automation kit from Iowa Aquaponics a while ago, so I could learn and do it myself. Instead of a screen though, it uploads everything to a webapp it comes with and that's what you use to see and control everything. Sometimes it's just frustrating when I'm fiddling with my system and I don't have my phone on me and I can't see something (my aquaponics system is in my basement and sometimes I'm just lazy). Where did you get your screen from? Can you please post bigger pictures and a description of how to hook the screen in? Thanks!

I think I may have given you too much information off the bat :stuck_out_tongue:

I have plans to make this setup independent of a power supply,
Is the tank lighting and pump also independent of a power supply?

No they are not yet.

However, when I do so my LCD screen goes white and the circuit does not behave (or work for that matter) as before.
Which LCD screen? There appear to be 2 LCD screens. The Arduino is capable of powering the LCD from it's regulated 5V supply. Directly powering the LCD with 9 volts doesn't seem like a good idea to me, unless the idea is to make the LCD suffer the same fate as the LEDs.

There is only one LCD screen. You should be able to see more clearly in the photo attached.

What I want to do is change the power source of the circuit from the on board Arduino to an external power. Later on I will use a larger battery and a solar panel to recharge. My question is, (and you somewhat answered) is the 9.6 V too much for the circuit? I was using the 3.3 and 5V ports on the arduino, so I guess that is still too much juice? Also, since when I read the outpout of the battery source it varies from 3v to 9.6 v, so would that mean I need a capacitor to use a battery?

Beagleears, Feel free to use my code, this picture should help you find a way to attach the LCD screen. It is not touch screen, only displays existing data on it. If you need further information, be as specific as possible.
The webapp sounds exciting and cool Is there a way you could tell me more about this, I'm definitely interested. Maybe we can trade some information because this is something I'm interested in doing.

There is only one LCD screen. You should be able to see more clearly in the photo attached.

In the tiny picture, the batteries in the holder looked a bit like an LCD.

Powering the Arduino with the battery pack would be OK. Using the 5V and 3.3V pins to power things like the LCD is the correct way to do it, as long as the current needed does not exceed the limits of the Arduino.

Also, since when I read the outpout of the battery source it varies from 3v to 9.6 v, so would that mean I need a capacitor to use a battery?

No. You need to recharge that batteries when they get below about 7V.

The webapp is great, I just wanted a screen too. I got lucky finding the kit when I did because they wanted testers so it was cheaper and I could sign-on to google talk at certain times to ask questions and give them feedback on how easy it was or where I ran into problems. But in the agreement I was told I couldn't post any Arduino code until they were done testing, which we already finished, and came out with their proper kit. I didn't get to download the webapp because they were making constant changes, but I know the it comes with the book because part of each chapter talks about the sensor/arduino/webapp working together. Uploading and customizing just wasn't part of what they were testing. It runs on Google's App Engine so you need a Google account and it's written in Python which was another plus for me because my only programming experience ever was with Python.

Thanks for uploading the bigger picture, that helps. Someone turned me to this Adafruit screen:

It looks like the same one and they have a tutorial so maybe that will answer your power problem? It takes up too many pins for me so I think it's out for my solution. From the tutorial it seems the screen was meant to be powered in the Arduino's power range so the 9.6V might damage it.

Cool thanks for the information. I have contacted Iowa Aquaponics to see if they need any help as well for beta testing. My LCD screen is a 16X4 so make sure that if you use the code that I have provided to change it accordingly for the 16x2 lcd screen. With that being said I would recc. the larger screen because the cost is not much more at all.