1

I am trying to setup a AM2302 (DHT22) to use with Raspberry Pi, and unable to get a signal. What I need help is to be able to conclude whether the problem is due to (1) sensor fault (2) wiring fault (3) software / missing dependency problem.

20/03/2019 Update - I have switched the wires with the correct GND pin #39 and the multi-meter reading shows 3.3V for the DAT and VCC, but again when I test using Adafruit_DHT and using the c driver, I get the same timeout error message. The wiring is posted in a second photo. I will have a try with another sensor, and then try using the piscope.

I have followed the instructions online from Adafruit website to download and install the library and failed when attempting to run the test script. From what I have traced the error code to a timeout message "DHT_ERROR_TIMEOUT" that is thrown in the C script "pi_2_dht_read.c" indicating that the AM2302 is not responding with the expected low voltage pull following the signal request pulse from the program. I don't have much experience in C code and just basic fluency using Python.

A few more details from the diagnostics

  1. the value reported in the variable pi_2_mmio_input(pin) is always reported as 16 at all times no matter whether the 500 ms / 20 ms pulse is sent or not
  2. the value of signal DAT from the sensor using a multi-meter is always 0.67V, no matter whether the sensor is enclosed in a closed chamber with pool of water inside (100% enviroment) or if it is in ambient (65-75%).
  3. the value of DAT when the 3.3V is unplugged returns to 0V.

Some other people have reported similar problem, and the caution message reported that "just waiting" or trying again will eventually get a reading. So I have applied the following test cases to test this theory, but I still get the same result.

  1. increasing the value of DHT_MAXCOUNT by 10x
  2. increasing the delay_seconds parameter for ready_retry () to 2s, 10s, 20s
  3. increasing the iteration attempts in read_retry() to 10, 20, 40

I have followed the instructions online from Adafruit website and also checked with a few other sources and still get the same result.

  1. instructions using Adafruit DHT Library
  2. Alternative software DHTXXD

Wiring details

AM2302 : Raspberry Pi

DAT : Pin #7 (GPIO4) gold/brown wire

VCC : Pin #1 (3.3V) red wire

GND : Pin #39 (GND) black wire

line of code in pi_2_dht_read.c which throws the exception

// wait for DHT to pull pin low.
unit32_t count = 0;
while (pi_2_mmio_input(pin)) {
  if (++count >= DHT_MAXCOUNT) {
  // Timeout waiting for response.
  set_default_priority();
  return DHT_ERROR_TIMEOUT;
  }
}

direct call to the C wrapper driver "Raspberry_Pi_2_Driver.c". Error code -1 corresponds to DHT_ERROR_TIMEOUT

>>import Adafruit_DHT
>>from Adafruit_DHT import Raspberry_Pi_2_Driver as driver
>>driver.read(2302,4)
(-1,0,0)

using Adafruit_DHT.read_retry(..)

>>import Adafruit_DHT
>>Adafruit_DHT.read_retry(2302,4)
Failed to get reading. Try again!

using the command from the tutorial

>>sudo ./AdafruitDHT.py 2302 4
Failed to get reading. Try again!

AM2302 wiring image - wrong pin 40 AM2302 wiring image - correct pin 39

  • 4
    If you connected as described it should work - although I usually use pin 9 as GND. Your (very unclear) photo seems to show you are using pin 40 - which won't work. (I have reservations about some of the Adafruit code - but that is a different issue) – Milliways Mar 19 at 9:09
  • You can visually check if the DHT22 is responding using piscope and easily log the transaction with monitor.py. – joan Mar 19 at 9:20
  • 1
    Agree with Milliways - it definitely looks like pin#40 not pin#39 – Jaromanda X Mar 19 at 12:56
0

From your picture it looks like you have your "GND : Pin #39 (GND) black wire" actually connected to pin #40 on the Pi. This will definitely cause your problem.

Here is the pinout for that header: enter image description here

  • yea I'm definitely going to test that first. When I was doing earlier tests I had it connected to pin 9 but its good to verify. – Taylor Hickem Mar 20 at 2:00
0

The successful pinout was: (+): pin1, 3.3v (dat): pin7, GPIO4 (-): pin6, GND

There seemed to be a driver problem as reinstallng the Adafruit library (essentially, updating it) helped acheive feed from the sensor.

sudo pip uninstall Adafruit_DHT
sudo rm -Rf /{PYTHON2}/dist-packages/Adafruit_*
sudo pip install Adafruit_DHT

The issue could have a number of reasons, but is likely tied to raspbian OS version.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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