From aa09082d7fc1251694d01cb0e760d5d8f3fe4634 Mon Sep 17 00:00:00 2001 From: capswiz Date: Fri, 30 Dec 2011 11:16:38 +0100 Subject: [PATCH] BUG : return DHT_ERROR_CHECKSUM when temperature is negative. So I removed "currentTemperature &= 0x7FFF" line 208 and put "& 0x7FFF" in the expression line 209. Now it works with negative temperatures. --- DHT22.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DHT22.cpp b/DHT22.cpp index 7daf684..8cf45f3 100644 --- a/DHT22.cpp +++ b/DHT22.cpp @@ -205,8 +205,8 @@ DHT22_ERROR_t DHT22::readData() if(currentTemperature & 0x8000) { // Below zero, non standard way of encoding negative numbers! - currentTemperature &= 0x7FFF; - _lastTemperature = (float(currentTemperature) / 10.0) * -1.0; + //currentTemperature &= 0x7FFF; -> if we modify currentTemperature after computing checksum, ERROR_CHECKSUM is returned + _lastTemperature = (float(currentTemperature & 0x7FFF) / 10.0) * -1.0; } else {