Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem: wrong values at negative temperatures an ESP8266 and DHT22 #177

Open
argltuc opened this issue Feb 1, 2021 · 4 comments
Open

Comments

@argltuc
Copy link

argltuc commented Feb 1, 2021

  • Arduino board: ESP8266 / NodeMCU 1.0 (ESP12-E Module)
  • Arduino IDE version (found in Arduino -> About Arduino menu): 1.8.13
  • installed DHT-sensor-library version: 1.4.1 / installed by Arduino IDE Lib manager

I use the DHT22 in combination with an ESP8266 and this lib.
When having negative temperatures, the resulting value of readTemperature() is -3278.6 at -0.1°C
To fix negatives values a recalculation is nessecary:

#include <stdint.h>
float temperature = dht.readTemperature();
if(temperature < 0)
 {
   temperature = (temperature = (INT16_MAX - temperature*-10)*-0.1; - temperature*-10)*-0.1;
 }

after some research, i figure out, that the values in data-array repressents an intager in ones complement, while the rest of data handling seems to be in BCD.
I will provide an PR to fix this issue.

@Maaajaaa
Copy link

I tried to repeat the bug with an ESP32 but all negative celsius temperatures that I got (though I did not get -0.1 in particular) seemed correct to me. Does this only concern -0.1C in partocular?

  • Arduino board: ESP32-CAM
  • Arduino IDE 1.8.12
  • installed DHT-sensor-library version: 1.4.2

@argltuc
Copy link
Author

argltuc commented Oct 28, 2021

If i remember correctly all negative values were wrong. Less temperature results in respective higher value then -3278.6.
Currently i can't repeat my measurements, since all my DHT22 sensor are used and fully integrated in some projects.

@tranquil-c
Copy link

I have been seeing this issue and have yet to narrow down on the cause.

I'm using version 1.4.4 of this library and building with PlatformIO:

  • framework-arduinoespressif32 @ 3.20007.0 (2.0.7)
  • tool-esptoolpy @ 1.40500.0 (4.5.0)
  • toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5

I've observed it twice now. On both occasions the temperature decreased, crossing 0 degrees, over the course of roughly an hour.

I'll be investigating the issue and will provide an update should I find anything notable.

@naymore
Copy link

naymore commented Dec 3, 2023

I know this thread is quite a bit old but I couldn't find any real solution to the problem.
I'm using v1.4.6 of this library (on an ESP8266) and I can confirm the problem is real.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants