i corrected my sketch but still the millies part is not working.
#include <dht.h>
dht DHT;
#define DHT1_PIN 7 // dht11 connected to pin 7
int exhaustpin = 4; // set pin for exhaust fan relay
int coolerpin = 5; // set pin for cooler relay
boolean exhaustState;
void setup(){
Serial.begin(9600);
pinMode(exhaustpin, OUTPUT);
pinMode(coolerpin, OUTPUT);
digitalWrite(exhaustpin,HIGH );
digitalWrite(coolerpin,HIGH );
exhaustState= LOW;
}
void loop()
{
DHT.read11(DHT1_PIN);
Serial.print(" MY Room Temperature = ");
Serial.println(DHT.temperature);
Serial.print("MY Room Humidity = ");
Serial.println(DHT.humidity);
delay(500);
int roomtemp =DHT.temperature;
static unsigned long startingCount;
if (exhaustState== LOW){
if ((roomtemp>=30)&&(digitalRead(coolerpin)==HIGH )){
digitalWrite(exhaustpin,LOW ); // if temperature increses above 30 the exhaust starts to work
startingCount = millis();
}
}
if (digitalRead(exhaustpin)==LOW){
exhaustState= HIGH ;
if ((millis()- startingCount) >= 600000){
digitalWrite(coolerpin,LOW );
digitalWrite(exhaustpin,HIGH ); // after the starting of exhaust fan it wait for 10 minutes ,then it turn
// on the cooler and turns off the exhaust fan
}
}
if (roomtemp<28){
digitalWrite(coolerpin,HIGH );
digitalWrite(exhaustpin,HIGH );
exhaustState= LOW;
// i am trying here to start cooling the room with my exhaust fan
// then wait 10 minutes ,if it is still not less than 28 degrees turn on the cooler to do the cooling
// and turn off the exhaust fan
}
}