diff --git a/dht.cpp b/dht.cpp index aa348d3..11b00be 100644 --- a/dht.cpp +++ b/dht.cpp @@ -1,12 +1,13 @@ // // FILE: dht.cpp // AUTHOR: Rob Tillaart -// VERSION: 0.1.31 +// VERSION: 0.1.32 // PURPOSE: DHT Temperature & Humidity Sensor library for Arduino, AVR optimized // URL: https://github.com/RobTillaart/DHTlib // http://arduino.cc/playground/Main/DHTLib // // HISTORY: +// 0.1.32 2021-02-01 fix negative temperature DHT22 again (code from DHTNew) // 0.1.31 2020-12-15 fix negative temperature DHT22 (code from DHTNew) // 0.1.30 2020-06-30 own repo; // 0.1.29 2018-09-02 fix negative temperature DHT12 - issue #111 @@ -113,12 +114,9 @@ int8_t dht::read(uint8_t pin) bits[2] &= 0x83; // CONVERT AND STORE - humidity = (bits[0] * 256 + bits[1]) * 0.1; - temperature = ((bits[2] & 0x7F) * 256 + bits[3]) * 0.1; - if (bits[2] & 0x80) // negative temperature - { - temperature = -temperature; - } + humidity = (bits[0] * 256 + bits[1]) * 0.1; + int16_t t = (bits[2] * 256 + bits[3]); + temperature = t * 0.1; // HEXDUMP DEBUG /* diff --git a/dht.h b/dht.h index 6757723..fd4014d 100644 --- a/dht.h +++ b/dht.h @@ -1,7 +1,7 @@ // // FILE: dht.h // AUTHOR: Rob Tillaart -// VERSION: 0.1.31 +// VERSION: 0.1.32 // PURPOSE: DHT Temperature & Humidity Sensor library for Arduino. AVR optimized // URL: https://github.com/RobTillaart/DHTlib // http://arduino.cc/playground/Main/DHTLib @@ -20,20 +20,22 @@ #include #endif -#define DHT_LIB_VERSION "0.1.31" -#define DHTLIB_OK 0 -#define DHTLIB_ERROR_CHECKSUM -1 -#define DHTLIB_ERROR_TIMEOUT -2 -#define DHTLIB_ERROR_CONNECT -3 -#define DHTLIB_ERROR_ACK_L -4 -#define DHTLIB_ERROR_ACK_H -5 +#define DHT_LIB_VERSION (F("0.1.32")) -#define DHTLIB_DHT11_WAKEUP 18 -#define DHTLIB_DHT_WAKEUP 1 +#define DHTLIB_OK 0 +#define DHTLIB_ERROR_CHECKSUM -1 +#define DHTLIB_ERROR_TIMEOUT -2 +#define DHTLIB_ERROR_CONNECT -3 +#define DHTLIB_ERROR_ACK_L -4 +#define DHTLIB_ERROR_ACK_H -5 + +#define DHTLIB_DHT11_WAKEUP 18 +#define DHTLIB_DHT_WAKEUP 1 + +#define DHTLIB_DHT11_LEADING_ZEROS 1 +#define DHTLIB_DHT_LEADING_ZEROS 6 -#define DHTLIB_DHT11_LEADING_ZEROS 1 -#define DHTLIB_DHT_LEADING_ZEROS 6 // max timeout is 100 usec. // For a 16 Mhz proc 100 usec is 1600 clock cycles @@ -46,6 +48,7 @@ #define DHTLIB_TIMEOUT (F_CPU/40000) #endif + class dht { public: diff --git a/library.json b/library.json index 7b68396..0b13224 100644 --- a/library.json +++ b/library.json @@ -15,7 +15,7 @@ "type": "git", "url": "https://github.com/RobTillaart/DHTlib.git" }, - "version":"0.1.31", + "version":"0.1.32", "frameworks": "arduino", "platforms": "*" } diff --git a/library.properties b/library.properties index af7b1f6..36ad52e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=DHTlib -version=0.1.31 +version=0.1.32 author=Rob Tillaart maintainer=Rob Tillaart sentence=AVR Optimized Library for DHT Temperature & Humidity Sensor on AVR only.