#include <DHT.h>
int p=13;
int red=10;
int orange=8;
int green=6;
DHT dht(p, DHT22);
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("DHT22 Example.. ");
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
float temp = dht.readTemperature();
float humd = dht.readHumidity();
if(isnan(temp) || isnan(humd)){
Serial.println("Failed to read DHT Sensor ..");
return;
}
digitalWrite(red, LOW);
digitalWrite(green, LOW);
digitalWrite(orange, LOW);
Serial.print("Humidity : ");
Serial.print(humd);
Serial.print("% Temperature : ");
Serial.print(temp);
Serial.println("°C");
if(temp >40){
digitalWrite(red, HIGH);
}
else if(temp <=30){
digitalWrite(orange, HIGH);
}
else{
digitalWrite(green, HIGH);
}
delay(1000);
}