Go Down

Topic: Billie's Hydroponic Controller (Read 214270 times) previous topic - next topic


Do you hane a picture, my valves use
NPT sizes.


These are the Valves I ordered from Ebay,  They  have male 1/2"-14 tpi  straight thread fittings.



I've decided to build this Hydroponic Controller. I've already ordered many parts but I have one question : what is the use of this valve (Pressure Solar Water Heater Dedicated 12V Solenoid Valve) ? This project seems to be very nice.

Thank you very much


Feb 24, 2014, 09:22 pm Last Edit: Feb 25, 2014, 01:56 pm by zatheros7 Reason: 1
@ lolocaledo
Hello- To answer your question directly, the solenoid valve is used to replenish the potable water in the hydroponic nutrient or aquaponic nutrient  tank. I am trying this valve as I have tried toilet tank valves in the past and they always fail at the worst time, or just fail and waste your money by flushing all of your nutrients out on the ground.

I too am building this project, started mine about 2 weeks ago, most of my parts are in from china and Hong Kong. Still missing a few. I attempted to build a PH controller using the practical maker arduaruim PH board a few years back. It did not work as the PH board can not be calibrated to span the PH range needed for plants. I was not aware of the Phidgets board at the time. (THANK YOU BILLIE!!)
I grow salad greens in plastic beer cups filled with small lava chips placed in PVC pipe similar to what Billie uses.

One of the pitfalls I have found with this build  is the additional code libraries needed have various and sundry names, and some have been updated and called a different name or obsoleted . I managed to sift the pearls from the shit and now have  Billie's latest code release compiling and loading on my mega. I want to get Billie's build working first , and then later add an  EC measurement to fully automate the system.  I currently use an BlueLab Truncheon for my EC reading now.

Where on the planet are you?   .nc  North Carolina?

With kind regards,


Does anyone else run into issues when connecting the tft sheild pins to the MEGA? I am trying to use less cable, and when I connect the 20 pins to their respective slots on the MEGA and screen displays the image, but the code and the screen do not work at all. Which pins are we supposed to connect to?


I have a like program running on an Arduino Mega. I'm also running a 3.2 inch TTF Touch Screen on a mega v2 shield.
Mega Shield utilizes pins 5V, 3V3, GND, 2-6, 20-41, & (50-53 for SD Card) I found it still runs 100% w/o pins 20 & 21 (the v2 shield does NOT have 20 & 21 thru header pins)


Mar 13, 2014, 11:15 pm Last Edit: Mar 13, 2014, 11:55 pm by Leinonen Reason: 1
Hi everyone. I am working with this too. My problems is here:

Code is the same as uploaded here, Billie's Hydroponic Controller V1.1.2b

So, i cant find working ITDB02_Touch.h anymore. At first i have working lcd and touch, but the touch was upside down?? I changed the library, to another downloaded from somewhere, and the calibration is too much at the left...

So, i tried the UTouch, and it worked pretty great, BUT.. Touch stop working, when plugged to external power supply??? Working OK when connected to computer, until reboot with ext power...

Anyway, the touch works with the ''right''  ITDB02_Touch.h, but upside down.. Work with external power too :)

Anyway, how i can calibrate this display?
Can i use Utouch someway?

Sorry about being noob, bought my first arduino about two months ago.. :) and sorry about my bad English.. :D
1st post at the forum , jihaa!


Hey Billie, I am interested in regarding hydroponic system. On the controller to add the EC (PPM) probe and Dosage for fertilizer. Interests elsewhere to get the cheapest material to the matter up and run.


Mar 30, 2014, 05:03 am Last Edit: Mar 31, 2014, 01:30 am by MiracleDro Reason: 1
Just wanted to say thanks for all the great info. I'm still turning on LED lights so I am far from understanding all of the code. However I have been growing in hydroponics for ten years and understand what I want to automate and how to do it. (just not how to write yet). What a great thread you have going here. What a great start for anyone looking to automate. I know it's time consuming answering all of these questions so just wanted to say thanks. Not a lot of people are willing to keep up with all the questions so it's great to see your willingness to spread the knowledge. An idea I had for nutrient mixing etc is to mix nutes in a different reservoir and then have a pump from there to your current reservoir. You could then set your floats to activate the pump in the nute reservoir. You could set the program to add from nutes reservoir if ec of the nutes reservoir is proper level else fill from plain water or whatever you currently do. I know I like to add in plain water for a couple top offs and then do half strength nutrients until I change the reservoir out so that could also be programmed as well.

