Hydroponic Controller w/ LiLon NodeMCU (ESP 8266)

The only thing I would change in the code is how you read the sensors. I have a project here that reads a DHT11 and in each virtual out checks if the values are null. Probably a better way to do it is read the sensor at the top of the loop and set a global variable which you can then use in the CAYENNE_OUT functions. This reduces the amount of reads which reduces the amount of time waiting for a valid result.

Declare t, h, and hif at the top of the sketch as global variables then try the code below.

void loop()
{
  //Check if read failed and try until success
  do {
    //Read humidity (percent)
    h = dht.readHumidity();
    //Read temperature as Fahrenheit
    t = dht.readTemperature(true);
    //Calculate Heat Index as Fahrenheit
    hif = dht.computeHeatIndex(t, h);
	//Delay to reset WDT
	delay(250);
  } while  (isnan(t) || isnan(h));
  
  Cayenne.run(); 
}


CAYENNE_OUT(V0)
{  
  Cayenne.virtualWrite(V0, t); //virtual pin 
}

CAYENNE_OUT(V1)
{  
  Cayenne.virtualWrite(V1, h); //virtual pin
}
CAYENNE_OUT(V2)
{
  Cayenne.virtualWrite(V2, hif); //virtual pin
}