LIMPINGLIM
Published © GPL3+

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.

BeginnerShowcase (no instructions)8,026
Humidity Sensor-Controlled Bathroom Exhaust Fan

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
DHT11 Temperature & Humidity Sensor (4 pins)
DHT11 Temperature & Humidity Sensor (4 pins)
×1
12V 200mm DIA computer casing fan
×1
Adafruit MOSFET board
×1
12v 1A power supply
×1
Jumper wires (generic)
Jumper wires (generic)
×1

Hand tools and fabrication machines

Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Schematics

Wiring Schematic

Code

Arduino Sketch

Arduino
#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, 150);
    }
  }
 }

Credits

LIMPINGLIM

LIMPINGLIM

2 projects • 20 followers

Comments