Water is one of the most valuable resources on Earth, yet every day thousands of liters of water are wasted due to negligence and overflow of overhead tanks. In most homes, apartments, hostels, and industries, people manually check the water level in the tank and switch the motor ON or OFF. This traditional method is unreliable and leads to:
- Overflowing tanks when we forget to turn off the motor β²
- Dry tanks when water gets finished and we notice it too late π
- Wastage of electricity and water
- Extra effort and time in manually checking water levels
To solve this real-life problem, modern technology like IoT (Internet of Things) provides an efficient and smart solution.
β 2. What is a Smart IoT Water Level Monitoring System?
The Smart IoT Water Level Monitoring System is a low-cost, wireless, real-time monitoring solution that helps you check the water level of your tank on your mobile phone from anywhere in the world.
It uses:
β ESP32 Wi-Fi Development Board
β Ultrasonic Sensor (HC-SR04)
β Blynk IoT App
β (Optional) Relay Module for Motor Control
Through this system, water level percentage automatically appears on the Blynk app in your smartphone. You can also add features such as automatic motor ON/OFF, alerts, and voice control using Alexa or Google Assistant.
β 3. Why This System is Important?
| Problem | Solution Provided by This Project |
|---|---|
| Water tank overflow | Real-time alert and motor control |
| Dry tank and motor damage | Low water level alerts |
| Manual checking required | Fully wireless & automatic |
| No monitoring from outside home | Works globally via internet |
| High-cost commercial systems | Low-cost DIY IoT solution |
This project is especially useful for:
- Homes and Apartments
- Schools and Colleges
- Industrial water tanks
- Farm irrigation systems
- Water storage plants
β 4. Project Overview β By YaranaIot Guru
This complete system is designed, developed, and explained by YaranaIot Guru. This project includes:
β Fully working Arduino code
β Circuit diagram explanation
β Blynk app setup
β Real-time water level monitoring
β Future upgrade ideas (Alexa, Telegram Alerts, Auto Motor Control)
Your name/channel will be mentioned inside the code, app template, and documentation.
β 5. Objectives of the Project
The main goals of this project are:
β To monitor real-time water level percentage using ESP32 and Blynk
β To display “Tank Full” and “Low Water” alerts on mobile
β To eliminate manual checking and save water
β To provide a low-cost IoT-based smart solution
β Optional β Control water pump using Relay module
β 6. Components Required
To build the Smart IoT Water Level Monitoring System using ESP32, Ultrasonic Sensor, and Blynk App, you will need the following components:
| Component Name | Quantity | Description / Use |
|---|---|---|
| ESP32 Wi-Fi Development Board | 1 | Main microcontroller with built-in Wi-Fi (sends data to Blynk Cloud) |
| Ultrasonic Sensor (HC-SR04) | 1 | Measures distance between sensor and water surface |
| Blynk IoT App (Android/iOS) | 1 | Displays real-time water level on your mobile phone |
| Jumper Wires (Male-to-Female/Male-to-Male) | As needed | For wiring connections |
| USB Cable / 5V Power Supply | 1 | Powers the ESP32 board |
| Relay Module (Optional) | 1 | Used to turn ON/OFF the water pump from Blynk App |
| Water Tank (Any size) | 1 | The tank in which water level is measured |
β Note: You can use a single-channel relay if you only want to control one water pump. For dual motor control, use a 2-channel relay.
β 7. Circuit Diagram and Pin Connections
There is no complex wiring in this project. You can easily connect the ultrasonic sensor to ESP32 using jumper wires.
π Ultrasonic Sensor to ESP32 Pin Mapping
| Ultrasonic Sensor Pin | ESP32 Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| TRIG | GPIO 5 |
| ECHO | GPIO 18 |
β‘ Relay Module (Optional for Motor Control)
| Relay Pin | ESP32 Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| IN (Signal) | GPIO 23 (example pin) |
π‘ Important Tip:
- Place the ultrasonic sensor at the top of the water tank, facing downward toward the water surface.
- Make sure the sensor is fixed and away from splashes.
β 8. Working Principle β How the System Works?
This water level monitoring system works using sound waves and wireless communication. Hereβs the step-by-step explanation:
β Step 1: Ultrasonic Sensor Measures Distance
- The Ultrasonic Sensor (HC-SR04) sends sound waves using its TRIG pin.
- These waves hit the water surface and bounce back to the sensor.
- The ECHO pin receives the reflected wave.
- The time taken for the wave to return is measured.
π Formula Used:
Distance (cm) = (Time Γ Speed of Sound) / 2
Speed of sound in air = 0.034 cm/Β΅s
β Step 2: ESP32 Calculates Water Level (% Percentage)
Once the distance is measured, we convert it to water level percentage using this formula:
Water Level (%) = [(Tank Height β Measured Distance) / Tank Height] Γ 100
Example:
If tank height = 30 cm and measured distance = 5 cm, then:
Water Level (%) = [(30 β 5) / 30] Γ 100 = 83.3%
β Step 3: Sending Data to Blynk App
- ESP32 connects to Wi-Fi and sends this water level data to Blynk Cloud.
- Blynk mobile app displays the water level using a Gauge/Label Widget.
- You can see the current water level from anywhere in the world.
β Step 4: Optional β Pump/Motor Control via Relay
- If water level is low, you can press a button on the Blynk app to turn ON the water motor.
- When tank is full, you can manually or automatically switch OFF the motor using relay + ESP32.
β Conclusion of Part 2:
In this part, you learned about:
β Complete components list
β Circuit connections between ESP32 and Ultrasonic Sensor
β Working principle and formula calculation
β Optional motor control using relay
β 9. Blynk IoT App Setup (Step-by-Step Guide)
To display real-time water level on your smartphone, follow these simple steps to set up the Blynk 2.0 application.
π± Step 1: Install and Login
- Download Blynk IoT App from Play Store (Android) or App Store (iOS).
- Sign up using your Email ID or log in if you already have an account.
π± Step 2: Create New Template
- Open the Blynk app β Click on + (New Template)
- Fill the details as follows:
| Field | Value |
|---|---|
| Template Name | Water Level Monitor β YaranaIot Guru |
| Hardware | ESP32 |
| Connection Type | Wi-Fi |
π± Step 3: Add Datastream
- Go to Datastreams β Add New Datastream β Virtual Pin
Fill like this:
| Field | Value |
|---|---|
| Name | Water Level |
| Type | Virtual Pin |
| Pin | V1 |
| Unit | % |
π± Step 4: Design Dashboard
- Go to Dashboard β Click β+ Widgetβ β Select Gauge or Label
- Set widget properties:
| Setting | Value |
|---|---|
| Title | Water Tank |
| Datastream | V1 |
| Min Value | 0 |
| Max Value | 100 |
π± Step 5: Copy Template ID and Auth Token
- Tap Device Info inside the Blynk template.
- Copy Template ID, Device Name, and Auth Token.
- Paste them in Arduino code.
β 10. Complete Arduino Code (Copy and Paste Ready)
// Water Level Monitoring using ESP32 + Ultrasonic Sensor + Blynk
// Project by: YaranaIot Guru
#define BLYNK_TEMPLATE_ID "Your_Template_ID"
#define BLYNK_DEVICE_NAME "Water_Level_Monitor"
#define BLYNK_AUTH_TOKEN "Your_Blynk_Auth_Token"
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Your_WiFi_Name";
char pass[] = "Your_WiFi_Password";
#define TRIG_PIN 5
#define ECHO_PIN 18
#define TANK_HEIGHT 30 // In cm (Change according to your tank height)
long duration;
float distance;
int waterLevel;
void setup() {
Serial.begin(115200);
pinMode(TRIG_PIN, OUTPUT);
pinMode(ECHO_PIN, INPUT);
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
}
void loop() {
Blynk.run();
measureLevel();
Blynk.virtualWrite(V1, waterLevel);
delay(1000);
}
void measureLevel() {
digitalWrite(TRIG_PIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIG_PIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIG_PIN, LOW);
duration = pulseIn(ECHO_PIN, HIGH);
distance = duration * 0.034 / 2;
int waterHeight = TANK_HEIGHT - distance;
waterLevel = (waterHeight * 100) / TANK_HEIGHT;
if (waterLevel < 0) waterLevel = 0;
if (waterLevel > 100) waterLevel = 100;
Serial.print("Water Level: ");
Serial.print(waterLevel);
Serial.println(" %");
}
β 11. Code Explanation (Simple and Beginner-Friendly)
| Code Line | Meaning |
|---|---|
#define BLYNK_TEMPLATE_ID | Unique ID from Blynk to link your device |
#include <WiFi.h> | Enables Wi-Fi connection for ESP32 |
pinMode(TRIG_PIN, OUTPUT); | Sets ultrasonic TRIG pin as output |
pulseIn(ECHO_PIN, HIGH); | Reads time taken for ultrasonic wave to return |
distance = duration * 0.034 / 2; | Converts time into distance in centimeters |
waterLevel = (waterHeight * 100) / TANK_HEIGHT; | Calculates water level percentage |
Blynk.virtualWrite(V1, waterLevel); | Sends water level to smartphone via virtual pin V1 |
β What You Have Learned So Far:
β How to configure Blynk App
β How to connect ESP32 with Wi-Fi
β Complete Arduino Code to measure & send water level to phone
β Explanation line-by-line
β Next Section (Part 4) Will Include:
β Advantages of the system
β Real-life applications
β Future upgrades (Alexa, Automation, Cloud)
β Conclusion + FAQs
β Part 4 β Advantages of IoT-Based Water Level Monitoring System
The Smart IoT Water Level Monitoring System offers multiple advantages over traditional manual methods. It is not just a convenience solution but also saves time, water, and energy. Below are the main benefits:
β 1. Real-Time Water Level Monitoring
You can see the exact water level (in percentage) on your smartphone from anywhere in the world using the Blynk IoT App.
β 2. No Manual Checking Required
No need to climb stairs or open the tank lid to check water. Everything is displayed automatically on your mobile screen.
β 3. Prevents Water Overflow
You can monitor and get alerts if the water tank is about to overflow. This prevents water wastage and protects motor from unnecessary running.
β 4. Saves Electricity & Motor Life
By turning off the motor at the correct time, you reduce electricity usage and increase the lifetime of the pump.
β 5. Works from Anywhere (Wi-Fi + Internet)
As long as your ESP32 is connected to Wi-Fi and your phone has internet, you can access water levels globally.
β 6. Low-Cost & Easy to Build
This DIY project uses affordable components like ESP32 and an Ultrasonic Sensor, making it budget-friendly for students, hobbyists, engineers, and homeowners.
β 7. Expandable & Customizable
Future upgrades like automatic motor control, voice commands using Alexa/Google Assistant, WhatsApp Alerts, and Cloud Data Logging can be easily added.
β Part 5 β Real-Life Applications
This system is not limited to homes only. It can be used in several fields:
| Application Area | Usage and Benefits |
|---|---|
| Homes & Apartments | Monitor overhead and underground water tanks automatically. |
| Schools & Colleges | Manage daily water usage in hostels, kitchens, and bathrooms. |
| Industries & Factories | Useful for chemical tanks, cooling towers, and storage tanks. |
| Farms & Agriculture | Monitor irrigation tanks and manage water supply to fields. |
| Hotels & Hospitals | Ensures continuous water supply without human intervention. |
| Commercial Buildings | Used in large water supply systems to avoid wastage and improve efficiency. |
β Part 6 β Future Upgrades (By YaranaIot Guru)
This project can be made more advanced by adding smart automation and IoT cloud services.
π 1. Automatic Motor ON/OFF Control
- If water level is low β Motor turns ON automatically
- If tank is full β Motor turns OFF automatically using relay + code logic
π 2. Voice Control using Alexa / Google Assistant
- Control the water pump using voice commands
- Example: βAlexa, turn ON the water pumpβ
- Integrate with Blynk + IFTTT + Google Assistant/Alexa
π 3. Telegram / WhatsApp Alerts
- Receive a message when the tank is full or empty
- Example: βπ¨ Alert: Water tank is 95% full. Please turn off the motor.β
π 4. Cloud Data Logging (Firebase / Thingspeak)
- Store water level data online
- Useful for analytics, graphs, daily usage tracking
π 5. Solar-Powered System
- Use a solar panel + battery module to run ESP32 and sensor
- Makes the entire system energy-efficient and independent
π 6. Voice Announcement System
- Add a speaker + MP3 module to make voice alerts like βTank is fullβ or βLow water level detectedβ.
β Part 7 β Troubleshooting & Common Mistakes
| Problem / Issue | Possible Reason | Solution |
|---|---|---|
| ESP32 not connecting to Wi-Fi | Wrong SSID or Password | Check Wi-Fi name and password in the code |
| Blynk app showing βDevice Offlineβ | Incorrect Auth Token or Template ID | Copy-paste correct details from Blynk app |
| Water level always showing 0% | Wrong tank height, loose sensor wiring | Measure tank height properly and secure connections |
| Sensor giving wrong values | Tank moisture, Echo pin not stable | Use waterproof sensor or wrap ultrasonic sensor properly |
| Motor not working with relay | Relay VCC not powered or wrong GPIO pin | Connect relay VCC to 5V and signal to correct ESP32 pin |
β Part 8 β Conclusion
Water is a precious resource, and managing it smartly is our responsibility. This IoT-Based Water Level Monitoring System using ESP32, Ultrasonic Sensor, and Blynk App is a low-cost, efficient, and modern solution to a common problem.
With this system, developed and presented by YaranaIot Guru, you can:
β Monitor your tank water level in real-time
β Prevent overflow and water wastage
β Save electricity and pump life
β Control the motor from your smartphone
β Upgrade to voice control, automation, and cloud analytics
This project is perfect for students, DIY creators, homeowners, IoT enthusiasts, and anyone who wants to make their home smarter and more efficient.
β Part 9 β Frequently Asked Questions (FAQs)
1. Can I use NodeMCU instead of ESP32?
Yes, you can use NodeMCU (ESP8266), but ESP32 is faster, has more GPIO pins, and supports dual-core processing.
2. Can I use this system without the internet?
Yes, it can work on local Wi-Fi, but remote monitoring requires internet access.
3. What is the ideal tank height for this project?
You can set any height in centimeters; just change the value of TANK_HEIGHT in the code.
4. Can I monitor multiple tanks?
Yes, by using multiple sensors and virtual pins (V1, V2, V3, etc.) on Blynk.
5. Is the ultrasonic sensor waterproof?
The HC-SR04 is not waterproof. For outdoor tanks or high moisture, use JSN-SR04T (waterproof ultrasonic sensor).
6. How can I protect the sensor from water splashes?
Place it inside a small plastic box or PVC pipe, facing downward.
7. Can I add auto motor control later?
Yes! Just add a relay and small code changes. I can provide that code if you want.
π Contact YaranaIoT Guru Empowering IoT Innovation | ESP32 | Home Automation | Smart Solutions | 50K+ Community
Weβd love to hear from you! Whether you have questions about IoT projects, collaboration opportunities, technical support, custom PCB design, bulk kit orders, corporate training, college workshops, or freelance development β weβre just one message away.
βοΈ Email (Official)
For all inquiries, project support, business collaboration, sponsorships, or documentation requests: π© contact@yaranaiotguru.in π§ Alternate: support@yaranaiotguru.in β³ Response Time: Within 24 hours (MonβSat) π‘ Use email for detailed queries with attachments (code, schematics, etc.)
π± Phone / WhatsApp (24Γ7 Support)
Instant live technical help, project consultation, troubleshooting, or order status: π +91 70527 22734 π¬ WhatsApp: Chat Now β° Call Timing: MonβSat, 10 AM β 7 PM IST π Emergency Support: WhatsApp anytime (reply within 1 hour)
π Official Website
Full project tutorials, downloadable code, PDF guides, schematics, blogs, free tools, and online store: π www.yaranaiotguru.in π Shop: yaranaiotguru.in/shop (ESP32 DevKits, Sensors, Relays, Custom PCBs, Project Kits)
βΆοΈ YouTube Channel
Step-by-step IoT tutorials, live coding, project builds, ESP32 programming, Blynk, Node-RED, MQTT, Home Assistant, and real-time demos: π Yarana IoT Guru πΊ 1,200+ Videos | 52K+ Subscribers | 5.5M+ Views | 4.8β Rating π₯ New Video Every Week π Subscribe & Turn On Notifications
π GitHub (100% Open Source)
All source codes, Arduino IDE sketches, PlatformIO projects, Node-RED flows, MQTT configs, and full documentation: π github.com/YaranaIotGuru β 50+ Repositories | 10K+ Stars & Forks π Top Projects:
- ESP32 WebSocket Real-Time Dashboard
- Smart Home with Blynk & Alexa
- IoT Irrigation System with Soil Moisture
- MQTT + Node-RED + MySQL Logging
- OLED Weather Station with API
πΈ Instagram
Daily IoT reels, quick tips, project teasers, live builds, student showcases, and giveaways: π @YaranaIoTGuru π± 10K+ Followers | Reels | Stories | Live Sessions
πΌ LinkedIn (Professional Network)
For B2B collaborations, IoT consulting, corporate training, startup partnerships, hiring, and industry insights: π Yarana IoT Guru π€ Services Offered:
- Custom IoT Product Development
- Embedded Systems Training
- College Workshops & FDPs
- PCB Design & Prototyping
π¦ Twitter / X
Real-time updates, tech news, poll-based Q&A, project launches, and community engagement: π @YaranaIoTGuru π’ Follow for instant alerts
π Hackster.io (Project Showcases)
In-depth project write-ups, circuit diagrams, bill of materials (BOM), code explanations, and user ratings: π hackster.io/yaranaiotguru π 50+ Published Projects | 100K+ Views | Top 5% Creator
π Instructables (DIY Guides)
Beginner-friendly step-by-step guides, printable templates, tool lists, and troubleshooting sections: π instructables.com/member/YaranaIoTGuru π Featured Instructables:
- Automatic Plant Watering System
- Voice-Controlled Home Appliances
- WiFi-enabled Temperature Monitor
π Medium Blog
Technical articles, IoT trends, tutorials, case studies, and career tips in embedded systems: π medium.com/@yaranaiotguru βοΈ 50+ Articles | 15K+ Readers
π Online Store & Kits
Ready-to-use IoT project kits, custom PCBs, sensors, modules, and merch: π yaranaiotguru.in/shop π¦ Free Shipping in India above βΉ999 π³ Payment: UPI, Card, Wallet, COD
π Community Platforms
| Platform | Link | Purpose |
|---|---|---|
| Telegram Channel | t.me/YaranaIoTGuru | Project files, PDFs, updates |
| Telegram Group | t.me/YaranaIoTCommunity | Peer support, doubts |
| Discord Server | discord.gg/yarana-iot | Live voice help, coding rooms |
| WhatsApp Community | Join Here | Announcements & polls |
π’ Office & Studio Address
Yarana Studio & Software (Yarana IoT Guru HQ) π Near Rookh Baba Mandir Umariya Badal Urf Gainda, Allahabad (Prayagraj), Uttar Pradesh β 212507, India β Google Rating: 5.0 β (Based on 100+ Reviews) π Opening Hours:
- Monday β Saturday: 10:00 AM β 5:00 PM
- Sunday: Closed π Associated Website: yaranawebtech.inπΊοΈ View on Google Maps(Search: “Yarana Studio & Software”)π Walk-ins welcome | Appointment recommended for project discussions