ESP32

IoT based Water Level Monitoring System using ESP32, Waterproof Ultrasonic Sensor, & New Blynk

ESP32 and Waterproof Ultrasonic Sensor with new Blynk V2.0

IoT based Water Level Monitoring:

IoT based Water Level Monitoring System using ESP32, Waterproof Ultrasonic Sensor, & New Blynk- In today’s article, you will learn how to make an IoT based Water Level monitoring and motor control system using the ESP32 WiFi + Bluetooth module, and the waterproof JSN SR04T Ultrasonic Sensor.

IoT based Water Level Monitoring

Just don’t worry if you see AJ-SR04M printed on the module. JSN SR04T and AJ-SR04M are exactly the same the only difference is that the AJ-SR04M has an empty location for a resistor and the JSN SR04T doesn’t have it. The amazing thing about this Ultrasonic Sensor is that it comes with a long wire due to which it can be easily installed. Anyway, for this project, we will also need an SPDT-type relay to control a water pump and the new Blynk V2.0 for monitoring the water level.

allpcb circuit




Well, I have already written several articles on the water level monitoring system. But today’s IoT-based water level monitoring system is different from those projects, because many things have changed in the last few months. For example, Blynk V1.0, which was also known as Blynk Legacy, has now been replaced by the Blynk V2.0. Additionally, this time I am using the JSN SR04T Waterproof Ultrasonic Sensor instead of the normal HC-SR04 Ultrasonic Sensor.

IoT based Water Level Monitoring

Well, you can use any of these Ultrasonic sensors. But, technically speaking, if you are willing to spend more, then you should go for the JSN SR04T Waterproof Ultrasonic Sensor, because it is a more advanced ultrasonic sensor that has a longer sensing range of up to 6 meters, and a higher accuracy of up to 1mm. It operates at a wider voltage range of 3-5V DC and has a built-in temperature compensation feature that helps to improve accuracy even in varying temperatures. However, the JSN SR04T is relatively more expensive than the HC-SR04 Ultrasonic Sensor.

In Our House water tank is located at a significant height, so we cannot check the water level in the tank. This often leads to the water running out and with the frequent power outages in our area, it becomes very difficult once the water runs out. To avoid this situation, I have created a prototype model of a water level monitoring and motor control system.

IoT based Water Level Monitoring

With the help of this project, now I can monitor the water level from any part of the world. This is fully automatic. When the water level decreases below a certain level the motor is automatically turned ON and when the water level increases to a certain level then the motor is automatically turned OFF. You can think of this Bulb as the water pump. This is a 220Vac Bulb. If you want to control a large water pump then you can use a power relay. I already have an article on the IoT power relay. Now, let’s go ahead and take a look at the connections. So, without any further delay let’s get started!!!



Amazon Links:

JSN SR04T Waterproof Ultrasonic Sensor

HC-SR04 Ultrasonic Sensor

ESP32 WiFi + Bluetooth Module(Recommended)

1-channel relay module

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



Waterproof Ultrasonic Sensor with ESP32:

IoT based Water Level Monitoring

As usual, I am using my ESP32 development board. But you can also do the same exact connections on a breadboard. Out of these 4 relays, I am using only 1 relay, and it’s connected to the GPIO Pin 12.

IoT based Water Level Monitoring

The VCC and GND pins of the Waterproof ultrasonic sensor are connected to the ESP32 3.3V and GND pins. Whereas the Trigger and Echo pins are connected to the GPIO pins 25 and 26 respectively.

Now, let’s go ahead and start with the Blynk Web Dashboard Setup.



Blynk Web Dashboard Setup:

Go to Blynk.cloud website login page and register a free account and if you have already registered an account then simply enter your login credentials and click on the login button. Once you are logged in then click on the New Template.

IoT based Water Level Monitoring

Enter the name of the template, select the Hardware type, connections types, and you can also write some description. Finally, click on the Done button.

IoT based Water Level Monitoring

While the Datasreams is selected; click on the + New Datastream, and from the drop down menu select the Virtual Pin.

IoT based Water Level Monitoring

Then enter the credentials for the virtual pin and click on the create button

IoT based Water Level Monitoring




We just created a Datastream, its name is waterlevel, its Alias is waterlevel, Pin is V0, Data Type is Integer, etc.

IoT based Water Level Monitoring

In the similar way add another variable for the distance measurement. If still you find it difficult then you can watch the video tutorial given at the end of this article. Anyway, after you have created your two Datastreams then you can start be clicking on the Web Dashboard. On the Left-side you will see different widgets. Simple Drag and drop the widgets as per your needs. Since we have two Datastreams, so for now we will need two widgets. You can also add multiple widgets if you want to display the same values on different widgets.

IoT based Water Level Monitoring

Click on the gauge setting

IoT based Water Level Monitoring

Then give a title to the gauge, link the virtual pin V0 with the gauge, and click on the save button.

IoT based Water Level Monitoring

Then click on the label gadget to display the distance and click on the setting button

IoT based Water Level Monitoring

Then give a title to the label, link the virtual variable V1, and click on the save button.

IoT based Water Level Monitoring



So, after assigning the datastreams; click on the search button and click on the add new device.

IoT based Water Level Monitoring

Click on the From template

IoT based Water Level Monitoring

Then click on water level monitoring and click on the Create Button.

IoT based Water Level Monitoring

Then copy the credentials by clicking on the copy Code. Without these credentials we won’t be able to connect our ESP32 module with the Blynk V2.0. Your credentials will be different from mine.

IoT based Water Level Monitoring

Then paste these credentials in the programming; as you can see in the image given below.

IoT based Water Level Monitoring

Note: If this is your first time using the ESP32 WiFi + Bluetooth module then you should read my article on how to install the ESP32 board in the Arduino IDE.

If you want to know in depth about the ESP32 and the New Blynk V2.0. Then you should read my getting started article on the ESP32 and Blynk V2.0.



IoT based Water Level Monitoring ESP32 Code:

On your side, make sure you change the SSID and Password, and also set the emptyTankDistance and fullTankDistance values. Anyway, finally, I clicked on the button. After uploading the code; I went back to the Blynk Dashboard to check if ESP32 was able to send values to the Blynk Dashboard. As expected, it worked. I was able to receive the value. Now, let’s go ahead and start with the Blynk IoT Mobile Application Setup.



Blynk IoT Mobile App setup:

Open the Blynk IoT application on your cell phone. “Make sure you use the same Gmail ID”.

IoT based Water Level Monitoring

Then click on the developer mode

IoT based Water Level Monitoring

Click on the water level monitoring

IoT based Water Level Monitoring




Click on the add button and gauge

IoT based Water Level Monitoring

Double click on the gauge

IoT based Water Level Monitoring

Click on the choose data stream

IoT based Water Level Monitoring



Select the variable you want to link to the gauge

IoT based Water Level Monitoring

Then give a title to the gauge and you can also play around with other parameters like the Alignment, Font Size, etc.

IoT based Water Level Monitoring

Then again click on the add button and insert label gadget which will be used to display the distance.

IoT based Water Level Monitoring

Then link the distance variable with it

IoT based Water Level Monitoring



Final look of the IoT based Water Level monitoring system Application

IoT based Water Level Monitoring

So, my mobile Application is also ready. Now, I am going to explain how to fix the Ultrasonic Sensor over the top of a water tank and how to calculate the water level percentage. So, let’s go ahead and do it.



Ultrasonic Sensor for the Water Level Percentage:

IoT based Water Level Monitoring

Let’s think of this Bucket as the Water Tank and we have to measure the water level inside this Tank. For this, first install the ultrasonic sensor. Then using the Blynk application check the distance value when the Tank is empty. I want my motor to turn ON before the tank completely gets empty. So, I am going to select 25cm as the trigger distance. So, when the water level inside the tank is at 25cm the motor will automatically turn ON.

IoT based Water Level Monitoring

Then fill the water tank to the desired level and check the distance value. Then reopen the code, update the values, and upload it again.

For the practical demonstration, watch the video tutorial given below.




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

Leave a Reply

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

Back to top button