• Skip to main content
  • Skip to primary sidebar

Homemade Circuit Projects

Need circuit help? Post them in the comments! I've answered over 50,000!

Blog | Categories | About | Contact | Calculators-online
You are here: Home / Arduino Projects / Smart Bathroom Exhaust Fan Controller Circuit with Sensors
warning message: electricity is dangerous, proceed with caution

Smart Bathroom Exhaust Fan Controller Circuit with Sensors

Last Updated on July 1, 2025 by Swagatam 13 Comments

So here we are now making one automatic smart exhaust fan controller system using Arduino UNO which will work for three bathrooms that are all connected to a single ventilation pipe and one common exhaust fan.

Table of Contents
  • The Concept
  • Basic Working Concept
  • Sensor and Relay Wiring Explanation
  • Elaborate Pin Connection Details
  • Full Arduino Code for Bathroom Fan Control
  • Wiring and Pinout Details of PIR Human Presence Detector Module
  • Wiring and Pinout Details of MQ135 Air Quality (VOC) Sensor
  • Wiring and Pinout Details of DHT22 Humidity Sensor Module
  • Conclusions

This whole project is going to be based on PIR sensors for human detection, VOC sensors for odor detection and humidity sensors for controlling steam and moisture after bath.

The fan will turn ON whenever any of these parameters go active from any bathroom and also it will keep running for some more minutes even after those parameters go off, so that all bad air and moisture get fully removed from the bathrooms.

This project was requested to me by one of the avid readers of this blog Mr. Manoj Dikshit, as given below:

The Concept

I need a circuit for our three bathrooms ventilation system.

Single Ventilation fan.

Three Bathrooms connected with a common pipe.

System may start working with (1st) human presence (maximum Diagonal 10 Feet) to (2nd) control odor (VOC) and (3rd) relative humidity of all three bathrooms.

Fan off time delay may be required to control Humidity after use.

Will outdoor humidity sensor be required?

Bathrooms may be utilized in parallel also.

Power Supply: SEB raw power and / or UPS.

Basic Working Concept

Now first of all, we have to understand that all three bathrooms are going to use only one exhaust fan, so we need to make the control system in such a way that even if any one bathroom detects human presence or bad smell or high humidity, the fan should turn ON instantly.

For that reason we will use three sets of sensors, each set having one PIR motion sensor, one VOC sensor like MQ135 and one humidity sensor like DHT22. So total we will have 9 sensor modules connected to Arduino UNO.

We will take signal output from all these 9 sensors and combine them in the Arduino logic using OR type conditions, so whenever any one sensor gives HIGH signal or crosses threshold then Arduino will activate a relay module which will switch ON the exhaust fan.

But that is not enough because we also need to make sure the fan does not turn OFF suddenly. So we will program a timer delay also which will keep the fan ON for around 5 minutes after last sensor trigger was received.

Sensor and Relay Wiring Explanation

So now let us make the connection details in simple way. We take one Arduino UNO board. Then we put three PIR motion sensors (HC-SR501 type) and connect their OUT pins to Arduino pins D2, D3, D4. These PIRs will detect human presence from each bathroom.

Then we use three MQ135 sensors which are gas/odor detectors. Their analog OUT pins will go to Arduino pins A0, A1, and A2. These will sense VOC levels from three bathrooms.

Then we take three DHT22 humidity sensors. They have three pins – VCC, GND, and DATA. We connect all their VCC to Arduino 5V, all GNDs to Arduino GND and their DATA pins to D5, D6, and D7. These will sense steam/humidity after bath.

Then we take a 5V relay module. This module must be one-channel type which has IN, VCC, and GND pins. The VCC and GND we connect to Arduino 5V and GND. The IN pin we connect to D8.

The relay COM and NO terminals will go in series with the AC live wire of the exhaust fan. So when Arduino sends HIGH to D8, relay turns ON and completes AC line to fan.

Power to Arduino can come from a 12V adapter or battery. The adapter can be from SEB mains power or from UPS. The relay and sensors will take power from Arduino itself.

Elaborate Pin Connection Details

Now we explain the pin connections fully so that it becomes very clear.

