Translate

Arduino Automatic Bathroom Using PIR Sensor

 1. Introduction

Automatic control systems are widely used in modern homes to improve convenience and save electricity. Bathrooms often require both lighting and ventilation, but people sometimes forget to switch them OFF after use.

In this project, we build an Arduino Automatic Bathroom Light and Exhaust Fan system using a PIR motion sensor and relay module. The PIR sensor detects human movement when a person enters the bathroom.

When motion is detected, the Arduino automatically turns ON the bathroom light and exhaust fan using relay modules. When there is no motion for some time, the Arduino turns them OFF automatically.

This project is useful for smart home automation and energy-efficient lighting and ventilation systems.


2. Components

  • Arduino Uno

  • PIR Motion Sensor (HC-SR501)

  • 2 Channel Relay Module

  • AC Bathroom Light

  • Exhaust Fan

  • Jumper Wires

  • Breadboard

  • USB Cable for Arduino


3. Circuit and Connections


Pinout Diagram of Arduino Uno R3Pinout Diagram of PIR Motion Sensor
Pinout Diagram Dual Channel Relay Module


PIR Motion Sensor

  • VCC → Arduino 5V

  • GND → Arduino GND

  • OUT → Arduino Pin 2

Relay Module

Relay Channel 1 (Light)

  • IN1 → Arduino Pin 8

Relay Channel 2 (Fan)

  • IN2 → Arduino Pin 9

Relay Power

  • VCC → Arduino 5V

  • GND → Arduino GND

AC Connections

Bathroom Light

  • Live wire → Relay COM1

  • Relay NO1 → Light Live terminal

  • Neutral → Light Neutral

Exhaust Fan

  • Live wire → Relay COM2

  • Relay NO2 → Fan Live terminal

  • Neutral → Fan Neutral


4. Circuit Working

The PIR motion sensor continuously monitors the surrounding area for infrared radiation changes caused by human movement.

When a person enters the bathroom, the PIR sensor detects motion and sends a HIGH signal to the Arduino.

The Arduino activates both relays, turning ON the bathroom light and exhaust fan.

When no motion is detected, the Arduino deactivates the relays, turning OFF both devices automatically.


5. Code

int pir = 2;
int lightRelay = 8;
int fanRelay = 9;

void setup()
{
pinMode(pir, INPUT);
pinMode(lightRelay, OUTPUT);
pinMode(fanRelay, OUTPUT);
}

void loop()
{
int motion = digitalRead(pir);

if(motion == HIGH)
{
digitalWrite(lightRelay, HIGH);
digitalWrite(fanRelay, HIGH);
}
else
{
digitalWrite(lightRelay, LOW);
digitalWrite(fanRelay, LOW);
}
}

6. Code Working

The PIR sensor pin and relay pins are first defined in the program.

Inside the setup() function, the PIR sensor pin is configured as an input while the relay pins are configured as outputs.

Inside the loop() function, the Arduino continuously reads the PIR sensor output. If motion is detected, the Arduino activates both relays and turns ON the light and exhaust fan. If no motion is detected, both devices are turned OFF.


7. Tips

  • Allow the PIR sensor 30–60 seconds to stabilize after power ON.

  • Adjust the sensitivity and delay knobs on the sensor.

  • Use a relay module with optocoupler for safe AC switching.

  • Ensure proper insulation for AC wiring.


8. Uses

  • Automatic bathroom lighting

  • Smart home automation

  • Energy saving systems

  • Automatic ventilation systems

  • Public restroom lighting control


9. Conclusion

In this project, we built an Arduino Automatic Bathroom Light and Exhaust Fan system using a PIR motion sensor and relay module. The system automatically turns ON the light and fan when motion is detected and turns them OFF when the bathroom becomes empty.

This project demonstrates a simple way to create smart home automation systems that improve convenience and save energy.

തുടക്കക്കാർക്കായി ഇലക്ട്രോണിക്സ് ലളിതമായി പഠിക്കാം.

Empowering students in Kerala with hands-on technical skills.