Robin2:
Great news.But we can't see the corrected version. I reckon you should know by now to post the latest version of your program without having to be asked.
...R
my new code is like this
#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 exhaust;
void setup(){
Serial.begin(9600);
pinMode(exhaustpin, OUTPUT);
pinMode(coolerpin, OUTPUT);
digitalWrite(exhaustpin,HIGH );
digitalWrite(coolerpin,HIGH );
exhaust= 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 interval;
long interval;
if (exhaust== LOW){
if ((roomtemp>=30)&&(digitalRead(coolerpin)==HIGH )){
digitalWrite(exhaustpin,LOW ); // if temperature increses above 30 the exhaust starts to work
interval = millis();
}
}
if (digitalRead(exhaustpin)==LOW){
exhaust= !exhaust;
if ((millis()-interval) >= 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 );
exhaust= !exhaust;
// 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
}
}