Fix DHT12 negative temps

Fix DHT12 negative temps (#10632)
This commit is contained in:
Theo Arends 2021-01-20 10:18:19 +01:00
parent c16fb465fb
commit e120e5f122

View File

@ -57,7 +57,7 @@ bool Dht12Read(void)
uint8_t checksum = Wire.read();
Dht12.humidity = ConvertHumidity( (float) humidity + (float) humidityTenth/(float) 10.0 );
Dht12.temperature = ConvertTemp( (float) temp + (float) tempTenth/(float) 10.0 );
Dht12.temperature = ConvertTemp( ((float)temp + (float)(tempTenth & 0x7F) / (float) 10.0) * (tempTenth & 0x80) ? -1.0 : 1.0 );
if (isnan(Dht12.temperature) || isnan(Dht12.humidity)) { return false; }