Help using Relays with greenhouse

Okay I got one last thing to ask : See my fundamental problem right now is to keep my OUTPUT for the condition used at HIGH for 60 sec? I have changed my boolean operators already but here is where I am stumped :

void loop() {

//Start reading from DHT sensor

 unsigned long currentDataTime = millis();
 static unsigned long startDataTime = 0;

 static float h, t, f, hic, hif;
 
 WaterLevel = map(WaterLevel, 0, 1023, 0, 255);
 
 if (startDataTime == 0) {

  startDataTime = currentDataTime;

  h = dht.readHumidity();
  t = dht.readTemperature();
  f = dht.readTemperature(true);

  if (isnan(h) || isnan(t) || isnan(f)) {
    Serial.println("Failed to read from DHT sensor!");
    return;
  }
  
  hif = dht.computeHeatIndex(f, h);
  hic = dht.computeHeatIndex(t, h, false);
      
  Serial.print("Humidity: ");
  Serial.print(h);
  Serial.print(" %\t");
  Serial.print("Temperature: ");
  Serial.print(t);
  Serial.print(" *C ");
  Serial.print(f);
  Serial.print(" *F\t");
  Serial.print("Heat index: ");
  Serial.print(hic);
  Serial.print(" *C ");
  Serial.print(hif);
  Serial.println(" *F");

  int WaterLevel = analogRead(WaterLevelPin);
  
//Log data from DHT and water level reading

  String dataString = "";
    for (int analogPin = 0; analogPin < 3; analogPin++) {
      int sensor = analogRead(analogPin);
      dataString += String(sensor);
      if (analogPin < 2) {
        dataString += ",";
      }
       
      File dataFile = SD.open("datalog.txt", FILE_WRITE);
        if (dataFile) {
          dataFile.println(dataString);
          dataFile.close();
          Serial.println(dataString);
        }
        else {
          Serial.println("error opening datalog.txt");
        }
    }
 }
 else if (currentDataTime - startDataTime > 5000) {
  startDataTime = 0;
 }
 
//Display readings on LCD

 lcd.setBacklight(1);
  
 lcd.home();
 lcd.print("Temperature");
 lcd.setCursor(0,1);
 lcd.print(t);
 lcd.print("*C");
 lcd.setCursor(0,2);
 lcd.print("Humidity");
 lcd.setCursor(0,3);
 lcd.print(h);
 lcd.print("*%");
 
//Sensory responses
    
 unsigned long currentCycleTime = millis();
 static unsigned long startCycleTime = 0;
 
 if (startCycleTime == 0) {

  if (t>=28 && h>=85) {
    digitalWrite(AuxFanPin, HIGH);
  }
  else if (t>=28 && h<=85) {
    digitalWrite(MainFanPin, HIGH);
    digitalWrite(HumidifierPin, HIGH);
  }
  else if (t<=28 && t>=19 && h>=85) {
    
  }
  else if (t<=28 && t>=19 && h<=85) {
    digitalWrite(AuxFanPin, HIGH);
    digitalWrite(HumidifierPin, HIGH);
  }
  else if (t<=19 && h<=85) {
    digitalWrite(HeaterPin, HIGH);
    digitalWrite(HumidifierPin, HIGH);
    digitalWrite(MainFanPin, HIGH);
  }
  else if (t<=19 && h>=85) {
    digitalWrite(HeaterPin, HIGH);
    digitalWrite(AuxFanPin, HIGH);
  }
  startCycleTime = currentCycleTime;
 }
 else if (currentCycleTime - startCycleTime > 60000) {
  startCycleTime = 0;
 }

//Light cycle

 unsigned long currentLightTime = millis();
 static unsigned long startLightTime = 0;

 if (startLightTime == 0) {
  digitalWrite(LightsPin, HIGH);
 }
 else if (currentLightTime == 10000) {
  digitalWrite(LightsPin, LOW);
 }
 else if (currentLightTime == 20000) {
  startLightTime = 0;
 }
}

I am still new at this and I am acquiring a lot of knowledge thanks to you all!!

Thank you for the help BTW, much appreciated :slight_smile: