From e120e5f1224bf49a8e593953cb3e327ac0053eca Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Wed, 20 Jan 2021 10:18:19 +0100 Subject: [PATCH] Fix DHT12 negative temps Fix DHT12 negative temps (#10632) --- tasmota/xsns_58_dht12.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasmota/xsns_58_dht12.ino b/tasmota/xsns_58_dht12.ino index 4bab87bb3..966794ce5 100644 --- a/tasmota/xsns_58_dht12.ino +++ b/tasmota/xsns_58_dht12.ino @@ -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; }