-
Water Leak Detection System using Arduino
-
1. Introduction
A water leak sensor is a simple and inexpensive way to detect the presence of water. It’s commonly used in home automation, basements, bathrooms, or industrial systems to prevent flooding or equipment damage.
The module detects water through exposed traces that act as conductors — when water touches them, the resistance decreases, and the sensor outputs a digital HIGH or LOW signal to Arduino.
2. Components Required
-
1 × Arduino Uno (or any compatible board)
-
1 × Water leak sensor module (e.g., YL-38 or FC-37)
-
1 × Buzzer or LED for indication
-
Jumper wires
-
USB cable for programming
3. Wiring Diagram
Sensor Pin Arduino Pin Description VCC 5 V Power supply GND GND Ground D0 (Signal) D2 Digital output (If your sensor has an analog pin “A0”, you can connect it to Arduino A0 for analog readings.)
Optionally:
-
Connect an LED to pin 13 to indicate water leak.
-
Connect a buzzer to pin 8 for alarm sound.
4. Arduino Code (Digital Output)
// Water Leak Sensor Example Code const int leakPin = 2; // digital input pin for water sensor const int ledPin = 13; // built-in LED for indication const int buzzerPin = 8; // optional buzzer pin void setup() { pinMode(leakPin, INPUT); pinMode(ledPin, OUTPUT); pinMode(buzzerPin, OUTPUT); Serial.begin(9600); Serial.println("Water Leak Detector Initialized"); } void loop() { int sensorState = digitalRead(leakPin); if (sensorState == HIGH) { // leak detected digitalWrite(ledPin, HIGH); digitalWrite(buzzerPin, HIGH); Serial.println("⚠️ Leak detected!"); } else { // no leak digitalWrite(ledPin, LOW); digitalWrite(buzzerPin, LOW); Serial.println("No leak detected."); } delay(500); }
5. How It Works
-
The sensor has exposed copper traces that form an open circuit when dry.
-
When water touches them, it closes the circuit, lowering resistance and allowing current to flow.
-
The signal pin sends HIGH (or sometimes LOW, depending on the module) to the Arduino.
-
Arduino then triggers an LED or buzzer as an alert.
6. Optional: Analog Reading Example
If you want to measure how much water is present, use the analog output instead of the digital one:
const int waterSensorPin = A0; void setup() { Serial.begin(9600); } void loop() { int sensorValue = analogRead(waterSensorPin); Serial.print("Water Level Value: "); Serial.println(sensorValue); delay(500); }Typical range:
-
0–300 → dry
-
300–700 → damp
-
700–1023 → wet / leak
You can use these values to trigger different alerts.
7. Practical Applications
-
Detecting pipe leaks or tank overflow
-
Basement water detection systems
-
Smart home alarms (using buzzer or Wi-Fi modules)
-
Industrial safety monitoring (around pumps or coolers)
8. References and Tutorials
-
-
