const int relayPin = 15;
const int relayPin1 = 4;
const int dhtPin = 2 ;
#include "DHT.h"
DHT dht(dhtPin, DHT22);
void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
pinMode(relayPin1, OUTPUT);
dht.begin();
}
void loop() {
float t = dht.readTemperature();
if (isnan(t)) {
Serial.println("Failed to read temperature from DHT sensor!");
return;
}
Serial.print("Temperature: ");
Serial.println(t);
if(t > 26){
digitalWrite(relayPin, HIGH);
digitalWrite(relayPin1, LOW);
}else{
digitalWrite(relayPin, LOW);
digitalWrite(relayPin1, HIGH);
}
delay(2000);
}