0

I have RPI Zero with DHT11 connected as recommended (diagram) and I was reading data from it with ~90 % success rate every 5 minutes using the old Adafruit library. But today morning it stopped receiving data so I tried to troubleshoot it using new Adafruit library and it seems like there is connection issue:

DHT sensor not found, check wiring

Notes:

  • I am using 10K resistor.
  • DHT11 is connected to GPIO4 (pin 7)
  • I was able to measure voltage changes on the sensor, so I believe the wiring is OK

When running joans DHT.py, I was able to read the values for the first time, but then error appered:

pi@raspberrypi:~/Teplomer $ ./DHT.py 4
1583582364.035  4 0 24.0 57.0
1583582366.112  4 2 24.0 57.0
^Ccancelling 4
pi@raspberrypi:~/Teplomer $ ./DHT.py 4
1583582386.131  4 2 0.0 0.0
1583582388.205  4 2 0.0 0.0
1583582390.279  4 2 0.0 0.0
^Ccancelling 4
pi@raspberrypi:~/Teplomer $
pi@raspberrypi:~/Teplomer $ ./DHT.py 4
1583582738.135  4 3 0.0 0.0
1583582740.407  4 0 23.0 53.0
1583582742.480  4 2 23.0 53.0
^Ccancelling 4
pi@raspberrypi:~/Teplomer $ ./DHT.py 4
1583582746.751  4 0 23.0 53.0
1583582748.825  4 2 23.0 53.0
1583582750.899  4 2 23.0 53.0
^Ccancelling 4
pi@raspberrypi:~/Teplomer $ ./DHT.py 4
1583582779.302  4 2 0.0 0.0
1583582781.376  4 0 23.0 53.0

However, I did not move any parts so it seems like the sensor is dead?
How can I troubleshoot it?

Thank you!

Wiring

FN_
  • 103
  • 1
  • 3

2 Answers2

2

Run my DHTXX script.

It requires the pigpio daemon do be running.

sudo pigpiod

It expects the Broadcom number of the GPIO connected to the data line.

E.g. ./DHT.py 4 to read a sensor connected to pin 7.

Refer to https://pinout.xyz/

joan
  • 71,852
  • 5
  • 76
  • 108
1

I had previously used the Adafruit code but found it unreliable and rather restrictive.

I now use Joan's pigpio code, and found it quite reliable.
See https://raspberrypi.stackexchange.com/a/105549/8697

I wrote my own wrapper around the DHT.py module to make things easier (Joan writes great code, but the documentation is very sparse). This has been running for months without trouble, through updates power failures etc.

One advantage is that if no DHT11 found it doesn't lock up like the Adafruit code. The DHT11 is quite critical about timing, and occasionally misses a reading if the Pi is otherwise busy, so it retries 5 times before giving up.

It should be simple to strip out the MQTT code to adapt to your needs.

Milliways
  • 62,573
  • 32
  • 113
  • 225