Black Lives Matter - Action and Equality. ... Adafruit is open and shipping.
0

DHT11 acting strange
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

DHT11 acting strange

by infinisean on Wed Jun 03, 2020 6:02 pm

Hi All,

New here, so please be gentle.
I just got some DHT11 sensors for a project I am working on and did a fresh install of Buster on my Pi4B, python 3.7.3 using virtualenv.
When running the test script, I am getting a lot of errors (40-50%) polling the DHT11 and then it eventually fails with an OverflowError.

Any insight would be greatly appreciated.

Thanks!

(py3) pi@MushPi4:~ $ python dhttest.py
Temp: 26.0 C 78.8 F Humidity: 55%
Temp: 26.0 C 78.8 F Humidity: 55%
DHT sensor not found, check wiring
Checksum did not validate. Try again.
Temp: 26.0 C 78.8 F Humidity: 54%
DHT sensor not found, check wiring
Temp: 26.0 C 78.8 F Humidity: 54%
Checksum did not validate. Try again.
DHT sensor not found, check wiring
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
DHT sensor not found, check wiring
Checksum did not validate. Try again.
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
DHT sensor not found, check wiring
Temp: 26.0 C 78.8 F Humidity: 54%
A full buffer was not returned. Try again.
DHT sensor not found, check wiring
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
DHT sensor not found, check wiring
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
Temp: 26.0 C 78.8 F Humidity: 54%
Checksum did not validate. Try again.
Traceback (most recent call last):
File "dhttest.py", line 11, in <module>
temperature_c = dhtDevice.temperature
File "/home/pi/py3/lib/python3.7/site-packages/adafruit_dht.py", line 242, in temperature
self.measure()
File "/home/pi/py3/lib/python3.7/site-packages/adafruit_dht.py", line 187, in measure
pulses = self._get_pulses_pulseio()
File "/home/pi/py3/lib/python3.7/site-packages/adafruit_dht.py", line 126, in _get_pulses_pulseio
pulses.append(self.pulse_in.popleft())
OverflowError: unsigned short is greater than maximum


CODE:

(py3) pi@MushPi4:~ $ cat dhttest.py
Code: Select all | TOGGLE FULL SIZE
import time
import board
import adafruit_dht

# Initial the dht device, with data pin connected to:
dhtDevice = adafruit_dht.DHT11(board.D20)

while True:
    try:
                # Print the values to the serial port
        temperature_c = dhtDevice.temperature
        temperature_f = temperature_c * (9 / 5) + 32
        humidity = dhtDevice.humidity
        print("Temp: {:1.1f} C    {:.1f} F     Humidity: {}% ".format(temperature_c, temperature_f,  humidity))
        #print("Temp:")
        #print('{:.1f} F'.format(temperature_f))
    except RuntimeError as error:
        # Errors happen fairly often, DHT's are hard to read, just keep going
        print(error.args[0])
    time.sleep(3.0)
Last edited by siddacious on Tue Jun 16, 2020 7:51 pm, edited 1 time in total.
Reason: adding code formatting

infinisean
 
Posts: 5
Joined: Thu May 28, 2020 9:18 pm

Re: DHT11 acting strange

by siddacious on Tue Jun 16, 2020 7:52 pm

Please post a clear, well lit picture that shows your testing setup and most importantly that shows all the connections.

Additionally please use the code tags to format code when you post it to help with legibility. I've edited your post to add them.

siddacious
 
Posts: 271
Joined: Fri Apr 21, 2017 3:09 pm

Please be positive and constructive with your questions and comments.