Class for DHT11, DHT21 and DHT22 (temperature & humidity)

MarsWarrior:
Just a few questions while checking both DHT versions:

Rob:

  • Has a delay of 20msec for both DHT11 and DHT22.
  • Uses a counter in the while to break out of the while in case the pin does not change

Mark:

  • Has a delay of 18msec for the DHT11 and 800usec for the DHT22.
  • Uses an endless while loop, so if the pin does not change --> Arduino in endless loop!

Further:

  • I am using multiple DHT22's on different pins. Which library would be most RAM efficient?
  • Is the 800usec the right delay for the DHT22? If so, it saves me 5*19msec = 75msec of doing nothing, which is a lot using NilRTOS/ChibiOS RTOSses...

Please comment 8)

  • 800usec for a DHT22 is according to the datasheets I found. And it works.
  • My library won't hang. The endless loop you mention has a return statement which is called after 85 usec.
  • Per DHT instance, you need 18 bytes of data~~, perhaps a little more overhead, I would need to measure to give a hard number~~. So no problem to run a lot of DHT sensors (tried two myself). The advantage of having an instance per sensor is that you can read out them in parallel. On the other hand, it would be straightforward to alter setup() to something like setup(pin, model) and then you could reuse the instance. But not sure if the effort is worth the 18*(sensor-1) bytes...