Smart Thermostat is now a legacy project › Forums › English support forum › Relay Box › Reply To: Relay Box
Hi,
Indeed this the lib I used.
This is code I changed, still quick & dirty, as I wanted to wait your response before I would clean the code up and add some more error catching. As this code is your work, I wanted you to have the final word 🙂 although I’m happy to help..
int chk = SimpleDHTErrSuccess;
double celsiusTemp = -10000;
double fahrenheitTemp = -10000;
float temperature = 0;
float humidity = 0;
if (DHTTYPE == 22) {
chk = dht22.read2(DHTPin,&temperature, &humidity, NULL );
} else {
chk = dht11.read2(DHTPin,&temperature, &humidity, NULL );
}
if (chk == SimpleDHTErrSuccess) {
thError=””;
Serial.print(“DHT OK,\t”); Serial.print(“TempCelcius= “);
Serial.print((float)temperature); Serial.print(” C°\t”);
Serial.print(“Humidity= “);
Serial.print((float)humidity); Serial.print(“\t”);
celsiusTemp = (float)temperature;
fahrenheitTemp = celsius2Fahrenheit(celsiusTemp);
} else {
switch (chk)
{
case SimpleDHTErrDataChecksum:
thError = “Checksum error”;
break;
default:
thError = “Unknown error”;
break;
}
Serial.print(thError);
}