In your new nutrient reservoir you could even have a separate controller if needed and setup similar to your ph method with a delay after a certain amount of nutrients are added in order to assure your reading is valid. If you using a 2 part nutrient you could set it up to add part A until ec is met then add part B in same fashion. Just my .02

Also would any of these TDS sensors work with arduino? http://webpages.charter.net/tdsmeter/products.html

Looking forward to learning more. Thanks again for all of the contributions from everyone.


Hello Billie,

Are you still there??


Hey DX,

Thanks for your kind reply!! The purpose of this project was to create a low budget, open-source controller which could be used all over the world so people could improve their crop yield and have more money to spend on other things other then food...
Though this project is still in it's infancy I hope one day it will be used by many people.
And off course I'm interested to see your code so you'll soon get a pm from me :D
The screen shots from your web interface look very promising, though implementing CO2 wasn't initially in my plan. I looked it up for some idea's about it and one could build a CO2 generator for a very low budget...So thanks for pointing this out to me ;)
Will be looking out for some cheap CO2 sensors out there...

With kind regards,


Hey Billy -Had not logged on for a while & didn't see your post & message.
I'll past the code to control CO2 using an analog source or 0-5vdc >>my monitor actually is 0-4vdc = 0-2000ppm but that's OK. There are a lot of off-the-shelf CO2 sensor/monitors made for the HVAC industry with o-10VDC output so a simple voltage divider circuit would do the trick (use 1% resistors & a mathched pair to get 0-5vdc & then change the arduino code for 0-5v or whatever.
The monitors I am using are made by a company called PureChoice -they contain a Telaire 6004 CO2 module >>and a Senserion SHT15 temp/RH sensor. Both the Telaire and Senserion sensors are the best of the best at their price level.  Too bad PureChoice went out of business because they had some great products -although good for me because I was able to buy the NOSE monitors on the cheap (less than the cost of the sensors! --and less than the price of the crappy no-name sensor I saw that some guy in another post bought from futurlec (or something like that).
Anyway, back to the sensor. Here is the NOSE unit http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&item=231088338207 -And
The NOSE has the Telaire & Senserion sensors & uses a Freescale Coldfire MCF5329 processor, running uCLinux with 256MB SDRAM & 128MB Flash memory, external LAN USB controller >which is strange because there are no USB ports -plus the processor has multiple USB ports and an onboard LAN controller -They really overkilled everything. There is also a SVGA LCD controller onboard but it's driving a 8x2 LCD!  There is a webserver so you can view the temp/RH/CO2 via the web as well as a lot of other data about the device status (mostly there to communicate with PureChoice servers that no longer exist -So every once in a while you get this "NO HTTPS" message.
I'm working on logging software with notifications if the temp/rh or co2 get out of whack (sms & email) but for now I just have remote view and graphing -which will keep logging as long as the host computer is running >can be remote computer, I'm currently loggin a couple local NOSE monitors & another in Canada.

Here is the CO2 control code. I don't use bottled CO2 so "fuzzy logic" (PID) control was not something I was concerned with but might be something to add later...
There is also some lines for LCD control that I don't use because the NOSE has its own display -but if you are using another CO2 sensor you might want an LCD display.

Looking at the code, I can say that it definitely can use some cleaning up!
But hopefully you or somebody else will find it useful!

code in next message (this post is too large)


// CO2 Controller for NOSE Monitor
// Feel free to distribute all or part of work but leave reference to www.dxhydro.com and monitor.dxhydro.com
// push button connect to GND and to PUSH_BUTTON_PIN
// SPDT switch connect center to GND, other switch pins to MODE_1_PIN and MODE_2_PIN

// if need pins D0 and D1 then remove all rows that contain 'Serial'

//default is for a pushbutton to scroll from 1200, 1300 & 1450 or whatever you enter for setting values.
//A ON-OFF-ON toggle can also be used. If more level options are desired, they could be added to the code.
//Three was enough for me & If I want to go with a higher or lower set point, I'll change the code.

#define USING_PUSH_BUTTON 1   // 1 - push button 0 - SPDT switch

// pins

#define CO2_PIN A6
#define LIGHT_PIN A7

#define RELAY_PIN 12

// push button  start
#define PUSH_BUTTON_PIN 2  // for push button only pin 2 !!!
#define buttonInterrupt 0
// push button  end

// SPDT switch  start
#define MODE_1_PIN 2
#define MODE_2_PIN 5
// SPDT switch  end


#define L1600_PIN 10
#define L1400_PIN 8
#define L1250_PIN 6

// sensors constant
#define CO2_LEVEL_TRESHOLD 200   // 200ppm
#define CO2_BAD_LEVEL 320  // 300 ppm If reading is below 350, there is a problem with the sensor & CO2 relay will turn OFF

#define LIGHT_HIGH_LEVEL  256 //if light sensor > 300 (0-5V == 0-1023  1.5v=~300  1023*1.5/5=~300)then light is on else off
// might need to tweek this number a bit, depending on the photocell -you can bypass this input too

#define DEFAULT_CO2_MAX_LEVEL 1600    // OLD WAS 1300

#define BUTTON_COUNT_ADDR 0  //address in internal EEPROM for store CO2 max level when using push button

#include <EEPROM.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
//Libs for I2C LCD

LiquidCrystal_I2C lcd(0x27,16,2); // set the LCD address to 0x27  CHANGED TO 0x21

int maxLevelsCount=3;
int maxLevels[] = {1600,1400,1250};

boolean waitForMax=true;

boolean isPushButton=false;
int buttonCount=0; // ->maxLevels[0] == 1600
boolean buttonChange=false;

void prepareSwitchPins(int pin1, int pin2){
 pinMode(pin1, INPUT);
 pinMode(pin2, INPUT);
 digitalWrite(pin1, HIGH);
 digitalWrite(pin2, HIGH);

void detectLevelSelectorType(){

 isPushButton=digitalRead(PUSH_BUTTON_PIN)==HIGH && digitalRead(PUSH_BUTTON_SELECTOR_PIN)==HIGH;

void setupPushButton(){
 attachInterrupt(buttonInterrupt, Rise, RISING);

void setupSPDTSwitch(){
 prepareSwitchPins(MODE_1_PIN, MODE_2_PIN);

void setPinsMode(){
 pinMode(L1600_PIN, OUTPUT);
 pinMode(L1400_PIN, OUTPUT);
 pinMode(L1250_PIN, OUTPUT);

int getCO2Level(){
 byte i=0;
 long s=0;
 int a=s/10;
 if(a>820){a=820;} // 4 volts its 820 from analogRead (1024/5 * 4 = 820)   5 -> max volts that read arduino
 int res=map(a, 0, 820, 0, 2000);  // 0 - 4  volts ->  0 - 2000 ppm
 return res;

int getLightLevel(){
 byte i=0;
 long s=0;
 int a=s/10;
 return a;

int getCO2MaxLevel(){
   return maxLevels[buttonCount];
   int m1=digitalRead(MODE_1_PIN);
   int m2=digitalRead(MODE_2_PIN);
   if(m1==HIGH && m2==HIGH){res=maxLevels[1];} //1400
   if(m1==LOW && m2==HIGH){res=maxLevels[0];} //1250?
   if(m1==HIGH && m2==LOW){res=maxLevels[2];} //1600?
   return res;

// 0 - OK may switch on relay  1 - light sensor <300  -1 - CO2 sensor failure
int getMaySwitchOnRelay(){
 int co2_level=getCO2Level();
   int light_level=getLightLevel();
   int may_ovveride=digitalRead(MAY_OVVERIDE_PIN);
   int light_ovveride=digitalRead(OVVERIDE_LIGHT_PIN);
     return light_ovveride==HIGH?0:1;
     return light_level>LIGHT_HIGH_LEVEL?0:1;
 }else return -1;

//state - true then ON relay else Off relay
void switchRelay(boolean state){
   digitalWrite(RELAY_PIN, HIGH);
    lcd.setCursor(0, 0);
    lcd.print("CO2 ACTIVE");
   digitalWrite(RELAY_PIN, LOW);
     lcd.setCursor(0, 0);
    lcd.print("CO2 OFF   ");

void switchOffAllLevelLeds(){

void showLevelLed(){
 int maxLevel=getCO2MaxLevel();

void setup(){
   lcd.init(); // initialize the lcd
 if(buttonCount>=maxLevelsCount){buttonCount=0; buttonChange=true;} //reset if EEPROM is clear
   Serial.println("PUSH BUTTON");
   Serial.println("SPDT SWITCH");


void loop() {

   Serial.print("Change CO2 level to:");
   EEPROM.write(BUTTON_COUNT_ADDR, buttonCount);

 int sres=getMaySwitchOnRelay();
   //getting co2 level
   int co2max=getCO2MaxLevel();
   int co2min=co2max-CO2_LEVEL_TRESHOLD;
   int co2level=getCO2Level();
   Serial.print("CO2: ");

   Serial.print(" max level:");
   lcd.setCursor(0, 1);
       lcd.print("Set Point: ");
   // condition for switch relay
   if(sres==-1){Serial.println("CO2 sensor failure!");}
   if(sres==1){Serial.println("Not enough light!");}

//debounce push button logic

volatile int buttonState = LOW; //initial button state
volatile long lastDebounceTime = 0;   // the last time the interrupt was triggered
long debounceDelay = 30;    // the debounce time; decrease if quick button presses are ignored

void Rise()
 long currentTime = millis();
 if ((currentTime - lastDebounceTime) > debounceDelay)
   lastDebounceTime = currentTime;
   if (buttonState == LOW)
     buttonState = HIGH;
     attachInterrupt(buttonInterrupt, Fall, FALLING);

void Fall()
 long currentTime = millis();
 if ((currentTime - lastDebounceTime) > debounceDelay)
   lastDebounceTime = currentTime;
   if (buttonState == HIGH)
     buttonState = LOW;
     attachInterrupt(buttonInterrupt, Rise, RISING);

void Switch()


To those still having issues with the Greenhouse controller touchscreen, here is how I setup mine

Running on mega2560
SainSmart 3.2 touchscreen with the adapter board. Kit C97

I made three ribbon cables to go between the adapter and the mega and plugged them in as if plugged directly.
               I now have access to those missing pins :)

Do a global search and replace for the ITDB02_Touch  and make it Utouch

Do not downgrade gcc.
The X axis is the problem with the system regardless of ITDB02_Touch or Utouch

The Y axis is fine, the scaling is fine.

X reads Right to Left NOT Left to right as it should.
Someone can probably tell me which two wires to swap for that to work normally
      but cant be fixed if you are plugged in directly to the mega :(

So you have about a dozen simple edits:

Find every         if ((x>=207) && (x<=307))
                                  These numbers can be ANY number

aka:                       if ((x>=LeftSideasZeroValue) && (x<=RightSideasZeroValue))
And we need:    if ((x>=RightSideasZeroValue) && (x<=LeftSideasZeroValue))
Subtract each number from 312 and put the new values back but reverse them

                                  if ((x>=207) && (x<=307))   becomes    if ((x>=5) && (x<=105))

Have fun.


is there an easy way to run this on the yun without lcd/tft but with website controls/monitor?


Hey Everyone,

Long time since I've been on the forum...Great to see that this thread has taken off so nice!! :)
I'm currently busy on a few projects with Arduino - 3D printer, A domatica system for the garden and...A new version of the Hydroponic Controller. This last one will be upgraded so that one can also measure/control the EC value of the nutrient tank.
Also will be trying to incorporate the ethernetshield so it can output data to Cosm (or what it's called today ;) ) if there is enough room for it. I'm currently using the Aduariumshield from Practical Maker as hardware since this shield has got everything we need for this project. Only an Ethernetshield and TFT screen need to be added.
When I'm ready for it I will put the documentation for this project online and you'll all be able to enjoy this upgrade ;)

I just wanted to ask... Have you tried to use the integrated SD card slot on the rear side of the LCD/TFT panel?
When I use the adjustable shield directly on top of the Mega, it works, but with the (8-bit) wiring like in your picture and adding MISO, SCK, CS(SS) and MOSI  to pins 50,52,53,51 (and shield's 16,17,35,34)  I have no luck so far. I am not sure which other pins I should connect or if it is at all possible. I do not know if you are using the break-out SD module for convenience or if you have ran into problems also.

The integrated SD reader from that specific TFT screen wasn't functioning. The seller on Ebay admitted this after a long time communicating about it... So I had to use an external one.

Hello Billie,

Are you still there??

Yes I am, but have been doing some other stuff. :)

is there an easy way to run this on the yun without lcd/tft but with website controls/monitor?

I don't have a Yun so I can't say...

Greetings Billie

Go Up