Arduino Hydroponics, DIY Hydroponics System using pH Sensor & EC Sensor, Hydroponic

(Last Updated On: September 12, 2021)

 

Hydroponics System, Description:

Hydroponics

Hydroponics is a branch of hydroculture. It is the process of cultivating plants without soil. The plants receive nourishment through mineral nutrients dissolved in water, instead of soil. In my previous tutorial, I have already explained how to monitor the soil nutrients like Nitrogen, phosphorus, and Potassium using the NPK Sensor, Arduino, and an Android cell phone application.

Hydroponics


Hydroponics is basically growing plants without soil. It is a more efficient way to provide food and water to your plants. Plants don’t use soil – they use the food and water that are in the soil. Soil’s function is to supply plants nutrients and to anchor the plants’ roots. Hydroponic gardeners may use different types of inert media to support the plants, such as rockwool, coconut fibre, river rock, Styrofoam, or clay pellets.

Hydroponics is a Latin word meaning “working water.” In the absence of soil, water goes to work providing nutrients, hydration, and oxygen to plant life. From watermelons to jalapeños to orchids, plants flourish under the careful regimen of hydroponics. Using minimal space, 90% less water than traditional agriculture, and ingenious design, hydroponic gardens grow beautiful fruits and flowers in half the time. If you want to study more about the Hydroponics system then I highly recommend read the Fresh Water Systems article.

Hydroponic makes it easier to measure and fill the exact amounts of nutrients in the water solutions, since each plant requires different nutrients. This can be really a tedious job if you do it manually. Well, I am not a Hydroponics expert and I really don’t know how much nutrients should be added in the water solution. But I can help you in designing and making your own Hydroponics system which you can use to measure and fill the exact amount of nutrients in the water using Solenoid valves which can be controlled as per the measured values.

So, this article is all about how to make your own Hydroponics system using Arduino, pH Sensor, EC sensor or TDS meter, DS18b20 one-wire digital temperature sensor, TOF10120 Laser distance Rangefinder, and an Oled display Module.

Before, making the final PCB I started with the Arduino Nano Development board and breadboard to perform my initial tests.

Hydroponics

This is the analog pH sensor kit from the DIY MORE, which needs to be properly calibrated before you can use it for measuring the pH values of different liquids. The pH sensor calibration I have already explained in my previous article “Ph Meter with Arduino and Calibration”.

Hydroponics




 I started off by connecting the pH sensor Probe with the Interface circuit. Next, I connected the Red wire with the V+ pin of the interface circuit. Black wire with the GND pin and the Yellow wire with the Po pin of the interface circuit. Finally, I connected the Red wire with the Arduino’s 3.3V, Black wire with the GND pin of the Arduino, and the Yellow wire with the Analog pin A0.

Hydroponics

This is the EC Sensor or TDS meter V1.0 from the DFrobot which is completely compatible with Arduino. One thing that I really like about this TDS Meter is that it supports 3.3 to 5.5 Volts wide voltage input, and 0 to 2.3 Volts analog voltage output, which makes this TDS meter compatible with 5V and 3.3V control systems or boards. I have very detailed tutorials on the TDS or EC sensor in which I have explained how to use it with Arduino and ESP32 for monitoring the water quality.

The TDS meter is connected with the Arduino or any other controller board using the A, +, and – pins as you can see in the image given above. For the easy interfacing I connected male to male type jumper wires.

Hydroponics

Connect the + pin of the TDS meter with 3.3V. Connect the Minus pin with the GND of the Arduino, and finally, connect the A pin of the TDS or EC sensor with the A1 pin of the Arduino.

Hydroponics

This is the DS18b20 One-Wire digital temperature sensor, I have already soldered a 10k resistor and some jumper wires as per the circuit diagram which I will explain later in this article.

Hydroponics



Connect the VCC wire with the 3.3V of the Arduino. Connect the ground of the DS18b20 with the ground of the Arduino, and finally, connect the Data wire with the digital pin D7 of the Arduino.

After connecting all the sensors, finally I connected the Oled display module for displaying the pH, Temperature, and EC values. My interfacing is completed and now I can start with my initial tests. I started off by powering up my Arduino board using a 12V adaptor.

Initially, when I turned the Arduino Nano, I was able to see the pH, Temperature, and EC values on the Oled display. At this time only the temperature sensor value was correct, while the values of the EC sensor and the pH sensor were wrong, as they were not yet dipped in the water.

For performing my initial tests I started with the Well water. First I started with the DS18b20 temperature sensor which is completely waterproofed and can be dipped in liquids without any problem. I have been using this sensor with Arduino, ESP32, ESP8266, and Raspberry Pi. This is seriously an amazing temperature sensor and as it’s a waterproofed temperature sensor for this project it’s just perfect. Anyhow after I immersed the Temperature sensor, the value on the Oled display module started to increase. For the practical demonstration watch video tutorial given at the end of this article. So the temperature sensor was working just fine.

