Last week I posted a DHT class on the playground - http://arduino.cc/playground/Main/DHTLib - that supports both DHT11 and DHT22 sensors.

Although the protocol / handshake is the same for both sensors the dataformats used differ unfortunately. The DHT22 has a wider range and higher resolution. The class is rewritten completely from scratch but inspired by earlier work of George Hadjikyriacou (see also - http://arduino.cc/playground/Main/DHT11Lib ) . The class has two read functions called read11(PIN) and read22(PIN) to read the different sensors. This way one instance of the class can serve multiple, and even mixed sensors. The code of the lib is straightforward and can be stripped if one only has DHT11 or only DHT22's.

Thanks for all complements, part of the kudos need to go to Simkard as he is the one who tested my code and gave me needed feedback. As you can see on the playground article there are still a few things needed to be tested - esp negative temperatures for the DHT22 - and I'm considdering to give both temp and humidity the value -500 or so if there is a problem reading the sensor. Now they keep the last value, so if someone doesn't check the return value of the read function (s)he might assume that the reading was OK as there is a valid looking temp/hum.

Good to know you have those sensors in your shop. The URL doesn't work for me (but I'll find them anyway)

It's OK to make a copy of the playground article, but please put a reference in it to the playground (I can do that in the code => good idea, thanks, welcome) as I will update only the playground article.

Ustedes usan la linea de datos conectada directamente a un puerto?. And not use a resistor entre la linea de datos y Vcc.You use the data line connected directly to a port?. And not use a resistor between the Vcc and data line.

No I did not use a resistor between the data line and the Vcc. But in my project the lines were very short. If your lines are longer you could try a 4K7 resistor (similar to I2C).

I'm trying to build a simple sensor upload to Pachube. I've been troubleshooting this for awhile, and it seems that the problem is with the DHT22 readings, not with the push to Pachube.I'm reading the data from the DHT22 correctly:

That's my serial output.The line after the "+"s is the checksum and humidity and temperature read from the DHT22. The two lines below that are link messages regarding my connection to Pachube. The final 5 lines deal with the data being sent to Pachube. The first two pieces (0 and 1) of data are analog reads from a light sensor and a motion sensor connected to analog lines. The two items following that (2,3) are the temperature and humidity reads from the DHT22.I can read the DHT22 in the first portion of my code. I cannot read them in the second portion of my code. Why?I've tried various methods of placing the initial DHT22 data into variables, and printing those variables. Inevitably the serial monitor prints out a "1" when it is trying to send the data feed to Pachube.

Am I wrong? Am I attacking this the wrong way, and instead should be looking at the Pachube end of things?

* Based on code:* Created 22 April 2011* By Jeffrey Sun* http://code.google.com/p/pachubelibrary/* and * robtillart* http://arduino.cc/forum/index.php/topic,58531.0.html* http://arduino.cc/playground/Main/DHTLib