Skip to content

Commit

Permalink
catch dht22 sign-mag -0C (#54)
Browse files Browse the repository at this point in the history
Co-authored-by: Arne Glaser <arne.glaser@valofly.com>
  • Loading branch information
argltuc and Arne Glaser committed Feb 15, 2021
1 parent d43929b commit 147ff17
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions dhtnew.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// FILE: dhtnew.cpp
// AUTHOR: Rob.Tillaart@gmail.com
// VERSION: 0.4.4
// VERSION: 0.4.5
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: https://github.com/RobTillaart/DHTNEW
//
Expand Down Expand Up @@ -37,6 +37,7 @@
// 0.4.2 2020-12-15 fix negative temperatures
// 0.4.3 2021-01-13 add reset(), add lastRead()
// 0.4.4 2021-02-01 fix negative temperatures DHT22 (again)
// 0.4.5 2021-02-14 fix -0°C encoding of DHT22


#include "dhtnew.h"
Expand Down Expand Up @@ -189,7 +190,10 @@ int DHTNEW::_read()
{
_humidity = (_bits[0] * 256 + _bits[1]) * 0.1;
int16_t t = (_bits[2] * 256 + _bits[3]);
_temperature = t * 0.1;
if(_bits[2] == 0x80)
_temperature = 0;
else
_temperature = t * 0.1;
}
else // if (_type == 11) // DHT11, DH12, compatible
{
Expand Down
4 changes: 2 additions & 2 deletions dhtnew.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// FILE: dhtnew.h
// AUTHOR: Rob Tillaart
// VERSION: 0.4.4
// VERSION: 0.4.5
// PURPOSE: DHT Temperature & Humidity Sensor library for Arduino
// URL: https://github.com/RobTillaart/DHTNEW
//
Expand All @@ -22,7 +22,7 @@
#include "Arduino.h"


#define DHTNEW_LIB_VERSION (F("0.4.4"))
#define DHTNEW_LIB_VERSION (F("0.4.5"))


#define DHTLIB_OK 0
Expand Down

0 comments on commit 147ff17

Please sign in to comment.