Billie's Hydroponic Controller

Hello everybody,

As promised i would post again on this forum :wink:
As mentioned in the previous post i'm making a hydroponics controller, which can monitor and adjust pH, Temperature and Humidity. Write a log to SD card with the data of all the inputs plus the amount of light measured, tagged with the current Date & Time.
My build is nearly done. I'm currently at the stage where I'm testing it small scale...

Here is a video i made to show of the graphic menu. Something where I put quite a lot of work in...

Since I've began programming there where not to many people out there that where willing to share their code, that's a shame really...because it's all open-source...
So...I attached the code I wrote for this project. :smiley: Use it, Mod it, do what you will with it :wink:

Edit: It's written with Arduino IDE 1.0...

HydroController_beta_1_0_1.ino (30.9 KB)

Billie, This is a really nice project. Lots of people will be interested in doing something very much like this.

To help us, could you post some drawing/diagram of the input and output devices and how they connect to the Mega?

Also, exactly what display are you using, and what code/library do you use to drive it?

Did you research different pH sensors? What did you find? That's a key part.

Nice work!

Hey Terry,

I can draw a diagram on paper and scan it if you like, with CAD or Fritzing i'm not so good :wink:
I'm using the Sainsmart 3.2" TFT touch screen. Ordered it from Ebay. It uses the UTFT and ITDB02_Touch library from Henning Karlsen
For the pH I'm using a Phidgets 1130 pH/ORP module, this has got a BNC connector where I can connect the pH probe (also ordered from Ebay) to. The pH probe itself is the cheapest thing I could find, because the primary idea behind this project was to make a cheap pH controller which wouldn't break my wallet :wink:
I must say that the accuracy of the probe is more then enough for hydroponics use. It has got an accuracy of 0.02, which isn't to bad at all. After that was complete the implementation of all the other sensors was a piece of cake :wink:

All other hardware and libraries are mentioned in de code, if you want to know...

Here is a 'simple' diagram of all the sensors.

The 3.2" TFT fits on top of the mega. But you only need to connect pins 2-6 for the touch, 22 - 41 for the display & connect GND, VCC and 3.3V
Then for the SD card...you can use pin 50 --> MISO, 51 --> MOSI, 52 --> SCK, 53 --> CS.
The RTC module...SDA --> pin 20, SCL --> pin 21
The four channel relay is pretty self explanatory :wink:

Without the cables attached..

And with...

Greetings... :wink:

Nicely done.

Very interesting to see the redraw times for those displays, not exactly lightning eh? I've got a couple of similar displays (not used yet) and have never been able to get a good idea of how fast they will be.


Rob

Hey Rob,

If you check out the code you will notice that there's about one and a half second delay time. This affects the screens refresh rate also :wink:

there's about one and a half second delay time

But surely not in the middle of drawing a screen.

For example the function mainscr() does nothing but draw stuff, as indeed do all the functions that draw a screen as far as I can tell, and yet it's pretty slow. I'm just wondering if that's a common thing with these type of displays.


Rob

I guess it's the case with mine, but the refresh rate is fast enough for my application. So I'm quite happy :slight_smile:
Today I connected all the sensors to the box and after some debugging...one VCC cable which had a bad connection...got it running.

In front you see the pH probe and between the probe and the case is the photo-sensor encased in some plastic tubing.

On the left side is a 'recovered' serial connector from an old pc. It houses the connection to the two float sensors and the photo-sensor. On the right hand side is the BNC connector for the pH probe. Between these is the SD card.

Tomorrow I'll put the sensors in a small barrel (20L) and start building the dosing station so the next tests can be run...

Silly Question.. where do you found your project box? I want one box with transparent material in front but i dont know where to buy one (water resistance)

I ordered mine at conrad. They got loads of different boxes. Mine is polycarbonate and has a moisture seal between the lid and box itself... As I'm going to install it in my greenhouse.

Oh, and i've got an update for the sketch...
Rewritten the pH algorithm. Which included incorporated 'smoothing' and a pulsing (on/off) effect for the dosing pumps.

Greetings... :wink:

Hydroponic_Controller_v1_1_0.ino (45.7 KB)

I've also made a new videoclip. Turn up the volume though, then you'll hear the pumps turning on and off...

Looks good, but I don't think Steven Spielberg has anything to worry about :slight_smile:


Rob

Funny...Just had a meting with Mr. Spielberg about this...In 2018 the new clip comes out. I can say that the soundtrack will be awesome!! :wink:

Can't wait, he does good stuff.


Rob

Wow Billie this is so cool..

I'm planing to monitor hydroponics over the internet. I bought the arduino mega328 and the ethernet shield.. Where do I start with? Can you give the steps on which area should I work on? Any help is so much appreciated.

Thank you

Hey Sunmark14,

I'd start with gathering all the required hardware to monitor. The big question is 'what' you want to monitor/control.
The hardware i used came from Ebay except for one part. Thats the Phidgets 1130 pH/ORP module. If your from the US, getting one shouldn't be a problem. If you live in Europe, you'll have to look a bit harder :wink:

These are the parts i used...

Arduino Mega 2560
Aquarium Peristaltic Dosing Pump head
pH Electrode Probe
Phigets 1130
4 Channels 5V Relay Module for Arduino
Pressure Solar Water Heater Dedicated 12V Solenoid Valve
DHT11 Temperature & Humidity Sensor Module
20PCS Photoresistor GL5539 LDR Photo Resistors Light-Dependen?t
3.2" TFT LCD Shield + Touch Screen TF SD Reader
2x Gray Duckbill Side Water Level Sensor Liquid Float Switch
SD Card Module Slot Socket Reader For Arduino
14pcs 2X40Pin Double Row 2.54 breakaway Male header
I2C RTC DS1307 AT24C32 Real Time Clock Module
5 PCS Bread Board Prototype proto Board 10*20cm
DC 9V/1A Power Supply For Arduino

After you acquired the parts you need, check out the code i wrote. Almost everything is made up in blocks, so if you don't need the LCD...you can leave out the graphical and touch functions. And the logical part will still work. Tip also remove the call to those functions in the void setup() and void loop().

Have fun and remember...If you improve on this design please post it back here :wink:

Any chance of some more detailed instructions?

How are you changing the temperature, I guess you can only monitor that? How are plants watered?

No, Temperature and Humidity are controlled via a bank of fans. Ten in total, which are turned on via one of the relays.
The total amps for the fans is about 8A. And this includes the spike when the fans are turned on.
The control for the fans isn't picture perfect, but will be rewritten when I have the time for it. The problem with the temp/humid control is that there's no hysteria, so if the temp/humid swings around the setpoint the relays will turn on/off quite fast and then there's a chance that they burn out...

More detailed instructions then already provided will not be made. I think that the provided information should be enough to build one yourself. I've included the schematics for all the sensors, where I bought them and provided the code... The rest, how you actually solder the parts you can find out for yourself...just ask Google and it will provide...
The most difficult thing was writing the pH control algorithm, since I'm not a programmer. And that's provided in the beginning of the post :wink:

I might be persuaded to build one for you, but that's gonna cost you... :stuck_out_tongue:
Hey...isn't figuring out these things not part of the fun in playing with Arduino???

Don't forget...Have fun and if you run into trouble while building one, just ask your question here and I will try to answer you as good as I can... :wink:

BillieBricks:
The problem with the temp/humid control is that there's no hysteria, so if the temp/humid swings around the setpoint the relays will turn on/off quite fast and then there's a chance that they burn out...

BillieBrick

I had this same problem in designing my aquarium/aquaponics monitor except in my case the issue was with my float switches which controlled my pumps via relay. With the water moving it would cause waves in the tank causing my float switch to go up and down turning on and off my relay constantly. The medicine to this problem is in the blink without delay example code http://arduino.cc/en/Tutorial/BlinkWithoutDelay. Basically what I did was made to variables for each pump one that records the last time the float was high and then one that records the current time the float was high and then previous - current > 5 sec turn on pump. I also included an if else that say if float is low reset previous. If you have any question or want some example i can dig it up and help you out just pm me.

superman:
BillieBricks

I had this same problem in designing my aquarium/aquaponics monitor except in my case the issue was with my float switches which controlled my pumps via relay. With the water moving it would cause waves in the tank causing my float switch to go up and down turning on and off my relay constantly. The medicine to this problem is in the blink without delay example code http://arduino.cc/en/Tutorial/BlinkWithoutDelay. Basically what I did was made to variables for each pump one that records the last time the float was high and then one that records the current time the float was high and then previous - current > 5 sec turn on pump. I also included an if else that say if float is low reset previous. If you have any question or want some example i can dig it up and help you out just pm me.

Thx for the input! Yet I think the problem I have is slightly different then your situation. You are using time to prevent the relays from burning out and I'm using temperature and humidity.
For example: Let's only use the temperature for this one... I set the set point for the temperature at 25°C. So when the temperature reaches 26°C the fans will turn on. Resulting in the machine registering the temperature drop to 25°C, but actually it is 25,9°C. The fan's stop working and almost immediately the temperature registers 26°C and everything starts over again.
Now with a hysteria you have a set point (25°C) and a deviation or hysteria (value the setpoint can deviate). So this would result in (assuming the set point is 25°C and the hysteria being 2°C) that the fan's turn on at 26°C and turn of at 24°C (actually 24.9°C), giving the machine a whole 1,1°C to climb before the fan's are turned on again...

Both have their advantages and disadvantages. I could be wrong off-course :wink:
Your idea is nice thinking by the way :wink:

I have a question for you...How many float switches do you use in your setup?
I've got two...one on the bottom and one on top. When the top one is 'LOW' the machine registers this, but doesn't do anything, other then displaying 'Tank Half Full' (we're optimistic like that :wink: ) Only when the bottom one is 'LOW' the solenoid valve is turned open. This remains open until both float switches are 'HIGH' again. Meaning the nutrient tank is full...

Oh and of course I've read the article 'blink without delay' which gave me a headache before I got around it... :fearful: Still have to use the base code to start from, I'm ashamed to say :fearful: