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

12
  • You are feeding 5V into the Pi GPIO (you have a pull-up between 5V and the GPIO). That might destroy the GPIO/Pi.
    – joan
    Mar 7, 2020 at 17:00
  • I have found both 3 and 5V diagrams, does this mean RPi's GPIO is only 3V tolerant and I should use only 3V? circuitbasics.com/…
    – FN_
    Mar 7, 2020 at 18:43
  • You should not feed more than 3V3 into a Pi GPIO. I use a resistor divider to drop a 5V output to a Pi safe 3V3. So if you use 5V use something like a resistor divider on the output to the GPIO.
    – joan
    Mar 7, 2020 at 20:36
  • It is hardly surprising it is unreliable! Just sticking du-pont cables through header holes is hit or miss. Also DO NOT put 5V on the GPIO.
    – Milliways
    Mar 7, 2020 at 23:31
  • @joan OK, taking note about the right voltage for Pi. So what should I do now? Get another Pi for testing? Is there a way how to check what is the issue?
    – FN_
    Mar 9, 2020 at 11:06

2 Answers 2

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/

3
  • Thank you for the comment, I receive error code 3 - DHT_TIMEOUT. Is there a way how to test whether is the sensor OK?
    – FN_
    Mar 7, 2020 at 11:16
  • @FilipNiko Add a photo to your question. The photo should be clear enough to see the connections between the Pi pins and the DHT11 pins. We can then check that your connections are okay and see which GPIO you are using.
    – joan
    Mar 7, 2020 at 11:31
  • EDIT: Now I moved from error code 3 to 2, dunno what is going on :(
    – FN_
    Mar 7, 2020 at 11:34
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.

1
  • Thanks for the comment, I will stick to the original DHT.py for the troubleshoot and maybe later use your wrapped :)
    – FN_
    Mar 7, 2020 at 12:49

Your Answer

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

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