IoT Based Smart Water Level Monitoring System using ESP32, Ultrasonic Sensor & Blynk

IoT Based Smart Water Level Monitoring System using ESP32, Ultrasonic Sensor & Blynk

ESP32

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?

ProblemSolution Provided by This Project
Water tank overflowReal-time alert and motor control
Dry tank and motor damageLow water level alerts
Manual checking requiredFully wireless & automatic
No monitoring from outside homeWorks globally via internet
High-cost commercial systemsLow-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 NameQuantityDescription / Use
ESP32 Wi-Fi Development Board1Main microcontroller with built-in Wi-Fi (sends data to Blynk Cloud)
Ultrasonic Sensor (HC-SR04)1Measures distance between sensor and water surface
Blynk IoT App (Android/iOS)1Displays real-time water level on your mobile phone
Jumper Wires (Male-to-Female/Male-to-Male)As neededFor wiring connections
USB Cable / 5V Power Supply1Powers the ESP32 board
Relay Module (Optional)1Used to turn ON/OFF the water pump from Blynk App
Water Tank (Any size)1The 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 PinESP32 Pin
VCC5V
GNDGND
TRIGGPIO 5
ECHOGPIO 18

⚑ Relay Module (Optional for Motor Control)

Relay PinESP32 Pin
VCC5V
GNDGND
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:
FieldValue
Template NameWater Level Monitor – YaranaIot Guru
HardwareESP32
Connection TypeWi-Fi

πŸ“± Step 3: Add Datastream

  • Go to Datastreams β†’ Add New Datastream β†’ Virtual Pin
    Fill like this:
FieldValue
NameWater Level
TypeVirtual Pin
PinV1
Unit%

πŸ“± Step 4: Design Dashboard

  • Go to Dashboard β†’ Click β€œ+ Widget” β†’ Select Gauge or Label
  • Set widget properties:
SettingValue
TitleWater Tank
DatastreamV1
Min Value0
Max Value100

πŸ“± 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 LineMeaning
#define BLYNK_TEMPLATE_IDUnique 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 AreaUsage and Benefits
Homes & ApartmentsMonitor overhead and underground water tanks automatically.
Schools & CollegesManage daily water usage in hostels, kitchens, and bathrooms.
Industries & FactoriesUseful for chemical tanks, cooling towers, and storage tanks.
Farms & AgricultureMonitor irrigation tanks and manage water supply to fields.
Hotels & HospitalsEnsures continuous water supply without human intervention.
Commercial BuildingsUsed 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 / IssuePossible ReasonSolution
ESP32 not connecting to Wi-FiWrong SSID or PasswordCheck Wi-Fi name and password in the code
Blynk app showing β€œDevice Offline”Incorrect Auth Token or Template IDCopy-paste correct details from Blynk app
Water level always showing 0%Wrong tank height, loose sensor wiringMeasure tank height properly and secure connections
Sensor giving wrong valuesTank moisture, Echo pin not stableUse waterproof sensor or wrap ultrasonic sensor properly
Motor not working with relayRelay VCC not powered or wrong GPIO pinConnect 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

PlatformLinkPurpose
Telegram Channelt.me/YaranaIoTGuruProject files, PDFs, updates
Telegram Groupt.me/YaranaIoTCommunityPeer support, doubts
Discord Serverdiscord.gg/yarana-iotLive voice help, coding rooms
WhatsApp CommunityJoin HereAnnouncements & 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

Leave a Reply

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