So we start with the PIR sensors. The first PIR sensor which will be fixed inside bathroom 1, its OUT pin we connect to digital pin D2 of Arduino UNO.

The second PIR sensor from bathroom 2, its OUT pin we connect to D3.

And the third PIR sensor from bathroom 3, we connect its OUT pin to D4.

All the three PIR sensors have VCC and GND also, so we join all their VCCs together and give it 5V from Arduino and same we do for all GNDs, we join them and connect to Arduino GND.

Now we take the three MQ135 VOC sensors.

These are analog sensors, so we take the analog OUT pin of the first MQ135 from bathroom 1 and connect it to A0 of Arduino.

The second MQ135 from bathroom 2 we connect to A1 and the third one from bathroom 3 we connect to A2.

All three MQ135s also need 5V and GND, so we connect all their VCC pins together to Arduino 5V, and all their GND pins to Arduino GND.

Now we move to humidity sensors.

We take the DHT22 from bathroom 1 and connect its DATA pin to digital pin D5 of Arduino.

The second DHT22 from bathroom 2 we connect to D6 and the third one from bathroom 3 we connect to D7.

Again for power, we connect all three DHT22 VCC pins to Arduino 5V and all GND pins to Arduino GND.

For better result we can use 10K pull-up resistors between each DATA pin and 5V.

Now we take the 5V relay module which will drive the fan. This relay has IN, VCC, and GND. The IN pin we connect to Arduino D8, VCC goes to 5V, and GND to GND.

The relay also has AC side terminals – COM and NO. We cut the live wire of AC which goes to the exhaust fan, and connect one cut end to COM, and the other cut end to NO. The neutral wire of the fan we leave as it is, it goes direct to AC neutral.

Now our full wiring is done, and now Arduino will monitor all 9 sensors and switch ON fan using the relay depending on any sensor activation.

Full Arduino Code for Bathroom Fan Control

Now let us write the full Arduino code for this system. This code will read all 9 sensors and turn ON the fan if any of them detects anything and keep fan ON for 5 minutes after last trigger.

#include <DHT.h>

#define DHTPIN1 5
#define DHTPIN2 6
#define DHTPIN3 7
#define DHTTYPE DHT22

DHT dht1(DHTPIN1, DHTTYPE);
DHT dht2(DHTPIN2, DHTTYPE);
DHT dht3(DHTPIN3, DHTTYPE);

int pir1 = 2;
int pir2 = 3;
int pir3 = 4;
int mq1 = A0;
int mq2 = A1;
int mq3 = A2;
int fanRelay = 8;

unsigned long fanOnTime = 0;
unsigned long delayDuration = 300000; // 5 minutes in milliseconds

void setup() {
  pinMode(pir1, INPUT);
  pinMode(pir2, INPUT);
  pinMode(pir3, INPUT);
  pinMode(fanRelay, OUTPUT);
  digitalWrite(fanRelay, LOW);

  dht1.begin();
  dht2.begin();
  dht3.begin();

  Serial.begin(9600);
}

void loop() {
  bool trigger = false;

  // Read PIRs
  if (digitalRead(pir1) == HIGH || digitalRead(pir2) == HIGH || digitalRead(pir3) == HIGH) {
    trigger = true;
  }

  // Read MQ sensors
  if (analogRead(mq1) > 500 || analogRead(mq2) > 500 || analogRead(mq3) > 500) {
    trigger = true;
  }

  // Read humidity
  if (dht1.readHumidity() > 75 || dht2.readHumidity() > 75 || dht3.readHumidity() > 75) {
    trigger = true;
  }

  if (trigger) {
    fanOnTime = millis();
    digitalWrite(fanRelay, HIGH);
  }

  if (millis() - fanOnTime < delayDuration) {
    digitalWrite(fanRelay, HIGH);
  } else {
    digitalWrite(fanRelay, LOW);
  }

  delay(1000); // Small delay
}

Wiring and Pinout Details of PIR Human Presence Detector Module

In the following PIR module image, please remove the 1N4148 diode and connect the "out" pin directly with the relevant pin of the Arduino as described in the above explanation.

Wiring and Pinout Details of MQ135 Air Quality (VOC) Sensor

