Humidity Sensor-Controlled Bathroom Exhaust Fan

Accumulation of moisture in a closed up space like a bathroom can lead to the appearance of mould, which can cause health issues.

Jan 31, 2019

28701 views

26 respects

Components and supplies

1

DHT11 Temperature & Humidity Sensor (4 pins)

1

12v 1A power supply

1

12V 200mm DIA computer casing fan

1

MOSFET board

1

Arduino Nano R3

1

Jumper wires (generic)

Tools and machines

1

Hot glue gun (generic)

Project description

Code

Arduino Sketch

arduino

Arduino Sketch

arduino

Downloadable files

Wiring Schematic

Wiring Schematic

Image

Comments

Only logged in users can leave comments

Image
Image

ahhzen

2 years ago

i came across this post when i looking for a solution for my humidity sensor controlled exhaust fan. Basically i have a DHT11 hook up to arduino nano and a AC relay which will kick ON when humidity reach a certain threshold (which is static programmed). Under ideal situation it works - when it reaches the threshold humidity, then the fan kicked on and sensor/logic will check if the humidity stay above the threshold, if it fell below then the fan will stay on for last 5 mins until OFF, otherwise it keeps on refreshing the 5 mins ON until humidity falls. But the things is, humidity in bathroom fluctuates, causing the fan to not turn on at all (normal condition too dry) or it never switch off (normal condition too humid). any idea what sort of logic we can implement here?

Image
Image

LIMPINGLIM

2 years ago

I suppose you will need to monitor the humidity fluctuation in your bathroom before setting your thresholds for what to happen when? I have used a smart temperature/humidity sensor to keep track and see the trend before implementing this. good luck

Image
Image

Anonymous user

2 years ago

Would i be able to use a DHT 22 of a more accurate (well, wider sensor collection) for this project, just but editing the range in the code

Image
Image

Anonymous user

2 years ago

why there is an LDR in the image

Image
Image

LIMPINGLIM

2 years ago

J'ai mis a jour le code & retire les lignes contenant le LDR.

Image
Image

LIMPINGLIM

2 years ago

Wanted the fan to stop when the light in the bathroom is ON, but i found it a bit redundant since I could pre-set fan speeds for various humidity levels and even stop it if the humidity reaches an acceptable low level.

Image
Image

LIMPINGLIM

2 years ago

c'est dommage que le code ne marche pa pour toi, mais le code est exactement ce qui est charge sur mon Nano. Peu etre l'erreur est dans le circuit shematique.

Image
Image

LIMPINGLIM

2 years ago

I suggest you can watch the youtube video on DHT11. It will guide you step-by-step to set up the sensor.

Image
Image

Anonymous user

2 years ago

je n'ai pas de capteur de luminosité LDR! comme sur le fritzing!

Image
Image

Anonymous user

2 years ago

yes except that on the diagram it is A2, A3 whereas in Sketch it is D2, D3 and it works better

Image
Image

Anonymous user

2 years ago

super merci je vais voir! avec DHT22 Digital Temperature and Humidity Sensor AM2302 ca marche pareil? rien a modifier?

Image
Image

Anonymous user

2 years ago

tu peut faire un code sans LDR? ca me rendras bien service moi j'ai fait ca , c'est bon? `#include <SimpleDHT.h> //Declaring digital pin no 2 as the dht11 data pin int pinDHT11 = 2; int DHTpower = 3; int Fan = 13; SimpleDHT11 dht11; void setup() { pinMode(Fan, OUTPUT); pinMode(DHTpower, OUTPUT); digitalWrite(DHTpower, LOW); digitalWrite(Fan, LOW); Serial.begin(9600); } void loop() { delay(1000); RHcheck(); //check Humidity Level delay(15000); //wait 15sec } void RHcheck() { //Check Humidity Level Function digitalWrite(DHTpower, HIGH); //On Humidity Sensor delay(5000); Serial.println("============ Check Humidity ==============="); delay(1000); Serial.println("DHT11 readings..."); byte temperature = 0; byte humidity = 0; int err = SimpleDHTErrSuccess; //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { Serial.print("No reading , err="); Serial.println(err);delay(1000); return; } Serial.print("Readings: "); Serial.print((int)temperature); Serial.print(" C, "); Serial.print((int)humidity); Serial.println(" %"); delay(500); if((int)humidity < 50){ digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan OFF"); delay(500); digitalWrite(Fan, LOW); }else{ if ((int)humidity > 58){ Serial.println("Humidity > 58%"); digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan ON @ full speed"); delay(500); digitalWrite(Fan, HIGH); }else{ Serial.println("50% < Humidity < 58%"); digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan ON @ low speed"); delay(500); analogWrite(Fan, 200); } } }`

Image
Image

Anonymous user

2 years ago

Hello which library for DHT11?

Image
Image

Anonymous user

2 years ago

bien ,mais le code? le tuto est très bien , mais du coup inutilisable pour les novices comme moi! dommage c'est pas cool

Image
Image

Anonymous user

2 years ago

Hi there, thanks for sharing. I tried it out and was getting no reading from the DHT11 humidity sensor. In your diagram you have the humidity sensor connected to A2 and A3 (analog pins), was not getting the sensor reading, so I changed them to D2, D3 (digital). After these changes the DHT11 produces the temperature and humidity measurements correctly. In your code you have 3 states, full speed, low speed and off. In my testing high and low speed are not distinguishable. So I simplified the code to two states: on if humidity > 60% and off otherwise. Another thing I did differently, is I used two fans in tandem to increase the air flow.

Image
Image

LIMPINGLIM

2 years ago

good job with adjusting to suit your requirements.

Image
Image

kitkat2373

3 years ago

Would i be able to use a DHT 22 of a more accurate (well, wider sensor collection) for this project, just but editing the range in the code

Image
Image

Anonymous user

3 years ago

Hi can I get guidance about humidity controlled fan. There is a project here with deals with temperature controlled fan. I need to change temperature to humidity and simply apply these changes

Image
Image

menzellu

4 years ago

Hi there, thanks for sharing. I tried it out and was getting no reading from the DHT11 humidity sensor. In your diagram you have the humidity sensor connected to A2 and A3 (analog pins), was not getting the sensor reading, so I changed them to D2, D3 (digital). After these changes the DHT11 produces the temperature and humidity measurements correctly. In your code you have 3 states, full speed, low speed and off. In my testing high and low speed are not distinguishable. So I simplified the code to two states: on if humidity > 60% and off otherwise. Another thing I did differently, is I used two fans in tandem to increase the air flow.

Image
Image

LIMPINGLIM

2 years ago

good job with adjusting to suit your requirements.

Image
Image

siva25143

6 years ago

why there is an LDR in the image

Image
Image

LIMPINGLIM

2 years ago

Wanted the fan to stop when the light in the bathroom is ON, but i found it a bit redundant since I could pre-set fan speeds for various humidity levels and even stop it if the humidity reaches an acceptable low level.

Image
Image

niermou

2 years ago

yes except that on the diagram it is A2, A3 whereas in Sketch it is D2, D3 and it works better

Image
Image

niermou

2 years ago

super merci je vais voir! avec DHT22 Digital Temperature and Humidity Sensor AM2302 ca marche pareil? rien a modifier?

Image
Image

niermou

2 years ago

tu peut faire un code sans LDR? ca me rendras bien service moi j'ai fait ca , c'est bon? `#include <SimpleDHT.h> //Declaring digital pin no 2 as the dht11 data pin int pinDHT11 = 2; int DHTpower = 3; int Fan = 13; SimpleDHT11 dht11; void setup() { pinMode(Fan, OUTPUT); pinMode(DHTpower, OUTPUT); digitalWrite(DHTpower, LOW); digitalWrite(Fan, LOW); Serial.begin(9600); } void loop() { delay(1000); RHcheck(); //check Humidity Level delay(15000); //wait 15sec } void RHcheck() { //Check Humidity Level Function digitalWrite(DHTpower, HIGH); //On Humidity Sensor delay(5000); Serial.println("============ Check Humidity ==============="); delay(1000); Serial.println("DHT11 readings..."); byte temperature = 0; byte humidity = 0; int err = SimpleDHTErrSuccess; //This bit will tell our Arduino what to do if there is some sort of an error at getting readings from our sensor if ((err = dht11.read(pinDHT11, &temperature, &humidity, NULL)) != SimpleDHTErrSuccess) { Serial.print("No reading , err="); Serial.println(err);delay(1000); return; } Serial.print("Readings: "); Serial.print((int)temperature); Serial.print(" C, "); Serial.print((int)humidity); Serial.println(" %"); delay(500); if((int)humidity < 50){ digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan OFF"); delay(500); digitalWrite(Fan, LOW); }else{ if ((int)humidity > 58){ Serial.println("Humidity > 58%"); digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan ON @ full speed"); delay(500); digitalWrite(Fan, HIGH); }else{ Serial.println("50% < Humidity < 58%"); digitalWrite(DHTpower, LOW); delay(500); Serial.println("Fan ON @ low speed"); delay(500); analogWrite(Fan, 200); } } }`

Image
Image

niermou

2 years ago

je n'ai pas de capteur de luminosité LDR! comme sur le fritzing!

Image
Image

niermou

2 years ago

Hello which library for DHT11?

Image
Image

Anonymous user

2 years ago

bien ,mais le code? le tuto est très bien , mais du coup inutilisable pour les novices comme moi! dommage c'est pas cool

Image
Image

LIMPINGLIM

2 years ago

c'est dommage que le code ne marche pa pour toi, mais le code est exactement ce qui est charge sur mon Nano. Peu etre l'erreur est dans le circuit shematique.

Image
Image

LIMPINGLIM

2 years ago

J'ai mis a jour le code & retire les lignes contenant le LDR.

Image
Image

LIMPINGLIM

2 years ago

I suggest you can watch the youtube video on DHT11. It will guide you step-by-step to set up the sensor.