Components and supplies
DHT11 Temperature & Humidity Sensor (4 pins)
12v 1A power supply
12V 200mm DIA computer casing fan
MOSFET board
Arduino Nano R3
Jumper wires (generic)
Tools and machines
Hot glue gun (generic)
Project description
Code
Arduino Sketch
arduino
Arduino Sketch
arduino
Downloadable files
Wiring Schematic
Wiring Schematic
Comments
Only logged in users can leave comments
LIMPINGLIM
a year 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
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
Anonymous user
2 years ago
why there is an LDR in the image
LIMPINGLIM
2 years ago
J'ai mis a jour le code & retire les lignes contenant le LDR.
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.
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.
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.
Anonymous user
2 years ago
je n'ai pas de capteur de luminosité LDR! comme sur le fritzing!
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
Anonymous user
2 years ago
super merci je vais voir! avec DHT22 Digital Temperature and Humidity Sensor AM2302 ca marche pareil? rien a modifier?
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); } } }`
Anonymous user
2 years ago
Hello which library for DHT11?
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
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.
LIMPINGLIM
2 years ago
good job with adjusting to suit your requirements.
kitkat2373
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
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
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.
LIMPINGLIM
2 years ago
good job with adjusting to suit your requirements.
siva25143
6 years ago
why there is an LDR in the 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.
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
niermou
2 years ago
super merci je vais voir! avec DHT22 Digital Temperature and Humidity Sensor AM2302 ca marche pareil? rien a modifier?
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); } } }`
niermou
2 years ago
je n'ai pas de capteur de luminosité LDR! comme sur le fritzing!
niermou
2 years ago
Hello which library for DHT11?
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
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.
LIMPINGLIM
2 years ago
J'ai mis a jour le code & retire les lignes contenant le LDR.
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.
ahhzen
a year 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?