DH-11 Sensor on a Raspberry Pi & Arduino

arduinoraspberry pisensortemperature

I am trying to make my DH-11 sensor work on my raspberry pi but I have not succeeded after several attempts. I followed the following tutorial from Adafruit:

https://learn.adafruit.com/dht-humidity-sensing-on-raspberry-pi-with-gdocs-logging

My attempts were unsuccessful. I just do not get any feedback whatsoever from the sensor. I know that both my DH11/DH22 sensors do work because I do read data from them if I do the same circuit using my arduinos and run a script. I also don't think my raspberry's GPIOs are damaged in any way since I tried with like 5 and I didn't get any data.

I am not trying to log stuff to a google doc like the tutorial does, I am just trying to read data from the sensor using the raspberry.. I have plans to log the data in a server an access it remotely… But for that I have to get readings from the sensor first.

Now, has anyone achieved this? Reading data from a DH11/DH22 in the raspberry pi? If so, could you tell me which tutorial you followed? I've been looking for some out there but it seems that Adafruit's is by far the most popular one.

Thanks for your help!

Cheers!

Best Answer

Adafruit's may be a popular tutorial but the actual software implementation is perhaps not the best (warning, I have my own software solution so should not be considered impartial).

The DHT11/DHT22 generate a bit stream to encode the reading. The length of each pulse high time encodes whether the bit is a zero or a one. Timing these bits is crucial to getting a valid reading.

Most implementations use busy wait timing for the bits which is susceptible to Linux rescheduling problems. Those implementations do work but are not reliable. You might need to take three of four readings before you get one which passes the checksum calculation (waiting several seconds between each).

One reliable method is to use the SPI hardware to read the bit stream. That will get error rates better than 1 in a 100,000 readings.

The other method is to use my pigpio library which times gpio events down to the microsecond level. DHT22 Python example here. The github has a DHT11 example.

For background information see post

Related Topic