DHT22 Troubleshooting Tips

This is a list of common problems that users have encountered when trying to connect a DHT22 temperature/humidity sensor to the Raspberry Pi.

  1. You must reboot the Pi after installing the Adafruit software.
  2. The 10k Ω pull up resistor is required and it must be connected between the data pin and the 3.3V pin.  Some users have had better results with lower values such as 5.1K Ω.
  3. Incorrect wiring is common.  Pin 1 is the left pin when looking at the front of the DHT22 sensor with the pins point downward.  The front is the side with vents.
  4. Pin 2 is data and Pin 3 is not used.  It is easy to accidentally swap them.
  5. Power the DHT22 with 3.3V.  It is simpler and safer.  Do not use 5V unless you know what you are doing.
  6. Keep your wiring short during testing (less than 15cm).  Longer wires can cause interference.  The datasheet states that wire distances greater than 100cm requires 5V and should use shielded cable.
  7. When installing the software libraries make sure there are no error messages during any of the steps.
  8. Make sure you are in the correct directory when running commands.  You want to be in the home directory when you use git or wget.  You want to be in the newly downloaded directories when you run installation commands.
  9. The Adafruit library requires that your python code be run with superuser privileges.  (Update: super-user privileges are no longer required for GPIO access with the latest version of Raspbian Jessie.) If you are using an older system then open a terminal window from the Raspberry Pi desktop GUI type/usr/bin/gksu -u root idle
  10. If the Adafruit library doesn’t work, try the Pigpio library and vice versa.
  11. If you are using Pigpio, make sure you start the daemon before issuing any commands.
  12. If you get string format errors, try typing the variables alone in the python shell.  It is very common to get the format syntax incorrect.
  13. You must wait at least 2 seconds between calls to the DHT22 sensor.  Polling it more frequently will lead to errors.
  14. Start with a clean build of the latest version of Raspbian.
  15. Make sure you don’t have any other programs running that interact with the GPIO pins.
  16. For testing purposes, disconnect any other hardware from the GPIO pins.
  17. Try a different Pi GPIO pin for data.  For the Adafruit library, you would specify the GPIO pin of the sensor when calling the read_retry method. For example, with the data pin connected to GPIO pin 13 you would use: h,t = dht.read_retry(dht.DHT22, 13). For the Pigpio library you would specify the GPIO pin for data when instantiating a sensor. For example a sensor connected to GPIO pin 19 would be: s = DHT22.sensor(pi, 19)
  18. If using the DHT11 instead of DHT22 make sure you change the Adafruit read_retry method to DHT11.  I have not tested the DHT11 and I don’t know if it works with Pigpio.  I’ve heard it works OK with Adafruit.
  19. Be careful when handling electronic components because they can be damaged by static electricity.
  20. On newer or overclocked Raspberry Pi’s it may be necessary to add a 10ms delay after the Pigpio trigger command to compensate for the extra speed.