Project Overview
This project creates a water leak detector that alerts you when someone approaches a leak area. While not a direct leak sensor, it can be placed near water heaters, washing machines, or sump pumps to alert you when you enter the area, reminding you to check for leaks.
Difficulty: Beginner
Estimated time: 1 hour
Estimated cost: $10-15
How It Works
A PIR sensor detects when someone enters the area near potential leak sources (water heater, washing machine, etc.). When motion is detected, a buzzer sounds and an LED lights up as a reminder to check for leaks. A moisture sensor can be added for direct leak detection.
Materials Needed
- Arduino Nano or Uno (1)
- HC-SR501 PIR sensor (1)
- Buzzer (1)
- LED (any color)
- 220Ω resistor
- Jumper wires
- Power supply (5V 1A) or battery pack
- Optional: Soil moisture sensor for direct leak detection
Circuit Diagram
Connection Table
| Component |
Pin |
Arduino Pin |
PIR Sensor |
VCC
5V
PIR Sensor |
GND
GND
PIR Sensor |
OUT
Digital Pin 2
Buzzer |
Positive
Digital Pin 8
Buzzer |
Negative
GND
LED |
Anode
Digital Pin 13 (via 220Ω)
LED |
Cathode
GND
Moisture Sensor (optional) |
AO
Analog Pin A0
表
Arduino Code
// Water Leak Area Reminder with PIR
const int pirPin = 2;
const int buzzerPin = 8;
const int ledPin = 13;
const int moisturePin = A0; // optional
unsigned long lastAlertTime = 0;
const unsigned long alertCooldown = 300000; // 5 minutes between alerts
void setup() {
pinMode(pirPin, INPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(buzzerPin, LOW);
digitalWrite(ledPin, LOW);
delay(60000);
}
void alert() {
digitalWrite(ledPin, HIGH);
tone(buzzerPin, 2000, 500);
delay(500);
tone(buzzerPin, 1500, 500);
delay(500);
digitalWrite(ledPin, LOW);
}
bool isLeaking() {
int moisture = analogRead(moisturePin);
return moisture > 800; // threshold for wet condition
}
void loop() {
bool motion = digitalRead(pirPin) == HIGH;
if (motion && (millis() - lastAlertTime > alertCooldown)) {
lastAlertTime = millis();
#ifdef USE_MOISTURE_SENSOR
if (isLeaking()) {
alert();
Serial.println("Leak detected near water heater!");
} else {
// Still remind to check
digitalWrite(ledPin, HIGH);
delay(2000);
digitalWrite(ledPin, LOW);
Serial.println("Please check for water leaks.");
}
#else
alert();
#endif
}
delay(100);
}
Installation Steps
- Assemble the circuit and test.
- Place the sensor near potential leak sources (water heater, washing machine, under sink).
- If using a moisture sensor, place it on the floor in the leak-prone area.
- Power the system with a battery for long-term operation.
- Test by walking into the area and verifying alert.
Project Extensions
- Add Wi-Fi to send notifications to your phone
- Add a water shutoff valve (servo-controlled)
- Add a real-time clock to log leak events
- Add an LCD to display leak status
Conclusion
This water leak detector reminds you to check for leaks whenever you enter the area, helping catch problems early.