Hydroponics

Next, I added the pH sensor for measuring the water pH value, while keeping the TDS meter or EC sensor outside. You can see the value is around 6.81. As per the EPA, the public water pH levels should be between 6.5 and 8.5. The water under test is very close to ph 7 which is really good. The aim is not to measure the water quality, but I just want to say the pH sensor is working great, I am getting the correct value. So far, the pH sensor and temperature sensor are working perfectly and now I am ready for the next step to add the TDS meter along with the other sensors.

Hydroponics

After adding the TDS meter although I was able to read the EC value but it really affected the pH value, as you can see on the display the pH value is changed, this is the kind of problem that most of the guys are complaining about that when we add the pH sensor and TDS meter in the same liquid container the pH value is greatly disturbed. This is a very serious kind of problem as we are not getting the actual pH value, this problem needs to be solved before we can make an efficient Hydroponics system. Anyways, I continued with my test, to further ensure, that the TDS meter is creating this problem, I removed the TDS probe, and then in just 3 to 4 seconds, the pH value got normal. Now I know exactly the pH sensor behaves in an abnormal way when the TDS Meter or the EC sensor is added in the same container. So, I decided to check this one more time, I dipped the TDS meter probe in the water, waited for around 3 to 4 seconds and the pH value jumped. So, from this initial test, we know that when the EC sensor is not dipped in the same container we get pretty stable pH values, and when we add the EC sensor then the pH value is greatly disturbed.

Now, to solve this problem we will need to isolate the power wires of the EC sensor. I will use two transistors to control the EC Sensor, so the EC sensor will remain OFF during the times when Arduino will be reading the pH Sensor. After Arduino reads the pH Sensor, then again the EC sensor will be turned ON. This is the next test that I am going to perform and let’s see if the problem will be solved.

Hydroponics



To isolate the voltage and GND wires of the TDS Sensor I am using these two general purpose PNP and NPN Transistors. The one on the right side is the 2N3906 PNP type transistor. The emitter is connected with 3.3 volts which goes to the TDS meter through the collector of the transistor. So 3.3V to the TDS sensor are supplied by turning on this transistor. The other transistor is the 2n2222 NPN transistor and I am using this transistor to control the GND. The emitter is connected with the Arduino’s GND while the collector of the 2n2222 NPN transistor is connected with the GND of the TDS meter. While the base of the transistor is connected with the digital pin 3 of the Arduino. I will explain the final connections in the circuit diagram after I am done with all the testing.

Again I powered up the Arduino board, initially everything was working just great, I was getting the correct pH values, and the correct temperature value. At this point, I was ready to add the EC sensor. So, I added the EC sensor in the same container, the pH sensor value didn’t change, and now it was working great. The EC Sensor isolation thing just worked. There are no abnormal fluctuations in the pH Sensor values. The TDS meter was turning ON and Turning OFF at regular intervals as defined in the code. The EC sensor remains off when the Arduino is reading the pH Sensor.

Now to further ensure that the whole system is working, I am going to use these few drops of Pepsi, the pH value should reduce.

Hydroponics

great, you can see the value is decreasing which means now the water is a little acidic. So, after successfully performing my initial tests, I designed a PCB, so that all the components can be easily interfaced.

Hydroponics

This time I also added the TOF10120 Laser distance Rangefinder sensor for measuring the water level. I am not displaying its value on the Oled display module but on the Serial monitor. You can use some if conditions in the programming to control a water pump. In the final Hydroponics system PCB, I also added headers for the Relay module. The relays can be used to control different pumps to add the required nutrients. Anyway, I did perform the same tests and the results were just amazing. Now, I will explain the final circuit diagram, PCB Designing, and Making. So, now you have an idea of what you are going to learn after reading this article. Without any further delay let’s get started!!!



Amazon Purchase Links:

pH Sensors

TDS Meter V1.0 Dfrobot:

DS18B20 one-wire digital temperature sensor:

TDS Pen:

tof10120 laser range sensor

SSD1306 128×64 Oled i2c display Module

12v Adaptor:

Arduino Uno

Other Tools and Components:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!




Hydroponics System Circuit Diagram:

Hydroponics

Let’s start with the 5V regulated power supply based on the LM7805 voltage regulator. J1 is the DC female power jack and this is where we connect our 12V adaptor. Two 470uF decoupling capacitors are connected on the input and output sides of the voltage regulator. The output of the regulator is connected with the Vin pin of the Arduino.

The GND pin of the TDS Meter or EC Sensor is connected with the collector of the 2n2222 NPN transistor and the emitter of the transistor is connected with the GND. The base of the transistor is connected with the Arduino’s pin 3. Similarly, the + pin of the EC Sensor is connected with the Collector of 2N3906 PNP type transistor and the emitter is connected with 3.3V. The base of the transistor is connected with the Arduino’s pin2. The A pin of the TDS Meter is connected with the A1 pin of the Arduino.

