Non-blocking DHT11, DHT21, DHT22 library

I wanted to use a DHT22 to measure temperature and humidity, and the only library I could find was the one from Adafruit. Unfortunately this library blocks execution for about 300 ms, which is not acceptable for my application.

So, I whipped together a library based on Adafruit's code that reads the temperature and the humidity from a DHT11, DHT21, or DHT22 sensor without blocking execution, except during the actual data acquisition which is timing critical.

It isn't well tested, but it seems to work for me. Find it at: GitHub - olewolf/DHT_nonblocking: Non-blocking Arduino library for the DHT11, DHT21, and DHT22 sensors.

Thanks for sharing!

Please check - http://playground.arduino.cc/Main/DHTLib -

There is at least one interrupt driven library mentioned there, - http://forum.arduino.cc/index.php/topic,155800.0.html - , it has been around for some time.

robtillaart:
There is at least one interrupt driven library mentioned there, - http://forum.arduino.cc/index.php/topic,155800.0.html - , it has been around for some time.

Thanks. I actually discovered this library myself shortly after writing my previous post. It probably wouldn't be ideal for my application, though, because I'm using a somewhat aggressive timer interrupt to control a stepper motor. I'd have to share the interrupts then.