In this IoT Internet of Things project, I have explained how to make a simple IoT-based water level indicator using an ultrasonic sensor, ESP32, and Blynk IoT platform.
The alarm will start for the LOW water level, and you will get a Blynk notification on the smartphone through the internet. Also, you can monitor the water tank level on OLED.
The alarm will also start when the tank is full. You press the push button to stop the alarm.
So if you follow all the steps, you can easily make this IoT based water level monitoring system using ESP32 and Blynk app.
Required Components for ESP32 Water Level Sensor
- ESP32 DEV KIT V1
- SR04M waterproof ultrasonic sensor OR HC-SR04 sensor
- 0.96″ I2C OLED Display
- 220-ohm 0.25watt Resistors – 2 no
- BC547 NPN Transistor
- LED 5mm – 1no
- 2-pin Push Button
- 2-pin Terminal connectors (3 no)
- 5V DC Buzzer
- AC to DC converter PM01 5V (Optional)
Circuit of IoT Based Water Level Indicator
In the circuit, if you want to use AC voltage, then you have to use a PM01 AC to DC converter. Otherwise, you can directly give 5V DC supply to this circuit.
The GPIO D26 & D27 are connected with the Echo & TREG pins of the SR04M-2 waterproof ultrasonic sensor.
The OLED SDA & SCL pins are connected with the D21 & D22 GPIO of ESP32.
GPIO D12 is connected with the push button to stop the buzzer. I have used the INPUT_PULLUP function in Arduino IDE instead of using the pull-up resistors with the push button.
And the indicator LED and Buzzer are connected with GPIO D14 & D13 of ESP32.
You can use any other ultrasonic sensor.
The minimum distance between the sensor and the full tank water level must be greater than 25cm.
PCB Layout for Water Level Indicator
Please download the PCB layout, then print it on the A4 page.
Please check the PCB size while printing, it should be the same as mentioned in Layout.
Homemade PCB for the Water Level Indicator
In the tutorial video, I have explained, how you can easily make the complete circuit on zero PCB using the PCB Layout.
Tutorial video on ESP32 Water Level Detector
During the tutorial video on wireless water level sensor, I covered the following topics:
- Quick demo on IoT-based water level monitoring system.
- How to make the water level detector on Zero PCB.
- Set up the Blynk IoT Cloud for ESP32.
- Steps to add a device in Blynk IoT Cloud.
- Source code for the IoT-based water level sensor.
- Set up the Blynk IoT app to monitor the water level.
- Add automation for LOW water level notification.
Set up Blynk IoT Cloud for the IoT-based Project
You can refer to the following article to set up the new Blynk cloud account
Getting started with New Blynk 2.0 IoT platform
Create Blynk Template
During creating the template, I selected ESP32 as the hardware and the connection type as WiFi.
Create Datastreams in Blynk Cloud
In the template, I have created first Datastreams (Pin: V1, Datatype: Integer, Min Value: 0, Max Value: 100) to show the water level in tank in percentage.
Second Datastream (Pin: V2, Datatype: String) will show the distance between sensor and water level in cm.
Add Automation in Blynk IoT
I have added Automation to get the LOW water Level notification in the Blynk IoT app.
I have turned on the Condition and Action radio button for the first Datastream V1. Type of Automation will be “Sensor”.
Create Web Dashboard in Blynk Cloud
After that, click and drag 1 Gauge widget, and 1 Level widget, and select the related Datastreams for each widget.
Then click on “Save” to save the template.
Add Device in Blynk Cloud using Template
You can refer to the following article to add a device to the Blynk cloud.
PCB for this ESP32 Water Level Indicator
You can also download the PCB Gerber file and order the PCB from PCBWay.
About PCBWay and their services
You can order any custom design PCBs from PCBWay at very reasonable prices.
PCBWay not only produces FR-4 and Aluminum boards but also advanced PCBs like Rogers, HDI, and Flexible and Rigid-Flex boards, at very affordable prices.
For the online instant quote page please visit – pcbway.com/orderonline
You can also explore different PCB projects from their Open-source community pcbway.com/project/.
For more details please visit the following articles.
Program ESP32 with Arduino IDE
For this IoT-based project, I have used the Arduino IDE to program ESP32.
First update the Preferences –> Aditional boards Manager URLs: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json, http://arduino.esp8266.com/stable/package_esp8266com_index.json
- Then install the ESP32 board (2.0.5) from the Board manager or Click Here to download the ESP32 board.
- Download the required libraries from the following links:
- Adafruit_SSD1306 Library (Version 2.5.7)
Source Codes for Blynk ESP32 Water Level Sensor
Click on the following buttons to download the source codes for this ESP32 project.
In the sketch, you have to update only the BLYNK_TEMPLATE_ID, BLYNK_DEVICE_NAME, Auth Token.
/* Fill-in your Template ID (only if using Blynk.Cloud) */ #define BLYNK_TEMPLATE_ID "" #define BLYNK_DEVICE_NAME "" #define BLYNK_AUTH_TOKEN ""
Enter the WiFi Credentials.
// Set password to "" for open networks. char ssid = ""; char pass = "";
Define Water Level Distance for empty tank and full tank in CM.
int emptyTankDistance = 70 ; //Distance when tank is empty int fullTankDistance = 30 ; //Distance when tank is full
Define trigger value in percentage, alarm will start when water level drop below triggerPer.
//Set trigger value in percentage int triggerPer = 10 ;
Here I have defined the triggerPer 10%, but you can define any value like 5%, 20% etc.
The ESP32 will only calculate the water level if the measured distance is between empty tank distance and the full tank distance.
After doing these changes, please upload the code to ESP32.
Install the Water Level Sensor circuit
On the PCB, either you can give AC supply as per the above circuit or you can give 5V DC supply as per the following circuit.
***While fitting the ultrasonic sensor in the water tank, please make sure the minimum distance between the sensor and the full tank water level must be greater than 25cm.
I hope you like this IoT-based water level monitoring system using ESP32 and Blynk IoT app.
Click Here for more such ESP32 projects.
Please do share your feedback on this IoT project. Thank you for your time.