#include <DHT.h>;
//Constants
#define DHTPIN 5 // what pin we're connected to
#define DHTTYPE DHT22 // DHT 22 (AM2302)
DHT dht(DHTPIN, DHTTYPE); //// Initialize DHT sensor for normal 16mhz Arduino
#define RELAY 4
//Variables
int chk;
float hum; //Stores humidity value
float temp; //Stores temperature value
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(RELAY, OUTPUT);
dht.begin();
}
void loop() {
// put your main code here, to run repeatedly:
delay(200);
//Read data and store it to variables hum and temp
hum = dht.readHumidity();
temp= dht.readTemperature();
//Print temp and humidity values to serial monitor
Serial.print("Humidity: ");
Serial.print(hum);
Serial.print(" %, Temp: ");
Serial.print(temp);
Serial.println(" Celsius");
delay(200); //Delay 2 sec.
REGELTEMP();
}
void REGELTEMP(){
if (temp < 6){
digitalWrite(RELAY,HIGH);
}else{
digitalWrite(RELAY,LOW);
}
}