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

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

The counter makes the loop fool proof.
The 20 mSec is to make code as similar as possible for both sensors, Mark optimizes the code to the detail of the datasheet which is good better :wink:

I am using multiple DHT22's on different pins. Which library would be most RAM efficient?

Not tested, I expect the lib from mark be smaller for a single sensor but my lib can support multiple with one instance. Somewhere there must be a break even point.
It would be very informative if you could provide some numbers

  • 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...

800usec - check datasheet.

In an RTOS one should schedule another thread when delay is called, to return /test later. In pseudocode

delay(uint32_t ms)
{
  wakeUpThisThread(ms);
  switchThread();
}

This way one could always use the waiting time effective. (disclaimer, no RTOS expert)