Detects a water leak and shuts the supply valve automatically.
Built and tested by Anju.A · Industrial Robotics Institute
Arduino IDE, Blynk (optional)
A leak protection system for homes and offices. A water sensor on the floor or near a pipe detects leaking water; the ESP32 immediately closes a 12V solenoid valve through a relay to cut the supply, and sounds a buzzer, preventing damage and water waste.
| Component | Qty |
|---|---|
| ESP32 Dev Board | 1 |
| Water Leakage Sensor (YL-69 / probe) | 1 |
| 12V Solenoid Water Valve | 1 |
| Relay Module | 1 |
| Buzzer | 1 |
| Jumper Wires / Breadboard | As needed |
| 12V Power Supply (valve) | 1 |
| 5V Power Supply (ESP32) | 1 |
| From | Connect to |
|---|---|
| Leak sensor VCC | 3.3V |
| Leak sensor GND | GND |
| Leak sensor DO | GPIO 34 |
| Relay VCC | 5V |
| Relay GND | GND |
| Relay IN | GPIO 26 |
| Solenoid valve | 12V supply through relay COM / NO |
| Buzzer + | GPIO 25 |
| Buzzer − | GND |
Complete, tested Arduino C++ code for this project. Copy it into Arduino IDE and upload it to the ESP32.
#define sensorPin 34
#define relayPin 26
#define buzzerPin 25
void setup() {
pinMode(sensorPin, INPUT);
pinMode(relayPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
Serial.begin(115200);
}
void loop() {
int sensorValue = digitalRead(sensorPin);
if (sensorValue == HIGH) { // water detected
Serial.println("Leakage Detected!");
digitalWrite(relayPin, LOW); // valve OFF (supply cut)
digitalWrite(buzzerPin, HIGH); // alert ON
delay(2000);
} else {
digitalWrite(relayPin, HIGH); // valve ON
digitalWrite(buzzerPin, LOW); // alert OFF
}
delay(500);
}A leak protection system for homes and offices. A water sensor on the floor or near a pipe detects leaking water; the ESP32 immediately closes a 12V solenoid valve through a relay to cut the supply, and sounds a buzzer, preventing damage and water waste.
You need: ESP32 Dev Board (1), Water Leakage Sensor (YL-69 / probe) (1), 12V Solenoid Water Valve (1), Relay Module (1), Buzzer (1), Jumper Wires / Breadboard, 12V Power Supply (valve) (1), 5V Power Supply (ESP32) (1). Software: Arduino IDE, Blynk (optional).
Yes. It is rated beginner and takes about 1–2 hours to build, using the ESP32. The guide on this page explains every connection and step.
The complete, tested Arduino C++ code is free on this page. Copy it into Arduino IDE and upload it to the board.
Yes. IRI sells a kit with the parts for this project (PRJ-172). Message IRI on WhatsApp at +91 86060 82634 for the kit price and delivery details.