PIR Sensor for Automatic Sink Faucet

Project Overview

This project converts a standard sink faucet into a touchless automatic faucet. When you place your hands under the faucet, a PIR sensor detects motion and opens a solenoid valve, allowing water to flow. When you remove your hands, the water stops after a short delay.

Difficulty: Intermediate
Estimated time: 3-4 hours
Estimated cost: $40-60

How It Works

A PIR sensor is positioned under the faucet spout, facing down toward the sink. When hands enter the detection zone, the sensor triggers an Arduino which activates a solenoid valve connected to the water line. The valve opens, water flows, and when hands are removed, the valve closes after a brief delay.

Materials Needed

  • Arduino Uno or ESP32 (1)
  • HC-SR501 PIR sensor (1)
  • 12V solenoid valve (normally closed, 1/2″ or 3/4″ NPT)
  • 12V power supply (2A minimum)
  • MOSFET or relay module
  • Plumbing fittings to adapt to your faucet supply
  • Waterproof enclosure for electronics
  • Jumper wires
  • Teflon tape

Circuit Diagram

Connection Table

VCC

5V

GND

GND

OUT

Digital Pin 2

IN

Digital Pin 3

Positive

Relay COM (power supply +)

Negative

Relay NO (to power supply -)

Plumbing Installation

  1. Turn off water supply under the sink
  2. Locate the cold water supply line to your faucet
  3. Install solenoid valve in-line using Teflon tape on all threaded connections
  4. Mount solenoid valve securely under the sink
  5. Turn water on briefly to check for leaks before connecting electronics

Arduino Code

// Automatic Faucet with PIR Sensor
const int pirPin = 2;
const int valvePin = 3;

unsigned long lastTriggerTime = 0;
const unsigned long waterDuration = 3000;
const unsigned long minInterval = 1000;

bool waterOn = false;
bool motionDetected = false;

void setup() {
  Serial.begin(9600);
  pinMode(pirPin, INPUT);
  pinMode(valvePin, OUTPUT);
  digitalWrite(valvePin, LOW);
  
  delay(60000);
}

void turnWaterOn() {
  digitalWrite(valvePin, HIGH);
  waterOn = true;
}

void turnWaterOff() {
  digitalWrite(valvePin, LOW);
  waterOn = false;
}

void loop() {
  bool motion = digitalRead(pirPin) == HIGH;
  
  if (motion && !motionDetected) {
    motionDetected = true;
    lastTriggerTime = millis();
    if (!waterOn) turnWaterOn();
  }
  
  if (!motion && motionDetected) {
    motionDetected = false;
    lastTriggerTime = millis();
  }
  
  if (waterOn && !motionDetected && (millis() - lastTriggerTime > waterDuration)) {
    turnWaterOff();
  }
  
  if (waterOn && (millis() - lastTriggerTime > 30000)) {
    turnWaterOff();
  }
  
  delay(100);
}

Installation Steps

  1. Install solenoid valve in water supply line
  2. Test for leaks before connecting electronics
  3. Assemble electronics in waterproof enclosure
  4. Mount PIR sensor under faucet spout facing downward
  5. Connect solenoid to relay and power supply
  6. Upload code and test with hand motion
  7. Adjust PIR sensitivity to detect only hands

Project Extensions

  • Add temperature sensor for water temperature display
  • Add flow sensor to monitor water usage
  • Add voice control via Alexa or Google Assistant
  • Add battery backup for operation during power outages
  • Add second solenoid for automatic soap dispenser

Conclusion

This touchless faucet project adds convenience and improves hygiene in your kitchen or bathroom. With proper installation, it provides years of reliable hands-free operation.

Leave a Reply

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

Component Pin Arduino Pin
PIR Sensor PIR Sensor PIR Sensor Relay Module Solenoid Valve Solenoid Valve