The DS18b20 waterproofed one-wire digital temperature sensor GND is connected with the Arduino’s GND. A 330-ohm resistor is connected between the Data wire and VCC wire. The data wire is connected with the Arduino’s pin7.

The i2c supported Oled display module SDA and SCL pins are connected with the Arduino’s A4 and A5 pins, while the VCC and GND pins are connected with the Arduino’s 5v and GND.

The TOF10120 Laser distance Rangefinder Sensor is also an i2c supported sensor. The Green and Blue wires are the SCL and SDA wires which are connected with the A5 and A4 pins of the Arduino. The Red wire is connected with 5V and the Black wire is connected with the GND of the Arduino.

The pH sensor or pH meter V+ and GND pins are connected with 3.3v and GND pins of the Arduino. Po pin is connected with the A0 pin of the Arduino. In the circuit diagram you can also see, I have added one relay module, but in the PCB design, I added more relays. So, that’s all about the circuit diagram.



Hydroponics System PCB Design:

Hydroponics

The PCB designing is done in the Cadsoft Eagle 9.1.0 version. All the connections are as per the circuit diagram already explained. In the PCB I added more relays and I am using D9 to D11 pins of the Arduino to control all 4 relays.

Download Gerber files: 

Arduino Hydroponics System PCB making:

Hydroponics

This is the Final PCB board. Next, I started off by placing the components and completed the Soldering Job.

Hydroponics

Our hydroponics system PCB is ready. I also added Vias for soldering male or female headers which can be used to power up other electronic components using 12V, 5v, and GND.

These female headers on the top side are used to connect relays. The female headers on the top right side are for the pH sensor. On the bottom side, you can see male and female headers for the EC Sensor, TOF10120 Laser distance Rangefinder, and DS18b20 one-wire digital Temperature sensor.

Arduino Hydroponics System:

Hydroponics

My Arduino based Hydroponics System is ready. All the electronics are connected as per the circuit diagram. Now, let’s take a look at the Hydroponics system programming. Download all the required libraries.


Hydroponics System Arduino Programming:


About the Hydroponics Arduino Code:

Before you start the programming, first of all, make sure you download all the necessary libraries. As you know I have been using the pH sensor, TDS meter or EC Sensor, TOF10120 Laser Rangefinder or Distance Sensor, DS18b20 one-wire waterproofed digital temperature sensor, and Oled display modules for quite a long time in different Arduino, ESP8266, and ESP32 based projects. So, this Hydroponics system code is developed by simply copying and pasting the code from my previous projects. The only thing that I didn’t do in my previous projects is the isolation thing. In this code, I defined pins for the + and GND pins of the TDS meter or EC Sensor. The rest of the code is exactly the same as explained in my previous tutorials. I have also shared links to all the related tutorials.

For the full step-by-step explanation, making, and demonstration watch the video tutorial given below. Don’t forget to subscribe to my website and YouTube channel Electronic Clinic.

Watch Video Tutorial:

 

 

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

10 Comments

  1. Great tutorial. I like to give it a go and try to make it for my hydroponic system even though I am a total newbie in both hydroponics and arduino.

    I wonder if I could have two additional outputs to turn on led light and water pump which both could be 220v devices with a timer or sensor ?

    Would it possible to extended it further and have all the data displayed on the web so I can monitor everything remotely?

  2. I keep getting a temperature return of -127 and a negative EC that doesn’t react to changing TDS in the solution with this code. Any idea why?

  3. I THE CODE FOR THIS WILL NOT LOAD IT GIVES ERRORS @ LINE 84 I HAVE ALL THE LIBERYS AND THAY ALL SHOW BUT THIS SIMPLE TIMER IS SHOWING ERRORS timer.setInterval(500L, display_pHValue);
    }
    void loop() {
    timer.run(); // Initiates SimpleTimer

  4. Hi thank you for a brilliant project. Have you thought of making it the perfect setup by adding a humidity sensor and and output to control a fan . The reason being Temperature and humidity are critical in hydroponics

  5. It is a great job, but perhaps (only perhaps) has a very little flaw, if I am not wrong: I didn’t find the SimpleTimer library with such arguments on. http://www.arduino.cc and then, after compiling received the message “no matching function for call to ‘SimpleTimer::setInterval(long int, void (&)())”. Please, where can I find the SimpleTimer library asked by the firmware? Best regards

  6. Very interested in this. Been a hydro grower for a while and these controllers are very expensive. My only question would be can the 2 Channel DC 5V relay be added to power couple peristaltic pumps for automatic pH? Im just starting my Arduino adventures so not sure if this is possible

Leave a Reply

%d bloggers like this: