From 66c32b0f4c07c869ba9d1d0f4f0833983f4f1572 Mon Sep 17 00:00:00 2001 From: Peter Allan Date: Wed, 6 Jan 2021 11:06:42 -0500 Subject: [PATCH 1/3] Update library.properties Brief testing showed no problems with esp32. --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 4ea1f58..71c222c 100644 --- a/library.properties +++ b/library.properties @@ -6,4 +6,4 @@ sentence=Non-blocking DHT11, DHT21, and DHT22 sensor library paragraph=Read temperature and humidity from the DHT11, DHT21, and DHT22 sensors without blocking other execution. category=Sensors url=https://github.com/olewolf/DHT_nonblocking -architectures=avr,esp8266 +architectures=avr,esp8266,esp32 From 50c3528584994d87c0ae46d1e6749c5fa6a42e2c Mon Sep 17 00:00:00 2001 From: Peter Allan Date: Wed, 6 Jan 2021 11:10:12 -0500 Subject: [PATCH 2/3] Update dht_nonblocking.cpp Followed Adafruit's latest code to return 0.1 degree digit for DHT11. Also increased COOLDOWN_TIME to 10 seconds to reduce self-heating error. --- dht_nonblocking.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/dht_nonblocking.cpp b/dht_nonblocking.cpp index dd1ca87..27d2b5e 100644 --- a/dht_nonblocking.cpp +++ b/dht_nonblocking.cpp @@ -30,7 +30,7 @@ /* Number of milliseconds before a new sensor read may be initiated. */ -#define COOLDOWN_TIME 2000 +#define COOLDOWN_TIME 10000 /* @@ -80,8 +80,9 @@ float DHT_nonblocking::read_temperature( ) const switch( _type ) { case DHT_TYPE_11: - value = data[ 2 ]; - to_return = (float) value; + to_return = data[2]; + if (data[3] & 0x80) to_return = -1. - to_return; + to_return += (data[3] & 0x0f) * 0.1; break; case DHT_TYPE_21: From 62113cb696d27bb681dc71b67ab70aa2a9960a67 Mon Sep 17 00:00:00 2001 From: Peter Allan Date: Wed, 20 Jan 2021 20:18:45 -0500 Subject: [PATCH 3/3] Update dht_nonblocking.cpp Switched the order of two DHT11 statements for correct 0.1C digit when negative. Pretty sure Adafruit has it wrong too. --- dht_nonblocking.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dht_nonblocking.cpp b/dht_nonblocking.cpp index 27d2b5e..4c3ed66 100644 --- a/dht_nonblocking.cpp +++ b/dht_nonblocking.cpp @@ -81,8 +81,8 @@ float DHT_nonblocking::read_temperature( ) const { case DHT_TYPE_11: to_return = data[2]; - if (data[3] & 0x80) to_return = -1. - to_return; to_return += (data[3] & 0x0f) * 0.1; + if (data[3] & 0x80) to_return = -1. - to_return; break; case DHT_TYPE_21: