The DHT11 and DHT22 sensors measure temperature and humidity, and are easy to interface because they only require a single I/O pin. They differ in their measurement accuracy, but are in fact fully interchangeable.
There is code for these sensors floating around on the web, but it all seems more complicated than necessary, and I really didn’t want to have to use floating point. So I added a new “DHTxx” class to JeeLib which reads them out and reports temperature in tenths of a degree and humidity in tenths of a percent.
Along with a new demo sketch called dht_demo:
That’s about as simple as it gets, and it compiles to less than 4 KB.
Sample output, in this case a DHT11 which only reports whole degrees and percentages:
Humidity is gradually shooting up as I breathe next to it (there’s a slight lag).
Onwards!
Xlnt, I have just started to use these and now it’s built into jeelib! – thanks.
For those interested (like me), here are the differences between the DHT11 and the DHT22 (source: http://www.ladyada.net/learn/sensors/dht.html):
DHT11
DHT22
Yes, I got bit by the sampling rate. I attached this guy to a UAV which was typically going at 10 m/s so at the prescribed sampling rate that would be every 20m for a DHT22. I like the sensor for several reasons, but for the UAV application, I should look at something for better sampling resolution.
p.s. JCW thanks for the nice library implementation! Do you add any access to error checking?
Is there any temperature sensors with more accuracy ?
Hi JCW and Everyone,
Recently I added one DHT22 to a second wireless temperature data logger. These wireless data loggers are both using bare minimum Atmega328P, caps and are powered with two AA batteries (~3.3v).
Running only the DS18B20 (and the ATmega328P) once every minute (the system is in low power mode for about 59 secs each minute) and consumes less than 0.01v / week. After adding the DHT22, I realized that in one week, the consumption raised to approximately 0,5v/week (yes, that’s 1/2 volt) after a week running.
This seems a “power-hungry” sensor to run in this minimal approach. (remotely and with batteries)
I think I’m not putting it to sleep after every minute reading… Is there any way to put the DHT22 in low-power/sleep mode while not reading data?
Luis
Even in low-power mode it draws a fair amount of current (150 µA, I think). The only way to avoid that is probably to power it from an I/O pin and turn that pin off.
Hi JCW,
Thanks for the tip! I will try that and see how it goes. Regards, Luís