Merge pull request #11302 from s-hadinger/fix_dht12

Fix DHT12 on ESP32
This commit is contained in:
Theo Arends 2021-03-12 09:06:04 +01:00 committed by GitHub
commit 4072d6485f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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