Community

DHT22 / AM2302 sensor driver library available?

I am looking for (sample) code to read temperature data from DHT22 sensor
There is a zip-file posted in the old forum back in 2011, but without an account it cannot be downloaded
Anyone?

Thx,

Jan

I have made the code from this post on the DHT22 available here: DhtSensorApp.zip.

Regards,
Mark

Thanks Mark!

Regards,
Jan

Hi Mark,

thanks for that code - I’ve been struggling with it on and off for a few days. I’ve sometimes been getting responses, sometimes not. I’ve not that much hardware experience, I’ve been trying to recreate:

This is how I set it up the wiring between a Netduino Plus and the DHT22 sensor: Pin 1 -> VCC Pin 2 -> D0 and D1 Pin 4 -> Ground And a 10K resistor between Pin 1 and Pin 2.

but without success (or even consistent failure)

there is mention of a diagram as well:
http://forums.netduino.com/index.php?app=core&module=attach&section=attach&attach_id=1959

but I’m unable to get to it

would you be able to help with that as well please?

no worries if you can’t

cheers

Toby

Here is the image mentioned

Regards,
Mark

Hi Mark,

thanks for getting back in touch so quickly!

That’s pretty much what I ended up with, though I have also been experimenting with the pull up resistor, as shown in this one:

(image not showing, but from here http://cactus.io/hookups/sensors/temperature-humidity/dht22/hookup-arduino-to-dht22-temp-humidity-sensor

I’m getting very inconsistent results - generally the ‘no pins’ connected error, but sometimes I’ve got all the way to ‘failed checksum’, which was exciting

I’ve just revived my old Netduino Plus, which is happily reading a Sparkfun soil moisture sensor and posting the values to IFTTT, but am I pushing my luck trying to get the DHT22 running as well? It’s been an interesting journey to get this far, but I don’t want to waste my time if the hardware just isn’t compatible

cheers

Toby

I’ve never tried to use that particular sensor although I have used the DHT11 (which is the same family of devices I believe) in the past. Never used it on the Netduino though. You could be encountering timing issues with the protocol which may explain the inconsistent results.

I’m currently using the BME280 for temperature, pressure and humidity readings. Although I believe that has been superseded by the BME680 (it’s cheaper and adds gas measurements to the mix). These have the advantage of using I2C for comms and so they are easier to use in some sense.

Regards,
Mark