olewolf / DHT_nonblocking

Non-blocking Arduino library for the DHT11, DHT21, and DHT22 sensors
GNU General Public License v3.0
37 stars 28 forks source link

Decimal value on DHT11 #7

Open fplanque opened 3 years ago

fplanque commented 3 years ago

Hi!

It seems that the DHT11 does actually report 1 decimal for temperature (eg: 19.9 °C) as shown here: https://forum.arduino.cc/index.php?topic=656964.0

Is there any way to obtain the decimal value with this library? (I always get a rounded number, eg: 19.0 or 20.0)

Thank you.

alwynallan commented 3 years ago

Same issue but I fixed it by looking at the latest Adafruit code. In read_temperature( ) change the relevant case to

  case DHT_TYPE_11:
    to_return = data[2];
    if (data[3] & 0x80) to_return = -1. - to_return;
    to_return += (data[3] & 0x0f) * 0.1;
    break;

BTW, it works with esp32 and that should be added to library.properties.

olewolf commented 3 years ago

Same issue but I fixed it ...

BTW, it works with esp32 and that should be added to library.properties.

Could you please make a pull request so I can update the library?

Thanks!

alwynallan commented 3 years ago

My git skills are limited, but I think I did it right.

There's another change in the Pull Request - increased COOLDOWN_TIME - that might cause problems elsewhere.

Thanks for maintaining this. Adafruit should adopt it.

A. Peter Allan

On Wed, Jan 6, 2021 at 9:45 AM Ole Wolf notifications@github.com wrote:

Same issue but I fixed it ...

BTW, it works with esp32 and that should be added to library.properties.

Could you please make a pull request so I can update the library?

Thanks!

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/olewolf/DHT_nonblocking/issues/7#issuecomment-755339869, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACNKNTHGZLHA5KUMPL437M3SYRZQZANCNFSM4VWZTRNA .