IoT-Based Underground Water Tank Level Monitoring Using ESP32 – Complete Project Guide

IoT-Based Underground Water Tank Level Monitoring Using ESP32 – Complete Project Guide

IoT Projects ESP32 Projects

Water has always been one of the most essential resources for human life, yet one of the most mismanaged. In households, apartments, and industries, water stored in underground tanks plays a major role in maintaining daily water usage. However, these tanks are usually placed outside the home, covered, dark, and located at an inconvenient position which makes checking water level difficult.

Most of the time, people directly switch ON the motor without even knowing how much water is available in the underground tank. Sometimes, tanks overflow because no one knows when the water reaches the top. Sometimes, the motor runs dry because the water has completely drained out. Both situations lead to waste of water, waste of electricity, and unnecessary damage to pumps.

To solve this real-world problem, today we will build a complete IoT-Based Underground Water Tank Level Monitoring System using ESP32, explained in detail by YaranaIoT Guru, your trusted platform for IoT-based projects and tutorials.

This system uses an ultrasonic sensor placed at the top of the underground tank, which measures the distance to the water surface. The ESP32 then processes this data and shows the exact water level percentage on your smartphone through the Blynk IoT app. You can access this data from anywhere in the world. You also get notifications when the tank is full or water is too low.

This is a smart automation project that brings real convenience to daily life and helps you manage water efficiently.


2. Why This Project is Important?

Water levels in underground tanks are usually checked manually—but manual checking is:

  • Time consuming
  • Inaccurate
  • Inconvenient
  • Often ignored
  • Not possible when you are away from home
  • Causes overflow and wastage
  • Causes pump dry running

That’s why creating a smart IoT-based monitoring system becomes important. This system ensures:

  • ✔ Accurate water level measurement
  • ✔ Mobile-based monitoring
  • ✔ Instant notifications
  • ✔ Remote access
  • ✔ No wastage of water
  • ✔ No overflow
  • ✔ No dry running
  • ✔ Smart home integration

This project by YaranaIoT Guru is highly suitable for homes, apartments, hospitals, industries, agriculture, and smart buildings.


3. System Overview

The system uses three major components:

  1. Ultrasonic Sensor (HC-SR04)
  2. ESP32 Microcontroller with WiFi
  3. Blynk IoT Cloud

The ultrasonic sensor continuously measures the distance between itself and the water surface. ESP32 converts this data to percentage based on tank height. It then uploads the data to Blynk Cloud. The Blynk mobile app displays:

  • Real-time water level %
  • Low water alert
  • Full tank alert

This makes the entire water management process smart and automated.


4. Components Required (Explained in Detail)

Below is the detailed list of components used in this project. Explanation provided by YaranaIoT Guru.


4.1 ESP32 Microcontroller (Main Brain)

ESP32 is a powerful and highly flexible microcontroller with:

  • Dual-core CPU
  • Built-in WiFi & Bluetooth
  • Multiple GPIO pins
  • High speed
  • Compatible with IoT platforms

It is perfect for real-time IoT tasks like data uploading, sensor reading, and notifications.


4.2 Ultrasonic Sensor HC-SR04

This sensor uses ultrasonic waves to measure distance.

  • Range: 2 cm to 400 cm
  • Accuracy: high
  • Used widely for level detection
  • Works perfectly for water tanks

It sends out a sound wave which reflects back from the water surface. The time taken for echo is used to calculate distance.


4.3 Jumper Wires

Used for connecting ESP32 and ultrasonic sensor.


4.4 PVC Pipe (Optional but Recommended)

Using PVC pipe around the sensor helps avoid:

  • Moisture
  • Sensor vibration
  • False readings due to tank walls

4.5 5V Power Adapter

ESP32 requires 5V for proper operation.


4.6 Smartphone with Blynk IoT App

To monitor the tank level remotely.


5. Block Diagram Explanation

Below is a simple block diagram of the system:

                   Smartphone (Blynk App)
                           |
                     Blynk Cloud Server
                           |
                         WiFi Router
                           |
                          ESP32
                           |
                    Ultrasonic Sensor
                           |
                  Underground Water Tank

Explanation:

  1. The ultrasonic sensor measures tank level.
  2. The ESP32 processes measurement.
  3. ESP32 sends data to Blynk Cloud.
  4. The user can check the water level from the Blynk App anytime.

6. Working Principle (Step-by-Step)

Here is how the system works internally:

Step 1: Ultrasonic wave transmission

The ultrasonic sensor continuously emits high-frequency sound waves.

Step 2: Reflection from water

The waves hit the water surface and bounce back.

Step 3: Time Measurement

The echo return time is measured through the Echo pin.

Step 4: Distance Calculation

Formula:

Distance = (Time × Speed of Sound) / 2

Step 5: Tank Height Calculation

If tank height = 120 cm
Sensor reading distance = 30 cm
Water height = 120 – 30 = 90 cm

Step 6: Percentage Calculation

( waterHeight / tankHeight ) × 100

Step 7: Upload to Blynk Cloud

ESP32 sends percentage to server.

Step 8: App Monitoring

User can track live data.

Step 9: Alerts

If < 20% → Low Water Level
If > 95% → Tank Full

Fully explained by YaranaIoT Guru.


7. Wiring / Circuit Connections

Here is the clear wiring table:

SensorESP32
VCC5V
GNDGND
TRIGGPIO 5
ECHOGPIO 18

Make sure connections are tight and sensor faces the water surface properly.


8. Blynk IoT Setup (2025 Latest Version)

Follow the steps below:


Step 1: Open Blynk App

Sign up using email.


Step 2: Create New Template

Template Name → Water Tank Monitor – YaranaIoT Guru
Hardware → ESP32
Connection → WiFi

Copy:

  • Template ID
  • Auth Token

Step 3: Add Datastream

V1 → Water Level (%)


Step 4: Create Dashboard

Add:

  • Gauge widget
  • Level indicator
  • Notification alert
  • Value display

Set V1 for all widgets.


Step 5: Add Device

Add new device using Template.

Your cloud setup is now complete.


9. Complete ESP32 Code (2000-word blog optimized)

// IoT-Based Underground Water Tank Level Monitoring System Using ESP32
// Developed by YaranaIoT Guru

#define BLYNK_TEMPLATE_ID "Your_Template_ID"
#define BLYNK_DEVICE_NAME "Water Tank Monitor"
#define BLYNK_AUTH_TOKEN "Your_Auth_Token"

#include <WiFi.h>
#include <BlynkSimpleEsp32.h>

char ssid[] = "YourWiFiName";
char pass[] = "YourWiFiPassword";

#define TRIG 5
#define ECHO 18

long duration;
float distance;
float waterLevelPercent;

int tankHeight = 120; // set according to your tank height

void setup() {
  Serial.begin(115200);

  pinMode(TRIG, OUTPUT);
  pinMode(ECHO, INPUT);

  Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);

  Serial.println("System Initialized by YaranaIoT Guru");
}

void loop() {
  Blynk.run();
  calculateLevel();
}

void calculateLevel() {
  digitalWrite(TRIG, LOW);
  delayMicroseconds(2);

  digitalWrite(TRIG, HIGH);
  delayMicroseconds(10);
  digitalWrite(TRIG, LOW);

  duration = pulseIn(ECHO, HIGH);
  distance = duration * 0.034 / 2;

  float waterHeight = tankHeight - distance;

  if (waterHeight < 0) waterHeight = 0;
  if (waterHeight > tankHeight) waterHeight = tankHeight;

  waterLevelPercent = (waterHeight / tankHeight) * 100;

  Serial.print("Water Level: ");
  Serial.print(waterLevelPercent);
  Serial.println("%");

  Blynk.virtualWrite(V1, waterLevelPercent);

  if (waterLevelPercent < 20) {
    Blynk.logEvent("low_level", "Water Below 20% - YaranaIoT Guru");
  }

  if (waterLevelPercent > 95) {
    Blynk.logEvent("tank_full", "Tank Full - YaranaIoT Guru");
  }

  delay(2000);
}

10. Installation Process (Real Tank Setup)

This step is extremely important for accuracy.

Step 1: Take a PVC pipe of 1-inch diameter.

Step 2: Fix ultrasonic sensor at top of pipe.

Step 3: Place pipe vertically inside the underground tank.

Step 4: Mount ESP32 outside the tank.

Step 5: Use waterproof casing.

Step 6: Use long wires if required.

Step 7: Give power using USB adapter.

Now open Blynk and start monitoring.


11. Advantages of This System

  • Highly accurate
  • Low cost
  • Real-time monitoring
  • Remote access
  • Prevents overflow
  • Saves water
  • Saves electricity
  • Easy to install
  • Works globally
  • Supports automation

