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:
- Arduino UNO R3 – 23.90 USD
- LCD 12864 screen shield – 24.05 USD
- Mini tentacle shield – 85.00 USD
- pH kit from Atlas – 149.15 USD
- EC kit from Atlas – 195.71 USD
- Arduino headers – 12.99 USD
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.