Please connect the analogue Output of the MQ135 sensor with the relevant pin of Arduino, as described in the above Arduino connection description.

Wiring and Pinout Details of DHT22 Humidity Sensor Module

Please connect the data "out" pin of the following DHT22 module with the relevant pin of Arduino, as previously described in the above sections.

Conclusions

So this code will keep checking all 3 PIRs, all 3 gas sensors and all 3 humidity sensors. If any one of them detects something, fan will start and timer will reset. If nothing is detected for 5 full minutes, then fan will stop. All 3 bathrooms are monitored together, so any one active will activate the fan.

This is how we can make full working smart automatic bathroom exhaust fan system using Arduino and multiple sensors.

You'll also like:

  • 1.  Ultrasonic Detector Circuit [Extend your Ear’s Sensitivity]
  • 2.  SMS Based Pump Controller with Automatic Dry Run Shut Off
  • 3.  Non Contact AC Phase Detector Circuit [Tested]
  • 4.  Non-Contact Cable Tracer Circuit
  • 5.  Make this EMF Pump Circuit and Go Ghost Hunting
  • 6.  Force Sensing Resistor Circuit Explained

Filed Under: Arduino Projects, Sensors and Detectors Tagged With: Bathroom, Controller, Exhaust, Sensors, Smart

About Swagatam

I am an electronics engineer and doing practical hands-on work from more than 15 years now. Building real circuits, testing them and also making PCB layouts by myself. I really love doing all these things like inventing something new, designing electronics and also helping other people like hobby guys who want to make their own cool circuits at home.

And that is the main reason why I started this website homemade-circuits.com, to share different types of circuit ideas..

If you are having any kind of doubt or question related to circuits then just write down your question in the comment box below, I am like always checking, so I guarantee I will reply you for sure!

Previous Post: « Simple H-Bridge Inverter Circuit using IR2184 ICs
Next Post: SMPS Flyback Boost Converter Calculator »
Subscribe
Notify of
guest
guest
13 Comments
Inline Feedbacks
View all comments

Primary Sidebar

circuit simulator image

Subscribe to get New Circuits in your Email

Categories

  • Arduino Projects (90)
  • Audio and Amplifier Projects (132)
  • Automation Projects (17)
  • Automobile Electronics (101)
  • Battery Charger Circuits (84)
  • Datasheets and Components (105)
  • Electronics Theory (140)
  • Free Energy (39)
  • Games and Sports Projects (11)
  • Grid and 3-Phase (19)
  • Health related Projects (25)
  • Home Electrical Circuits (12)
  • Indicator Circuits (15)
  • Inverter Circuits (89)
  • Lamps and Lights (142)
  • Meters and Testers (71)
  • Mini Projects (46)
  • Motor Controller (65)
  • Oscillator Circuits (28)
  • Pets and Pests (15)
  • Power Supply Circuits (89)
  • Remote Control Circuits (50)
  • Security and Alarm (64)
  • Sensors and Detectors (103)
  • SMPS and Converters (31)
  • Solar Controller Circuits (60)
  • Temperature Controllers (42)
  • Timer and Delay Relay (49)
  • Transmitter Circuits (29)
  • Voltage Control and Protection (38)
  • Water Controller (36)

Other Links

  • Privacy Policy
  • Cookie Policy
  • Disclaimer
  • Copyright
  • Videos
  • Sitemap

People also Search

555 Circuits | 741 Circuits | LM324 Circuits | LM338 Circuits | 4017 Circuits | Ultrasonic Projects | SMPS Projects | Christmas Projects | MOSFETs | Radio Circuits | Laser Circuits | PIR Projects |

Social Profiles

  • Twitter
  • YouTube
  • Instagram
  • Pinterest
  • My Facebook-Page
  • Quora
  • Stack Exchange
  • Linkedin
  • Recent Comments

    • David on Simple Buck Converter Circuits using Transistors
    • Swagatam on Simple Buck Converter Circuits using Transistors
    • Swagatam on Pure Sine Wave Inverter Circuit Using IC 4047
    • Swagatam on Pure Sine Wave Inverter Circuit Using IC 4047
    • Swagatam on Simple Delay Timer Circuits Explained

    © 2025 · Swagatam Innovations