ESP32

DIY Hydroponics System using pH Sensor, EC Sensor, Ultrasonic, DS18B20, & ESP32

DIY Hydroponics:

DIY Hydroponics System using pH Sensor, EC Sensor, Ultrasonic, DS18B20, & ESP32- This is version 2 of my DIY hydroponics system, which uses a pH sensor, EC sensor, A02YYUW Waterproof Ultrasonic Sensor, DS18B20 waterproof one-wire digital temperature sensor, a pair of Gravity Analog signal isolators, the ESP32 WiFi + Bluetooth module, and Blynk application.

DIY Hydroponics system using ph sensor ec sensor ds18b20 with esp32

If you have read my previous article on the Hydroponics system, you know I have not changed anything on the hardware side. Everything looks the same.

allpcb circuit

In this article, I won’t talk about the connections and how to install all the required libraries; because I have already done it in the previous article and also in the video available on my YouTube channel “Electronic Clinic”.




Amazon Links:

ESP32 WiFi + Bluetooth Module (Recommended)

SSD1306 Oled display

DS18B20 one-wire digital waterproof temperature sensor

Analog Signal Isolators

EC/TDS Sensor

DFrobot Gravity Analog pH sensor Kit V2

*Disclosure: These are affiliate links. As an Amazon Associate I earn from qualifying purchases.

I made some small changes in the programming and in the Blynk application.

In version 1 of the DIY Hydroponics system, we could not change the sensor limits in real time because all the limits were pre-defined in the code. To change the limits, we had to go into the program and update them each time.



But this time, you do not need to change the code. You can change the limits using sliders in the Blynk application.

set limits of ph tds temperature and water level in DIY Hydroponics system

The limits you set here will be stored in the ESP32’s EEPROM. So, if the controller turns off or resets, the limits you set will not change. This is a very powerful feature, especially for those who want to use this hydroponics system in multiple locations. Everyone can configure the system as they like. Let me show you how.

In the Blynk application, you can see I have added two tabs. As you can see in the image above “Tab 1 and Tab 2”. On “Tab 1” I have added widgets for monitoring the water level, pH value, TDS value, and temperature.

mointoring ph ec tds water level and temperature on the cell phone using blynk - DIY Hydroponics



On the second tab, I have added sliders for setting the limits for those sensors.

set limits for the DIY Hydroponics system using cell phone

As you can see, I have already set the lower and upper limits for monitoring the water level.

For this demonstration, I am using this place as a water tank.

The total distance from the Ultrasonic Sensor to the bottom of the water tank is printed on the Oled display module; which in my case was 100cm.

Note: The distance printed on the Oled display module is the total distance from the Ultrasonic Sensor to the point from where the signal is reflected back. Whereas the water level value displayed on the gauge represents the water percentage. So, while defining the Water tank lower and upper limits make sure you follow the distance value printed on the Oled display module.

So, using the sliders I set the lower limit to 80cm. In the image given below, you can see the water level is 74cm.

DIY Hydroponics system



When the water level goes below the lower limit, this light will turn on. Instead of turning ON the light, you can also send a notification.

DIY Hydroponics system with water level monitoring

You can see the bulb has turned ON because the Water percentage is dropped below the pre-defined value.

Similarly, I have set a limit for the pH sensor.

set ph limit for DIY Hydroponics system

The pH limit is 7.28. I want the ESP32 to turn ON the Bulb when the Water pH value drop below 7.28. You can set any limit as per your preference.

how to monitor drinking water ph value - DIY Hydroponics

Right now, you can see pH value of drinking water that is 7.8. The light is off because the pH value is greater than the defined value.




Let’s make this water a bit acidic by adding some cold drink.

check water acidic level - DIY Hydroponics

You can clearly see, after adding cold drink the drinking water pH value has dropped below the set pH value, it indicates that the water is going acidic, so that’s why the Light is turned ON to notify the concerned person.

If I want this value to be normal, I can change its limit in the Blynk application.

how to set ph limit for water ph monitoring - DIY Hydroponics

