Pages: [1]   Go Down
Author Topic: DHT22 sensor experiment - not reading all bytes => Fast Humidity sensor  (Read 1039 times)
0 Members and 1 Guest are viewing this topic.
Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13707
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Last week I updated my DHTlib and I got the following idea. The data of the DHT exists of 5 bytes (2 humidity, 2 temperature and 1 CRC). What if I not read all 5 bytes? would that be usable?

A quick experiment (patching  my lib) gave the following results:
Code:
5 bytes - normal library
----------------------------------------
Type, status, Humidity (%), Temperature (C) Time (us)
DHT22, OK, 63.0, 22.3, 5196
DHT22, OK, 63.0, 22.3, 5092

4 bytes - skipping CRC byte (last byte) // removed CRC error msg)
----------------------------------------
DHT22, OK, 62.6, 22.2, 4220
DHT22, OK, 62.7, 22.3, 4324

3 bytes - humidity + only high temperature)
----------------------------------------
DHT22, Checksum error, 62.2, 0.0, 3372
DHT22, Checksum error, 62.2, 0.0, 3372
==> makes no sense as temperature is then in steps of 25.6C

2 bytes - only reading humidity
----------------------------------------
Type, status, Humidity (%), Temperature (C) Time (us)
DHT22, Checksum error, 63.1, 0.0, 2808
DHT22, Checksum error, 62.9, 0.0, 2760

1 byte - only reading high humidity
----------------------------------------
DHT22, Checksum error, 51.2, 0.0, 1896
DHT22, Checksum error, 51.2, 0.0, 1904
==> big error in humidity
It is clear that reading less bytes decreases the reading time and there are only 2 interesting options.
1) skipping the CRC improves the speed by almost 0.8 millisec ~~16%
2) if you only need humidity and no CRC check you can even win 2.3 millisec ~~45%

So yes, not reading all bytes can be useful, especially if you are in a real need for fast humidity (without CRC!)
And no, this will not become part of the DHTlibrary.  smiley

Note that for the DHT11 which has a wakeup delay of 20 millis these gains are substantially less
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Topsham, Vermont USA
Offline Offline
Edison Member
*
Karma: 33
Posts: 1923
... in The Woods In Vermont
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I think Rob will be getting a letter from the Wet Administratiefrechtelijke Handhaving Verkeersvoorschriften.
Logged

Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

Global Moderator
Netherlands
Offline Offline
Shannon Member
*****
Karma: 217
Posts: 13707
In theory there is no difference between theory and practice, however in practice there are many...
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

LOL smiley-wink
Logged

Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Pages: [1]   Go Up
Jump to: