Welcome to Hackster!
Hackster is a community dedicated to learning hardware, from beginner to pro. Join us, it's free!
Ramona Fuchs
Published © GPL3+

Humidity Guardian

Humidity Guardian: An automated system that monitors and controls indoor humidity, activating fans when levels exceed a set threshold.

BeginnerWork in progress24 hours261
Humidity Guardian

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
DHT22 Temperature Sensor
DHT22 Temperature Sensor
×1
Buzzer, Piezo
Buzzer, Piezo
×1
Alphanumeric LCD, 16 x 2
Alphanumeric LCD, 16 x 2
×1
Grove - Relay
Seeed Studio Grove - Relay
×1

Story

Read more

Code

Testcode (Fan is controlled by temperature and not humidity)

C/C++
I will change that later.
#include <DHT22.h>        //DHT22 libary

#define DHT22_PIN 11      // Pin for DHT22
#define BUZZER_PIN 13     // Pin for Buzzer
#define RELAIS_PIN 12     // Pin for relay

DHT22 dht22(DHT22_PIN);

bool relayTurnedOn;

void setup() {
  Serial.begin(9600);
  Serial.println("Arduino is working!");
  pinMode(13, OUTPUT);
  pinMode(12, OUTPUT);
  digitalWrite(12, LOW);
}

void loop() {

       // Wait 2 seconds
      delay(2000);
      
      float humidity = dht22.getHumidity();
      float temperature = dht22.getTemperature();
      

    Serial.print("Temperature: ");
    Serial.print(temperature);
    Serial.print(" °C, ");
    Serial.print("Humidity: ");
    Serial.print(humidity);
    Serial.println(" %");


    // Buzzer
    if (humidity >= 60){
      tone(13, 1000, 200);  
    } else if(humidity < 50){
      noTone(13);
    }
    
        // Controll the relay based on temperature
    if (temperature >= 15 && !relayTurnedOn) {
      digitalWrite(12, LOW);  //turn relay on
       relayTurnedOn = true;
      Serial.println("Relay On");
    } else if (temperature <=5 && relayTurnedOn) {
      digitalWrite(12, HIGH);  // turn relay off
       relayTurnedOn= false;
      Serial.println("Relay Off");
    }
   
    delay(1000);
  } 

Credits

Ramona Fuchs
1 project • 0 followers
Contact

Comments

Please log in or sign up to comment.