So, I dropped the pH limit to 5.91. Now you can see the light is off, which means everything is normal as per the set limit.

Now, it will only notify when the water becomes too acidic. So let’s make the water more acidic.

ph of water DIY Hydroponics system

You can see, the light turned on again; as the water pH value has dropped below the defined limit. Although, I mixed pepsi in the water and still it’s too acidic. 



In version 3, you won’t see so much wiring because everything will be plug-and-play. I have already placed an online order on NextPCB, and once I receive the PCBs, I will share updates with you.

HQDFM service - DIY Hydroponics

To check for errors and manufacturability in your PCB design, you can use NextPCB’s online HQDFM tool or their desktop software, both available absolutely free of cost. When you design PCB through EDA, you know what DRC is and believe it is enough for everything. But the reality is more than that. DRC, DFM, and DFA are totally different concepts. DRC is a design rule. DFM and DFA represent a guideline: the manufacturers are able to produce your design into reality and make sure all circuit and assembly works through the whole product life. From what I can tell, a manufacturer with such a tool means they care for the quality of the products.

Additionally, NextPCB provides component sourcing services since they are the largest component distributor in China. And guess what? They offer free PCBs for new customers up to $30. And that’s not all. For 5 PCBs assembly, you can use their assembly services for free if the types of components on your board are 30 or less.

By the way, the PCB board I am currently using, I have also manufactured it from NextPCB. Their PCB quality is quite amazing. The edges are burr-free and polished smooth. The weight and texture feel great to my touch. If you also want to order high-quality PCBs or PCB assembly for your projects or prototypes, what are you waiting for? Quote.

For the connections read my previous article.

Now, let me show you the changes, I made in the programming.



DIY Hydroponics Programming:



About the changes in DIY Hydroponics System:

Next, I defined some variables for the Limits.

Inside the void setup() function, I used the EEPROM.begin().

Next, I added code to read values from these particular addresses in the EEPROM and assign them to different variables. These addresses will store the values sent from Blynk application. The purpose of using these instructions over here is to ensure that when the controller restarts, it reads these stored values from the EEPROM.

For the lower level, upper level, pH limit, TDS limit, and temperature limit, I have defined virtual pins V4, V5, V6, V7, and V8. Through these virtual variables, we send the sensor limits from Blynk application to the ESP32. Then, using EEPROM.write() and EEPROM.commit(), we permanently save these limits to the ESP32’s memory.

After this, you need to use these limits in your program.

As you can see, I used the upper level and lower level variables in the map function, and I also used the pH limit in a condition.

You can do the same for the other sensors.

So, these are the changes, I made on the ESP32 side.




Next, login into your Blynk account and create 5 more datastreams for the Sensors limits. In the previous article, we created 4 datastreams from V0 to V3. This time you need to create V4, V5, V6, V7, and V8 datastreams for the limits.

limits for DIY Hydroponics system using blynk

If you don’t know how to modify the existing dashboard then you should watch the video tutorial given at the end of this article.

Once all the datastreams are created then add sliders to the dashboard and assign the created datastreams exactly the same way as we assigned to the Gauges in the previous article.

Now, for the Blynk iOT application setup.

You will need to do everything just the same, but this time, you will also need to add tabs to give it more professional look. On one tab, we will add widgets for monitoring.

ph monitoring on blynk application - DIY Hydroponics

And on the other Tab, we will add sliders.

Create a slider in blink application for DIY Hydroponics system

If you face any issues, read my previous article, and if you want to learn in detail then I highly recommend reading my article on the the ESP32 and the New Blynk V2.

Advanced DIY Hydroponics system

Now, with this updated Blynk IoT application, we can not only monitor sensors at any time and from any location, but we can also adjust sensor limits according to our preferences. So, that’s all for now.



Watch Video Tutorial:

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...

Related Articles

One Comment

  1. hello,

    love your work! truly remarkable
    is your versions 3 board available to download ?
    would love to get my hands on it and have a play

    let me know

    cheers
    luke

Leave a Reply

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

Back to top button