A water level sensor connected to Arduino or ESP32 solves one of the most common household problems in India — knowing when your overhead tank is full, half-empty, or running dry. Instead of climbing to the terrace every few hours or running the motor blindly, a simple sensor setup gives you real-time water level data on a display, your phone, or even triggers the pump automatically. This guide covers every sensor type suitable for water tank monitoring, with wiring diagrams, Arduino code, and a complete IoT solution using ESP32.
Water Level Sensor Types Compared
There are four main approaches to measuring water level, each with trade-offs in accuracy, cost, durability, and ease of installation:
| Type | How It Works | Accuracy | Price (₹) | Durability |
|---|---|---|---|---|
| Ultrasonic | Measures distance to water surface | ±3mm | 150-500 | Excellent (no contact) |
| Float switch | Magnet in float triggers reed switch | Fixed points only | 50-150 | Good (moving parts) |
| Capacitive | Detects water through container wall | On/off only | 80-200 | Excellent (non-contact) |
| Resistive probe | Measures resistance between probes | Graduated levels | 30-80 | Poor (corrodes) |
Ultrasonic Water Level Monitoring
Ultrasonic sensors are the best choice for continuous water level measurement. They mount at the top of the tank (no water contact), measure the distance to the water surface, and you calculate the water level by subtracting from the known tank height.
JSN-SR04T — The Waterproof Choice
While the standard HC-SR04 works for experiments, its electronics aren’t waterproof. For a real tank installation, use the JSN-SR04T or AJ-SR04M — they have sealed ultrasonic probes connected by cable to a separate control board that stays dry. The probe mounts through a hole in the tank lid or hangs inside the tank opening.
Key specifications for water tank use:
- Minimum distance: 20 cm (mount the sensor at least 20 cm above maximum water level)
- Maximum distance: 450 cm (covers most residential tanks)
- Beam angle: About 75° — in narrow tanks, reflections off walls can cause false readings
- Operating voltage: 5V DC
Dealing with Condensation
Indian water tanks, especially plastic ones on rooftops, develop condensation on the lid during temperature changes. This can cause water droplets on the ultrasonic probe, affecting accuracy. Mounting the probe at a slight angle (10-15°) and using a small ventilation hole in the enclosure helps prevent moisture buildup.
Float Switch for Simple Level Detection
Float switches are the simplest and most reliable water level sensors. A buoyant float contains a magnet that triggers a reed switch at a set level. They output a simple HIGH/LOW signal — water reached this level, or it hasn’t.
Use multiple float switches at different heights (25%, 50%, 75%, 100%) for graduated level indication. Wire each to a digital pin on Arduino.
// Multi-level float switch reader
const int LEVEL_25 = 2;
const int LEVEL_50 = 3;
const int LEVEL_75 = 4;
const int LEVEL_100 = 5;
void setup() {
Serial.begin(9600);
pinMode(LEVEL_25, INPUT_PULLUP);
pinMode(LEVEL_50, INPUT_PULLUP);
pinMode(LEVEL_75, INPUT_PULLUP);
pinMode(LEVEL_100, INPUT_PULLUP);
}
void loop() {
int level = 0;
if (digitalRead(LEVEL_25) == LOW) level = 25;
if (digitalRead(LEVEL_50) == LOW) level = 50;
if (digitalRead(LEVEL_75) == LOW) level = 75;
if (digitalRead(LEVEL_100) == LOW) level = 100;
Serial.print("Water level: ");
Serial.print(level);
Serial.println("%");
delay(1000);
}
Float switches are common in Indian pump controllers because they’re mechanical — no calibration, no software, just a switch. The drawback is that you only get level readings at the points where switches are installed, not a continuous measurement.
Capacitive and Resistive Sensors
Capacitive Non-Contact Sensors
Capacitive sensors detect water through the tank wall (plastic or glass, not metal). They’re ideal when you can’t or don’t want to make holes in the tank. Stick the sensor on the outside of the tank wall at the desired detection level. They output a digital signal when water is present at that level.
These work best with thin-walled plastic tanks. Thick concrete tanks may not work. Install a sensor at each level you want to monitor.
Resistive Water Level Sensors
The common PCB-style water level sensor uses exposed traces that measure resistance based on how much of the sensor is submerged. They’re extremely cheap (₹30-50) and great for learning, but they corrode quickly in real-world use. The exposed copper traces develop a layer of corrosion within weeks of continuous water contact, making readings unreliable.
For prototyping and learning, they’re fine. For a permanent installation, use ultrasonic or float switches instead.
Arduino Water Level Project with Ultrasonic Sensor
Here’s a complete water level monitor using a waterproof ultrasonic sensor and LED bar graph display:
#include <SoftwareSerial.h>
const int trigPin = 9;
const int echoPin = 10;
const int ledPins[] = {2, 3, 4, 5, 6}; // 5 LEDs for level indication
const int buzzerPin = 7;
const float TANK_HEIGHT = 100.0; // Tank height in cm
const float SENSOR_OFFSET = 5.0; // Distance from sensor to full level
void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzerPin, OUTPUT);
for (int i = 0; i 95%) or empty ( 95 || percentage < 10) {
tone(buzzerPin, 1000, 200);
}
delay(2000);
}
float measureDistance() {
// Take 5 readings and return median for stability
float readings[5];
for (int i = 0; i < 5; i++) {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
readings[i] = pulseIn(echoPin, HIGH) * 0.034 / 2;
delay(50);
}
// Simple bubble sort for median
for (int i = 0; i < 4; i++) {
for (int j = i + 1; j < 5; j++) {
if (readings[j] < readings[i]) {
float temp = readings[i];
readings[i] = readings[j];
readings[j] = temp;
}
}
}
return readings[2]; // Return median
}
void updateLEDs(float percentage) {
int activeLEDs = map(percentage, 0, 100, 0, 5);
for (int i = 0; i < 5; i++) {
digitalWrite(ledPins[i], i < activeLEDs ? HIGH : LOW);
}
}
ESP32 IoT Tank Monitor with Mobile Alerts
An ESP32-based monitor adds WiFi, enabling you to check water levels from your phone and receive alerts. Connect the JSN-SR04T the same way — Trig to GPIO5, Echo to GPIO18.
Popular dashboard options for Indian users:
- Blynk — Free tier supports 2 devices, has a polished mobile app. Good for families who want a simple interface
- ThingSpeak — Free for up to 3 million messages/year. Great for data logging and trend charts
- Telegram Bot — No app installation needed beyond Telegram. Send level readings on request or when level crosses thresholds
- Custom web dashboard — ESP32 hosts a simple webpage showing current level. Access from any device on the same WiFi network
For Telegram alerts, use the UniversalTelegramBot library. Set up a bot via BotFather, get the chat ID, and send messages when the water level drops below 20% or rises above 95%.
Automatic Pump Controller
The logical next step is automating the pump. Use a relay module to switch the pump motor based on water level:
- Turn pump ON when level drops below 20%
- Turn pump OFF when level reaches 90% (not 100% — leave headroom to prevent overflow)
- Add a dry-run protection check — if the level doesn’t rise within 5 minutes of pump activation, the underground sump may be empty. Shut off the pump to prevent motor damage.
Safety considerations for pump control:
- Use an appropriately rated relay (10A minimum for most domestic pumps)
- Add a manual override switch so the pump can be operated without the controller
- Include a hardware safety cutoff (float switch at the overflow level) independent of the Arduino
- Use opto-isolated relay modules to protect the Arduino from mains voltage spikes
- Ensure proper earthing of the pump and relay enclosure per IS 732 standards
Frequently Asked Questions
Which water level sensor is most reliable for Indian rooftop tanks?
The JSN-SR04T waterproof ultrasonic sensor is the most reliable for long-term installations. It has no moving parts, no water contact with electronics, and handles the temperature extremes on Indian rooftops (0°C winter nights to 60°C summer surface temperatures). Float switches are a close second for simplicity.
Can I monitor underground sump and overhead tank together?
Yes. Use two sensors — one in each tank — connected to the same Arduino or ESP32. The controller reads both levels and runs the pump only when the sump has water (above 20%) and the overhead tank needs filling (below 20%). This prevents dry-running the pump.
How do I waterproof the electronics enclosure?
Use an IP65-rated ABS junction box (available at electrical shops for ₹100-200). Seal cable entry points with silicone sealant. Mount the box in a shaded spot — direct sunlight on a plastic enclosure can push internal temperatures above 70°C, damaging the ESP32. If shade isn’t available, use a white enclosure and add small ventilation holes (covered with mesh to keep insects out).
Does ultrasonic work with metal tanks?
Yes, ultrasonic sensors work inside metal tanks — sound bounces off the water surface regardless of tank material. The sensor mounts at the top looking downward. Capacitive sensors, however, won’t work through metal walls.
My ultrasonic readings are jumping erratically. How do I fix it?
Common causes: water splashing (from inlet pipe), condensation on the probe, or the sensor detecting tank walls instead of the water surface. Solutions: mount the sensor away from the water inlet, use a PVC pipe sleeve to create a calm measurement column (a 10cm diameter pipe hanging in the water), and take the median of 5-10 readings instead of a single reading.
Conclusion
A water level monitoring system can be as simple as a ₹50 float switch with an LED indicator or as sophisticated as an ESP32-based IoT controller with phone alerts and automatic pump management. For most Indian homes, a JSN-SR04T ultrasonic sensor with an ESP32 and Telegram alerts hits the sweet spot — accurate, reliable, affordable, and accessible from anywhere on your phone.
Get started with the right sensors from Zbotic’s sensor collection and bring intelligence to your water management.
Add comment