12. Real-World Applications

  • Residential homes
  • Apartment complexes
  • Hostels
  • Hospitals
  • Water storage systems
  • Industrial tanks
  • Agricultural water tanks
  • Smart buildings

13. Troubleshooting Guide

❌ Sensor not reading properly

✔ Use PVC pipe
✔ Make sure sensor isn’t tilted

❌ WiFi not connecting

✔ Check SSID/password
✔ Keep ESP32 close to router

❌ Wrong percentage

✔ Update tankHeight value

❌ Blynk not updating

✔ Reboot ESP32
✔ Check Auth Token


14. FAQs

Q1: Can this system run without WiFi?

No, because IoT needs cloud connection. But data will restore once WiFi reconnects.

Q2: Can I control the motor automatically?

Yes! ESP32 can control a relay module. If you want, I will give full code & wiring.

Q3: Is ultrasonic sensor waterproof?

No, but PVC pipe protects it. Waterproof sensors are available but expensive.

Q4: What is total cost of this project?

₹600 to ₹1000 approx.

📞 Contact YaranaIoT Guru Empowering IoT Innovation | ESP32 | Home Automation | Smart Solutions | 50K+ Community

We’d love to hear from you! Whether it’s IoT project queries, collaborations, tech support, custom PCB design, bulk orders, corporate training, college workshops, or freelance development — we’re just one message away.


✉️ Email (Official)

For detailed inquiries, project support, business collaboration, sponsorships, or documentation: 📩 contact@yaranaiotguru.in 📧 Alternate: support@yaranaiotguru.inResponse: Within 24 hours (Mon–Sat) 💡 Best for attachments (code, schematics, logs, etc.)


📱 Phone / WhatsApp (24×7 Support)

Instant live help, troubleshooting, project consultation, or order updates: 📞 +91 70527 22734 💬 WhatsApp: Chat NowCall Hours: Mon–Sat, 10 AM – 7 PM IST 🚀 Emergency? WhatsApp anytime — reply within 1 hour


🌐 Official Website

Tutorials, code, PDFs, schematics, blogs, free tools & online store: 🔗 www.yaranaiotguru.in 🛒 Shop: yaranaiotguru.in/shop (ESP32 DevKits, Sensors, Relays, Custom PCBs, Project Kits)


▶️ YouTube Channel

Step-by-step IoT builds, live coding, ESP32, Blynk, Node-RED, MQTT, Home Assistant & more: 🔗 Yarana IoT Guru 📺 1,200+ Videos | 52K+ Subs | 5.5M+ Views | 4.8★ Rating 🎥 New Video Every Week — 🔔 Subscribe & Turn On Notifications


🛠 GitHub (100% Open Source)

All codes, Arduino sketches, PlatformIO projects, Node-RED flows, MQTT configs & docs: 🔗 github.com/YaranaIotGuru50+ Repos | 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 reels, quick tips, live builds, student showcases & giveaways: 🔗 @YaranaIoTGuru 📱 10K+ Followers | Reels | Stories | Live Sessions


💼 LinkedIn (Professional Network)

B2B, IoT consulting, training, hiring & partnerships: 🔗 Yarana IoT Guru

🤝 Services Offered:

  • Custom IoT Product Development
  • Embedded Systems Training
  • College Workshops & FDPs
  • PCB Design & Prototyping

🐦 Twitter / X

Real-time updates, polls, project launches & community Q&A: 🔗 @YaranaIoTGuru 📢 Follow for instant alerts


🛠 Hackster.io (Project Showcases)

In-depth write-ups, circuits, BOM, code & ratings: 🔗 hackster.io/yaranaiotguru 🏆 50+ Projects | 100K+ Views | Top 5% Creator


📝 Instructables (DIY Guides)

Beginner-friendly step-by-step guides with templates & troubleshooting: 🔗 instructables.com/member/YaranaIoTGuru

🛠 Featured Guides:

  • Automatic Plant Watering System
  • Voice-Controlled Home Appliances
  • WiFi-enabled Temperature Monitor

📚 Medium Blog

Deep-dive articles, trends, tutorials & career tips in embedded systems: 🔗 medium.com/@yaranaiotguru ✍️ 50+ Articles | 15K+ Readers


🛒 Online Store & Kits

Ready-to-use IoT kits, custom PCBs, sensors & 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 ★ (100+ Reviews)

🕒 Opening Hours: Mon–Sat: 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 *