PIR Sensor Based Water Leak Detector

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

VCC

5V

GND

GND

OUT

Digital Pin 2

Positive

Digital Pin 8

Negative

GND

Anode

Digital Pin 13 (via 220Ω)

Cathode

GND

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

  1. Assemble the circuit and test.
  2. Place the sensor near potential leak sources (water heater, washing machine, under sink).
  3. If using a moisture sensor, place it on the floor in the leak-prone area.
  4. Power the system with a battery for long-term operation.
  5. 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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Component Pin Arduino Pin
PIR Sensor PIR Sensor PIR Sensor Buzzer Buzzer LED LED Moisture Sensor (optional)