Open martin-eden opened 2 years ago
I'm using this "DHT11" sensor from eBay: https://www.ebay.com/itm/221914097856
Despite specified range 0..50 °C it can measure negative temperatures and have temperature granularity 0.1 °C. Temperature sign is stored in bit 7 of second temperature byte.
are you getting more accuracy than DHT11.read2() ? (read2 takes floats)
As you figured it out in another issues,
read2() returns floats but temperature granularity is 1.0, not 0.1. https://github.com/winlinvip/SimpleDHT/blob/f938823ea9e0eaaa2deee98171097582c953aa33/SimpleDHT.cpp#L180
That's how I've done it:
// 2nd temperature byte: tenths of temperature in low nibble in BCD.
Temperature = (float) ((int16_t) Data[2] * 10 + (Data[3] & 0x0F)) / 10;
// 2nd temperature byte: bit 7 is temperature sign.
if (Data[3] & 0x80)
Temperature = -Temperature;
That lines in my "scrapyard" unmaintained repo.
For DHT11
While rewriting library for myself I've discovered that there are tenths of degrees Celsius transmitted in low nibble of second temperature byte. It is encoded in BCD, so hex values are in range 00..09.