Automatic Bathroom Fan Controller

Introduction: Automatic Bathroom Fan Controller

We have decided to name this device Smart Fella the fart smeller. My 12 year old son in the 6th grade and I have put together this Instructable. Our project is an automatic bathroom exhaust fan control that will sense methane gas and humidity.

No longer will there be complaints about a lingering aroma. No more complaints about wet walls. I will conserve electricity by not running the fan for extended periods and conserve heat in the winter months. Most of all, Mom will never feel the need to bust in and give a verbal reprimand to turn the fan on.

This invention fits the covid-19 don't touch this criteria where scientists have speculated that the disease can be spread through aerosol feces in farts, and we all want the world to be safer and smell better.

Supplies

  • 16 x 2 LCD
  • Temp and humidity sensor DHT22
  • 1 Relay module
  • Arduino UNO
  • breadboard and various wires
  • MQ4 methane gas sensor
  • polarized extension cord
  • bathroom exhaust fan
  • solder,heat shrink tube
  • insulated crimp connectors
  • 9v power supply

Step 1: Getting Started

You will need to assemble the control portion of your device. I have provided a lists of what connections need to be made in order to energize and read the components. If you look at my photos you will see the first that looks like a birds nest of tangled wires and the second laid out a little neater.

Here is the pin out:

MQ4 methane gas sensor

vcc=+

gnd=ground

adout=A0 Arduino

Relay module

vcc=+

gnd=ground

in1=10 Arduino

110v relay common= spliced into plug supplying power to the 9v power supply

110v nc = not used

110v no = spliced into fan power

DHT22 Temp and humidity sensor

vcc=+

gnd=ground

data=13 Arduino

16 x 2 LCD Display

1=ground

2=VCC

3= 2k- 3kῼ resitor to ground. Test with a variable resistor for best display clarity

4=pin D7 Arduino

5=ground

6=pin D6 Arduino

7=not used

8= not used

9=not used

10=not used

11=pin D5 Arduino

12=pin D4 Arduino

13=pin D3 Arduino

14=pin D2 Arduino

15=vcc

16 = ground

Step 2: Start in a Good Space

It has been a long time since the bathroom heater had been used. I never trusted it, and it often smelled like smoke so I disconnected it years ago.

Removing it and installing the fart / smart feller may be the best thing I ever did.

Step 3: CODE

Upload the code into the Arduino. I changed some of the pins in the provided sample codes found on the internet to keep the wiring smooth. I believe the original sample code I read separated the wires going to the Arduino into function groups. I have also entered explanations into the code to make it easier to understand and adjust fan starting values and run times.

//Smart Fella automatic bathroom fan controller

//AKA Fart Smeller

//Written by JED-I James and his dad

#include

int sensorValue;

#include

const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;//pins to be used for the LCD display

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

dht11 DHT; //Note: DHT on behalf of the temperature and humidity sensor

int hum=0;

const int dht11_data = 13; //pin 13 will be the humidity sensor input

#define DHTTYPE DHT11;

int fanPin = 10;

float fanTime=0;

// starting parameters

void setup()

{

lcd.begin(16, 2);

Serial.begin(9600); // sets the serial port to 9600

pinMode(fanPin,OUTPUT); // pin 10 will control relay

// Print a message to the LCD.

lcd.print("Gas: Humidity");

}

void loop()

{sensorValue = analogRead(0); // read gas sensor

fanTime = (fanTime -1); // countdown after alarm level drops to normal

delay (500);

lcd.setCursor (0,1); // starting column second row

DHT.read(dht11_data); // temp/humidity sensor

hum=DHT.humidity; // sets varlible

lcd.print (sensorValue); // print gas value

lcd.setCursor (7,1); // move cursor under humidity

lcd.print (hum); // print humidity

Serial.println (sensorValue,DEC); //troubleshooting monitor

Serial.println (hum);

Serial.println ( fanTime);

{

if(sensorValue>= 70) //fan trigger points

{(fanTime=300);} //positive timer value, countdown does not start until triggers are below set points

if (hum>= 80)

{(fanTime=300);}

if (fanTime >= 9) //fan operational logic

{digitalWrite(fanPin,LOW);} //a low value will energize the 110v relay

if (fanTime <= 8)

{digitalWrite (fanPin,HIGH);} //relay for 110v w/fan pin normally open state

}

}

Step 4: 110 Volt Wiring

This is important. If you are not qualified, authorized, and knowledgeable with electricity I would not attempt it.

This fan will be receiving electricity from 2 sources independently of each other. The fan that was installed had an un-polarized plug. That plug must be removed and discarded. The plugs must be polarized and the outlets wired properly to make sure a short circuit will be avoided.

Identify the common, normally open and normally closed relay contacts. I would suggest marking the relay and both ends of the insulated spade connectors. The insulated spade terminals will allow you to disconnect the device without leaving open conductors in the fan case.

Step 5: Install

I assembled the components on a PVC board with the gas sensor high because methane is lighter than air and the humidty sensor low to provide the most flow past it. The Arduino is also oriented with the USB port facing down to make adjusting the code possible without removing anything.

Step 6: Summary

It Works!

I didn't include a video for some obvious reasons.

The gas sensor manufacturer suggests running the sensor for 24 hours in order to burn off manufacturing oils and the sensor is not calibrated, so I will need to re-calibrate the trigger points for starting the fan after it has run for a few days.

"Can't Touch This" Family Contest

Participated in the
"Can't Touch This" Family Contest

Be the First to Share

    Recommendations

    • Back to School: Student Design Challenge

      Back to School: Student Design Challenge
    • Organization Contest

      Organization Contest
    • Halloween Contest

      Halloween Contest

    Comments