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:


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!


  • \$\begingroup\$ Have you successfully used any GPIO on RasPi yet? Have to run as root (sudo) to have access to GPIO. \$\endgroup\$
    – MarkU
    Commented Mar 13, 2015 at 7:20
  • \$\begingroup\$ Yes I have doing other projects... So its not because of that \$\endgroup\$
    – idelara
    Commented Mar 16, 2015 at 5:13
  • \$\begingroup\$ have a look at this post electronics.stackexchange.com/questions/236530/… ; and if you will be willing to test out the code, I would be very interest to know if it is also fit to a DHT11. I am trying with that code to cut out the spikes due to DHT11 errors, and it seems to be work so far. \$\endgroup\$ Commented Jun 14, 2016 at 9:47

2 Answers 2


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

  • \$\begingroup\$ Thank you for pointing out the right direction for me. I see that you use a bit of a complicated terminology here. I have always wanted to create my own scripts not just use already-coded ones. Do you have any advice regarding how I can get started in regards to how to time bits and getting readings? Thanks! Your help is much appreciated! \$\endgroup\$
    – idelara
    Commented Mar 16, 2015 at 5:17
  • \$\begingroup\$ @JackGal I suggest you download my piscope and have a look at the waveform generated by the sensor during a reading. Then have a look at the various software solutions to see how they are capturing and interpreting the waveform. By comparing the waveform against the solutions you will be able to decide on your own solution. Good luck. \$\endgroup\$
    – joan
    Commented Mar 16, 2015 at 11:00

There are couple of steps for reading the DHT11 with raspberry. First if your using the wiringPi library you are good to go there are already some implementations in the internet. But if in my case you want to do it without any external libraries you have to map the memory of raspberry in order to manipulate the GPIO pins. Then you need a precise timer in order to send the DHT11 an initiation signal, which is going to trigger the sensor to start giving you data. You can read the timers in the datasheet of the product. After that the sensor is going to send you 5 bits of data. The first one is the integer part of the humidity. The second one is the decimal part of the humidity. Third and fourth are the temperature values. And the fifth bit is the check sum. So if your timers are correct when you sum the first four bits they must be equal to the fifth bit in order to have correct data.

You can see my implementation here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.