Creating a robust pH/EC monitor for hydroponics using Atlas probes and an Arduino

linkedinrssyoutubeinstagram
image_pdfimage_print

A few months ago I talked about how you could build a simple sensor station for your hydroponic projects using an arduino (see here). However this small project used the relatively cheap – but I have found not very robust – pH/EC probes and boards from gravity which makes it a poorer choice for a more professional project aiming to constantly monitor the pH/EC of a production hydroponic setup. Today I am going to tell you how you can build a dedicated pH/EC monitor using the robust pH probes from Atlas, which also have several important advantages we will be discussing within this post. I would also like to point out that Atlas is not paying me anything to write this post, I write just because of my experience using their probes.

The pH/EC probes from gravity have several problems when looking for a robust sensing setup. The first issue they have is that the probes are not rated for constant immersion, so they are damaged if you place them within solution the whole time which is probably what you want to do within a production hydroponic setup. The second issue is that the boards require cable connections to the Arduino which introduces a significant amount of noise that can causes problems with measurements. Due to poor isolation there can also be issues with the gravity boards when measuring EC/pH at the same time. To overcome these issues we can use probes and boards from atlas which have the advantage of having no cable connections to the Arduino – connections are through pins directly – plus the probes are rated for constant immersion and are much more robust. These are the things we would need to build this project:

As you notice this sensor project is much more expensive than the sensor station I had discussed before, with a price tag of around 490 USD (not including shipping). However when looking for a robust setup you definitely should favor the additional expense as this will likely be paid off with much longer service times.

When you get the pH/EC kits the first thing you want to do is change your EZO boards (the small circuit boards that come with them) to i2C mode so that you can use them with your mini tentacle shield. To do this follow the instructions here, follow the instructions in the “Manually switch between UART and I2C” section, use female jumpers to make this process easier. Note that you can use your LCD shield analogue 5V and ground pins when you need power within the process.

//Libraries
#include <U8glib.h>
#include <stdio.h>
#include <Wire.h>
#include <Arduino.h>

#define TOTAL_CIRCUITS 2  

///---- variables for pH/EC tentacle shield ------- //

#define TOTAL_CIRCUITS 2   

char sensordata[30];                  
byte sensor_bytes_received = 0;       

byte code = 0;                        
byte in_char = 0;  
int channel_ids[] = {99, 100} ;                   
   
// ------------------------------------------------ //    

// EC values // CHANGE THESE PARAMETERS FOR EC PROBE CALIBRATION
#define EC_PARAM_A 0.00754256

//pH values // CHANGE THESE PARAMETERS FOR PH PROBE CALIBRATION
#define PH_PARAM_A 1.0
#define PH_PARAM_B 0.0

#define XCOL_SET 55
#define XCOL_SET2 65
#define XCOL_SET_UNITS 85

//--------------------------

U8GLIB_NHD_C12864 u8g(13, 11, 10, 9, 8);   
float pH, EC;

//--------------------------

void draw() {
  u8g.setFont(u8g_font_04b_03); 
  
  u8g.drawStr(0,11,"pH:");
  u8g.setPrintPos(XCOL_SET,11);
  u8g.print(pH);
  
  u8g.drawStr(0,21,"EC:");
  u8g.setPrintPos(XCOL_SET,21);
  u8g.print(EC);
  u8g.drawStr( XCOL_SET_UNITS,21,"mS/cm" );
  
}

void read_tentacle_shield(){

  for (int channel = 0; channel < TOTAL_CIRCUITS; channel++) {      
  
    Wire.beginTransmission(channel_ids[channel]);     
    Wire.write('r');                         
    Wire.endTransmission();                       
    
    delay(1000); 

    sensor_bytes_received = 0;                        
    memset(sensordata, 0, sizeof(sensordata));        

    Wire.requestFrom(channel_ids[channel], 48, 1);    
    code = Wire.read();

    while (Wire.available()) {         
      in_char = Wire.read();           

      if (in_char == 0) {               
        Wire.endTransmission();         
        break;                          
      }
      else {
        sensordata[sensor_bytes_received] = in_char;      
        sensor_bytes_received++;
      }
    }
    
    if (code == 1){
      if (channel == 0){
        pH = atof(sensordata);
        pH = pH*PH_PARAM_A + PH_PARAM_B;
      }
      if (channel == 1){
        EC = atof(sensordata);
        EC = EC*EC_PARAM_A;
      }    
    }
  }
  
}

void setup()
{
    pinMode(13,OUTPUT);  
    Serial.begin(9600);
    u8g.setContrast(0);
    u8g.setRot180(); 
}

void loop()
{
 
  digitalWrite(13, HIGH);       
  delay(800);
  digitalWrite(13, LOW);   
    
  read_tentacle_shield();

  u8g.firstPage();
    do  {
      draw();
    } 
      while( u8g.nextPage() );          
      
}

Once you have changed the EZO boards to i2C you can now plug everything into the arduino and upload the code into your arduino. Plug the EZO boards into the mini tentacle shield and then plug that shield into the arduino. You’ll notice that the EZO boards make it impossible to plug the LCD screen directly on top – as the EZO circuits make the shield too tall – so you should use stackable headers to extend the connections so that you can plug the LCD screen on top without any problems. Make sure you download and install the U8glib library in your arduino IDE before uploading the code.

As with the previous code you’ll notice there are variables called PH_PARAM_A, PH_PARAM_B and EC_PARAM_A within the beginning of the code that you should change in order to calibrate your probes. Follow the instructions about calibration I gave in the previous post in order to figure this out. Using the calibration solutions that come with your kits you’ll be able to perform this calibration procedure. Whenever you want to calibrate your probes you should reset these variables to their original values, reupload the code and retake measurements.

Following this guide you will have a very robust sensor setup using very high quality probes. These probes are also coupled with a board that has no wire connections with the arduino, offering very high quality readings with very small amounts of noise. Additionally the LCD shield opens up the possibility to add more sensors to your station so that you can monitor, temperature, humidity, and carbon dioxide potentially from a single place.

Facebooktwitterredditpinterestlinkedin

6 Comments

  • August 16, 2017 @ 6:48 pm

    Dr. Fernandez, thanks for this follow up article on Arduino application for Hydroponics.

    • admin
      August 17, 2017 @ 3:58 am

      Thanks for writing. You’re welcome!

  • September 5, 2017 @ 1:08 am

    Can you share circuit diagram of this project? or photo of all part that has been assembled. Thanks

    • admin
      September 5, 2017 @ 6:42 am

      Hi Sudung,

      Thanks for writing. I really don’t see a need for that, if you purchase all the mentioned parts it will be fairly obvious how to put them together. There are no circuit diagrams needed, the pieces just come together without any soldering. If you get the pieces it should be simple to put them together. I hope this answers your inquiry,

      Best Regards,

      Daniel

      • September 7, 2017 @ 8:12 pm

        Hai Daniel , thank you for your answer. I want to develop aquaponic system combine with solar power. So your reference is very valuable.

  • October 31, 2017 @ 12:03 pm

    Would you be able to use 2 PH kits and monitor more than one tank?

Leave a Reply to Remo Cancel reply

Your email address will not be published. Required fields are marked *

Subscribe Today!
Receive our FREE blog post updates and monthly newsletter
Thanks for signing up. You must confirm your email address before we can send you. Please check your email and follow the instructions.
We respect your privacy. Your information is safe and will never be shared.
Don't miss out. Subscribe today.
×
×
WordPress Popup Plugin