ESP32

Water Level Monitoring with Ultrasonic Sensor A02YYUW, ESP32, & Blynk

Water Level Monitoring with Ultrasonic Sensor:

Water Level Monitoring with Ultrasonic Sensor A02YYUW, ESP32, & Blynk- Today, we are making the most practical IoT based Water Level Monitoring and control system using the EP32 WiFi + Bluetooth module, A02YYUW Waterproof Ultrasonic Sensor, and Blynk application.

Right now, what I am about to explain, you all have to listen carefully, because it’s better to listen now than to regret later. Otherwise, later you will be saying, “I wish I hadn’t rushed in selecting the sensor.”

Water Level Monitoring with Ultrasonic Sensor




For monitoring water level, you can use the HC-SR04 Ultrasonic Sensor, the JSN SR04T Waterproofed Ultrasonic Sensor, and even the TOF10120 Laser Rangefinder Distance Sensor. I have already used all these sensors for water level monitoring. But among all these sensors, the most reliable, accurate, and durable is the A02YYUW Waterproof Ultrasonic Sensor.

Each has its pros and cons. For example, if you look at the HC-SR04 Ultrasonic sensor, it’s a 5V sensor, and you can use it with 5V compatible controller boards. But if you want to use it with 3.3V compatible controllers, you will need a voltage converter. Its range is also limited, and it’s not waterproofed, so there is a high chance it could get damaged by water.

And if you consider the JSN SR04T waterproof ultrasonic Sensor, no doubt it’s better than the HC-SR04 Ultrasonic Sensor because it’s waterproofed, and it comes with quite a long wire. But I don’t like its interface board because it increases the project overall size. Moreover, I am not entirely satisfied with its output.

And if you are thinking of using the TOF10120 Laser RangeFinder sensor for water level monitoring in water tanks, that’s not a good idea because its range is quite limited.

And then here comes the Beast the A02YYUW Ultrasonic Sensor, Its completely waterproofed, there is no interface board; you can directly connect its wires to the controller board, its compatible with 5V and 3.3V controller boards so there is no need to use any kind of voltage converter. If you want to know more about its technical specifications, its interfacing with Arduino and ESP8266, then I highly recommend reading my getting started article on the A02YYUW Waterproof Ultrasonic Sensor.

And let me also tell you this the UART version of the A02YYUW waterproof ultrasonic Sensor.

After selecting the sensor, next, you need to decide which variant of the ESP32 you want to choose. You know there are different variants of the ESP32 boards.



If you want your controller to work for years and you don’t want any issues while uploading your programs, then I strongly suggest you to get yourself a pair of these ESP32 development boards.

esp32 boards used Water Level Monitoring with Ultrasonic Sensor circuit diagram

If you check my ESP32 based projects, you will see that I have been using this particular ESP32 development board for years. Because its build quality is good, it is also durable, you can connect a Lipo battery with it, and it has more GPIO pins. So, I highly recommend getting yourself a pair of these ESP32 boards. I have added the Amazon Link to the same exact ESP32 board below under the Amazon Links.

esp32 development board for Water Level Monitoring with Ultrasonic Sensor

As usual, I am using my newly designed ESP32 Development board, because it already has most of the components needed for this project like for example this 5V relay which I can use to control a water pump, the ESP32 WiFi + Bluetooth module itself, and most importantly the 5V and 3A power supply. Since, this is a development board and I use it for making and testing my ESP32 based projects, so that’s why I have soldered female headers on the Left and Right sides of the ESP32 WiFi + Bluetooth module so that I can connect other sensors and breakout boards.

And that’s not all, on this development board; for the A02YYUW Waterproof Ultrasonic Sensor, I have these 4 contacts labeled as Ultrasonic Sensor.

Water Level Monitoring with Ultrasonic Sensor interfacing

So, I can connect the Ultrasonic Sensor Voltage and GND wires to the 3.3V and GND contacts. And the TX and RX wires to the contacts labeled as Tx and Rx.

esp32 Water Level Monitoring with Ultrasonic Sensor circuit diagram

For the Ultrasonic Sensor interfacing you can follow this circuit diagram and you can follow this circuit diagram for the relay driver.

Water Level Monitoring with Ultrasonic Sensor relay driver circuit diagram

You can also use a readymade 5V relay module. If you also want to make the same ESP32 development board then you can read my article on the ESP32 development board.



Amazon Links:

ESP32 WiFi + Bluetooth Module (Recommended)

A02YYUW Waterproof Ultrasonic Sensor

Other Tools and Components:

Arduino Nano USB-C Type

Top Arduino Sensors:

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!

Water Level Monitoring with Ultrasonic Sensor

My hardware setup is ready. Everything looks quite neat and clean; there are no jumper wires so there are no loose connections. Now, let’s start with the Blynk Web Dashboard setup.



Blynk Web Dashboard Setup:

While you are logged-in into your Blynk account.

Click on the New Template.

Water Level Monitoring with Ultrasonic Sensor blynk web dashboard setup for esp32

Write the Template Name.

Water Level Monitoring with Ultrasonic Sensor blynk iot template

While ESP32 is selected as the Hardware type and WiFi as the connection type; click on the Done button.

While you are on the Datastreams tab, click on the + New Datastream and select Virtual Pin.

datastreams in blynk for Water Level Monitoring with Ultrasonic Sensor




On the Virtual Pin Datastream, write the name, and define the min and max values.

virtual datasteam pin in blynk iot Water Level Monitoring with Ultrasonic Sensor

Again click on the + New Datastream and select Virtual Pin.

blynk datastream for switch Water Level Monitoring with Ultrasonic Sensor

Write the name and define the MIN and MAX values. This time we selected 0 and 1. 0 means

OFF and 1 Means ON.

blynk datastream relay Water Level Monitoring with Ultrasonic Sensor

After creating the Datastreams, click on the Save button. Let me also tell you. It doesn’t matter how many datastreams you want to create, you have to follow the same steps. You just need to make sure you select the corrent units and properly set the MIN and MAX values. You can also select a different DATA Type and any virtual pin of your choice.



Anyway, next, you can click on the Web Dashboard.

Water Level Monitoring with Ultrasonic Sensor blynk web dashboard

While you are on the Web Dashboard, you can select widgets of your choice and add them to the Dashboard. On the free Plan you are not allowed to use the Pro widgets. But, you can use some free widgets like the Gauge and a Switch. And to be very frank, these widgets are good for this project. So, you can select a Gauge and Switch to the Dashboard and assign the desired Datastreams.

widgets adding in blynk for Water Level Monitoring with Ultrasonic Sensor

You can see I assigned the Datastream (V0) to the Gauge and Datastream (V1) to the Switch. When you are Blynk Web Dashboard is ready, click on the Save button.

On the Left side you can see Devices, buddy you need to click on it.

add device in blynk for esp32 Water Level Monitoring with Ultrasonic Sensor

Now, on the right side, you can see the + New Device, click on it to add your device.

add new device form template in blynk for esp32 Water Level Monitoring with Ultrasonic Sensor

Choose a way to create new device. we are going to select From Template.

add new blynk device template for esp32 Water Level Monitoring with Ultrasonic Sensor

Click on the Choose template and select your template that is “Water level Monitroing”.

blynk credentials for Water Level Monitoring with Ultrasonic Sensor

Now, finally, you need to click on the “Click to copy Code” to copy the credentials and paste them in the programming.



Water Level Monitoring Programming:

Don’t forget to change the GPRS Credentials.

If this is your first time using the ESP32 WiFi + Bluetooth module then you will also need to install the ESP32 board in the Arduino IDE.

add esp32 board in arduino for esp32 Water Level Monitoring with Ultrasonic Sensor

For this you can read my getting started article on the ESP32 WiFi + Bluetooth Module.

Next, you will also need to install the entire blynk library package. For this simply go to the Sketch Menu, then to Include Library, and click on the Manage Libraries.

add arduino library for esp32 Water Level Monitoring with Ultrasonic Sensor

Type Blynk in the search box.

add blynk library package for esp32 Water Level Monitoring with Ultrasonic Sensor

You can see I have also installed this library. It works with over 400 boards.  Finally, you can select your ESP32 board from the boards list and after selecting the correct communication port; you can upload the program, in my case I have already uploaded this program. Next, you can start with the Blynk IoT Application setup on your smartphone.



Blynk IoT App setup on Smartphone:

For this, first of all, you will need to install the IoT blynk in your smart phone. Make sure you log in with the same email that you used on your computer. Simply, open your Blynk application on your cell phone and select your project.

add iot blynk application for esp32 Water Level Monitoring with Ultrasonic Sensor

After this, things are pretty straightforward, you need to add the Gauge and Switch and assign them the desired Datastreams. You don’t need to create the Datastreams, we already did it.

blynk iot Water Level Monitoring with Ultrasonic Sensor

I assigned the Datastream V0 to the Gauge and Datastream V1 to the Switch. It’s not compulsory to use the same widgets, you can select any other widget and a different button. All you need to make sure; you assign the correct Datastreams.

If you face any issues then you can watch my video tutorial given at the end of this article. Anyway, our application is also ready, now let’s start the practical demonstration.




Practical Demonstration:

I have powered up the project using a 12V adaptor.

esp32 Water Level Monitoring with Ultrasonic Sensor

The Red, Black, Yellow, and White wires are from the A02YYUW Waterproof ultrasonic Sensor, for the sake of demonstration, I fixed the Ultrasonic Sensor on the Edge of this table. I showed this in the Video available on my YouTube channel Electronic Clinic.

For demonstration purposes, I have connected this 110/220Vac bulb. Instead of using this bulb, you can connect a real water pump it could be AC or DC; just make sure it doesn’t exceed the current carrying capacity of the Relay. If you need to control a large water pump then you will need to use a power relay, for this you can read my article on IoT Power Relay.

Safety:

Anyway, remember safety first, When the 110/220Vac supply is connected, never touch the relay contacts as it can be extremely dangerous. It is important to note that when working with mains voltage, proper safety precautions should always be taken and it is advisable to consult relevant electrical codes and standards.

Water Level Monitoring with Ultrasonic Sensor

The ESP32 and Blynk application are connected to the WiFi. Let me also tell you, there is no need to connect to the same WiFi, you can use a different WiFi network or GSM network on the mobile side. It is an IoT based Water Level monitoring system, you can connect to your ESP32 board from any part of the world.

At first, I thought of using a bucket as a water tank, but when I started testing, I got incorrect readings because of the high sensing angle of the Ultrasonic Sensor. If the diameter of the bucket were a bit larger, then there wouldn’t have been any issue. The actual water tank is usually quite big, so there wouldn’t be any issue.

Anyway, for demonstration purposes, I decided to use a wooden sheet as the water level.

Water Level Monitoring with Ultrasonic Sensor

Right now, on the Blynk application you can see the Water Tank is empty. I could turn ON the water Pump automatically. But, I want the control in my hands.  So, let’s turn ON the Water Pump.

controlling esp32 Water Level Monitoring with Ultrasonic Sensor

As I started to move the wooden sheet in the upward direction “Wooden sheet = Water Level”. The percentage value on the Gauge started to increase.

Water Level Monitoring with Ultrasonic Sensor

As I kept moving the Wooden sheet in the upward direction, the percentage value also kept increasing.

When the control is in your hands then you can turn OFF the Water Pump at any time. Let’s say, I don’t want to completely fill the water tank; so I can just go ahead and turn OFF the Water Pump.

Water Level Monitoring with Ultrasonic Sensor in running mode

I can also add a condition in the programming to turn OFF the Water Pump automatically when the Water Tank is let’s say 90 to 95% or 100% full. It’s totally up to you when you want to turn ON and turn OFF the Water Pump. 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

Leave a Reply

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

Back to top button