#include <DHT.h>
#define DHTPIN 2 // DHT11 sensor data pin
#define LED 5 // Relay control pin
#define DHTTYPE DHT22 // DHT11 sensor type
DHT dht(DHTPIN, DHTTYPE);
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
dht.begin();
}
void loop() {
float temperature = dht.readTemperature(); // Read temperature from DHT11
Serial.print("Temperature: ");
Serial.print(temperature);
Serial.println(" *C");
// Check temperature and control relay
if (temperature < 40.0) {
digitalWrite(LED, LOW); // Turn off relay
Serial.println("EXHAUST FAN OFF");
} else if (temperature > 40.0) {
digitalWrite(LED, HIGH); // Turn on relay
Serial.println("EXHAUST FAN ON");
//delay(600000);
delay(10000);
}
delay(1000);
}