A Sensor That Watches Water Levels — and Warns Before It Floods
This little device bounces sound waves off the water below it to measure how high it has risen. As the level climbs, it lights up green, then yellow, then red — and if things get critical, it sounds a buzzer and sends a text message, just like a real flood warning system.
What This Alert System Can Do
An Arduino Nano runs the whole system. An ultrasonic sensor — the same kind of sensor bats and submarines use — measures the distance down to the water's surface, so the Arduino always knows exactly how high the water has risen.
- Measures water level continuously using sound-wave distance sensing.
- Shows a traffic-light status with green (safe), yellow (rising) and red (danger) LEDs.
- Sounds a buzzer the moment water reaches the critical threshold.
- Sends an SMS alert through a GSM module, so help can be called even without Wi-Fi.
Parts You'll Need
Everything here is easy to find online or at a local electronics store.
Arduino Nano
Reads the sensor, controls the LEDs and triggers the SMS alert.
₹450HC-SR04 Ultrasonic Sensor
Measures distance to the water surface using sound waves.
₹100Green, Yellow & Red LEDs
A simple traffic-light display for water level status.
₹30Buzzer
Sounds a loud alarm when the water level turns critical.
₹30SIM800L GSM Module
Sends a real SMS text alert to a phone, no internet needed.
₹500Activated SIM Card
Any basic SIM with an active plan works for sending SMS.
—Dedicated 4V Power Supply
A separate regulated supply just for the power-hungry SIM800L.
₹200Resistors & Jumper Wires
220Ω resistors for each LED, plus wiring for the whole circuit.
₹100Build It Step by Step
Build and test on a breadboard first, somewhere dry, before mounting the sensor near any water.
Gather parts and plan the mount
The HC-SR04 needs to face straight down at the water from above — plan a mounting point like a bracket over a tank or drain, well clear of the water itself.
Wire the ultrasonic sensor
Connect the HC-SR04's Trig and Echo pins to two digital pins on the Arduino Nano, and power it from 5V.
Wire the LED indicators
Connect the green, yellow and red LEDs, each through its own 220Ω resistor, to three digital pins.
Add the buzzer
Wire the buzzer to a spare digital pin so it can sound an alarm the moment the water reaches the red zone.
Wire the GSM module
Connect the SIM800L to its own 3.7-4.2V power supply — never the Arduino's 5V pin — since it can briefly draw up to 2A while sending a message.
Upload the code
Install the Arduino IDE's SoftwareSerial support (built in), insert an activated SIM card into the SIM800L, and upload the sketch from the code section below.
Mount and test safely
Mount the sensor above the water source and test each alert level by slowly raising a cup of water underneath it — never test near a real flood risk.
Circuit Diagram
Here's how every part connects back to the Arduino Nano, with the GSM module on its own separate power line.
| Module | Module Pin | Arduino Nano Pin |
|---|---|---|
| HC-SR04 Ultrasonic Sensor | Trig | D9 |
| Echo | D8 | |
| Green LED | Anode (via resistor) | D4 |
| Yellow LED | Anode (via resistor) | D5 |
| Red LED | Anode (via resistor) | D6 |
| Buzzer | Signal pin | D7 |
| SIM800L GSM Module | RX (via voltage divider) | D3 |
| TX | D2 | |
| VCC / GND | Dedicated 4V supply / shared GND |
Arduino Code
This sketch uses the built-in SoftwareSerial library to talk to the SIM800L with simple AT commands.
// ===== FLOOD WATER LEVEL ALERT SYSTEM ===== // Measures water level with an ultrasonic sensor, // shows a traffic-light status, and texts an alert // when the water level turns critical. #include <SoftwareSerial.h> // ---- Pins ---- #define TRIG_PIN 9 #define ECHO_PIN 8 #define LED_GREEN 4 #define LED_YELLOW 5 #define LED_RED 6 #define BUZZER 7 SoftwareSerial sim800(2, 3); // RX, TX to the GSM module // ---- Tank settings (change these to match your setup) ---- const int TANK_HEIGHT_CM = 100; // distance from sensor to tank bottom const int YELLOW_LEVEL_CM = 60; // water level that triggers "rising" const int RED_LEVEL_CM = 85; // water level that triggers "danger" String alertNumber = "+91XXXXXXXXXX"; // phone number to text bool alertSent = false; void setup() { Serial.begin(9600); sim800.begin(9600); pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); pinMode(LED_GREEN, OUTPUT); pinMode(LED_YELLOW, OUTPUT); pinMode(LED_RED, OUTPUT); pinMode(BUZZER, OUTPUT); Serial.println("System starting..."); delay(2000); // give the SIM800L time to register on the network } void loop() { int waterLevelCM = readWaterLevel(); Serial.print("Water level: "); Serial.print(waterLevelCM); Serial.println(" cm"); updateIndicators(waterLevelCM); delay(2000); } int readWaterLevel() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); long duration = pulseIn(ECHO_PIN, HIGH); int distanceToWater = duration * 0.034 / 2; // convert echo time to cm return TANK_HEIGHT_CM - distanceToWater; // how high the water has risen } void updateIndicators(int level) { digitalWrite(LED_GREEN, LOW); digitalWrite(LED_YELLOW, LOW); digitalWrite(LED_RED, LOW); digitalWrite(BUZZER, LOW); if (level >= RED_LEVEL_CM) { digitalWrite(LED_RED, HIGH); digitalWrite(BUZZER, HIGH); if (!alertSent) { sendSMS("FLOOD ALERT: Water level is critical!"); alertSent = true; } } else if (level >= YELLOW_LEVEL_CM) { digitalWrite(LED_YELLOW, HIGH); alertSent = false; // reset so a new alert can fire if it rises again } else { digitalWrite(LED_GREEN, HIGH); alertSent = false; } } void sendSMS(String message) { sim800.println("AT+CMGF=1"); // set SMS text mode delay(300); sim800.print("AT+CMGS=\""); sim800.print(alertNumber); sim800.println("\""); delay(300); sim800.print(message); delay(300); sim800.write(26); // Ctrl+Z sends the message delay(1000); Serial.println("SMS alert sent"); }
Troubleshooting
Most issues trace back to the sensor's mounting angle or the GSM module's power supply — here's what to check.
🌊 Readings jump around wildly
Mount the HC-SR04 pointing straight down, not at an angle — tilted sensors bounce sound waves away instead of straight back.
📵 SIM800L won't send SMS
Check the SIM card has an active plan with SMS credit, and that it isn't PIN-locked — remove the PIN using a phone first.
🔌 SIM800L keeps restarting
This almost always means its power supply can't deliver enough current. Add a large capacitor (1000µF) across its power pins to handle transmission spikes.
🚦 LEDs never change color
Double-check YELLOW_LEVEL_CM and RED_LEVEL_CM are set correctly for your tank's actual height.
🔇 Buzzer stays silent
Make sure it's an active buzzer (built-in oscillator) — passive buzzers need a tone signal, not a simple HIGH/LOW.
📨 Multiple texts for one flood
This is expected behavior reset — the code only resends once the level drops back below yellow and rises again, to avoid spamming the same alert.
Fun Upgrades to Try
Frequently Asked Questions
Is it safe for a 9-year-old to build this near water?
The build and testing should happen away from real water, using a small cup to simulate rising levels. Only an adult should mount and test the finished device near an actual water source like a tank or drain.
Why can't the SIM800L share power with the Arduino?
The SIM800L can briefly pull up to 2A while transmitting, which is far more than the Arduino's 5V pin can safely supply — sharing power usually causes both the Arduino and the GSM module to reset.
Does this need an internet connection?
No — the SIM800L sends SMS messages the same way a basic mobile phone does, over the regular cellular network, so it works even where there's no Wi-Fi.
Can I use this for a fish tank or rain barrel instead?
Yes — it works for any container. Just update TANK_HEIGHT_CM, YELLOW_LEVEL_CM and RED_LEVEL_CM in the code to match the container's actual measurements.
What if I don't have a SIM card to spare?
You can skip the SIM800L entirely and keep just the LED and buzzer alerts — the water level monitoring and visual warnings will still work on their own.

Comments
Post a Comment