DHT11 not working properly
See original GitHub issueUsing version 3.5.8
in a loop it almost never gets a reading with the following code:
import time
import board
import adafruit_dht
dhtDevice = adafruit_dht.DHT11(board.PG6)
for try_number in range(1,200):
print(f"Try number {try_number}")
try:
print(f"Got temp of: {dhtDevice.temperature}")
print(f"And hum of: {dhtDevice.humidity}")
break
except RuntimeError as e:
print(e)
time.sleep(2.1)
else:
time.sleep(2.1)
print("\n")
The weird part is that using the version 3.5.5
it actually get the readings correctly.
More data: Python: 3.8.5 SBC: Orange Pi Lite Installed libraries:
Adafruit-Blinka==6.4.1
adafruit-circuitpython-busdevice==5.0.6
adafruit-circuitpython-dht==3.5.5
adafruit-circuitpython-mcp3xxx==1.4.5
Adafruit-PlatformDetect==3.4.0
Adafruit-PureIO==1.1.8
appdirs==1.4.4
attrs==20.3.0
bcrypt==3.2.0
cached-property==1.5.2
certifi==2019.11.28
cffi==1.14.3
chardet==3.0.4
cryptography==3.2.1
dbus-python==1.2.16
distlib==0.3.1
distro==1.5.0
distro-info===0.23ubuntu1
docker==4.3.1
docker-compose==1.27.4
dockerpty==0.4.1
docopt==0.6.2
filelock==3.0.12
idna==2.8
iotop==0.6
jsonschema==3.2.0
mudpi==0.10.0
paho-mqtt==1.5.1
paramiko==2.7.2
pycparser==2.20
pyftdi==0.52.9
PyGObject==3.36.0
PyNaCl==1.4.0
pyrsistent==0.17.3
pyserial==3.5
python-apt==2.0.0+ubuntu0.20.4.4
python-dotenv==0.15.0
pyusb==1.1.1
PyYAML==5.3.1
redis==3.5.3
requests==2.22.0
requests-unixsocket==0.2.0
six==1.14.0
texttable==1.6.3
unattended-upgrades==0.1
urllib3==1.25.8
virtualenv==20.1.0
websocket-client==0.57.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:14
Top Results From Across the Web
[SOLVED] DHT11/DHT22 - Failed to read from DHT sensor
1. Wiring · 2. Power · 3. Bad USB port or USB cable · 4. Power source · 5. Sensor type · 6....
Read more >Problem with DHT11 on UNO (FIXED) - Arduino Forum
HI, I have used dht11 sensors before without problem, but now can't get it to work. I have two of them and same...
Read more >[SOLVED] "Failed to read from DHT sensor!" - Losant Forums
You'll need to increase the underlying MQTT library's memory limit. The PubSubClinet MQTT library has a default memory limit that is not enough ......
Read more >DHT11 interface Errors - Raspberry Pi Forums
If you're powering the sensor from a 3.3V pin, in some cases powering the DHT with 5V solves the problem. ... Sometimes powering...
Read more >Problem with a DHT11 Temperature & Humidity sensor
Finally I was able to solve the problem by not using the resistor and connecting it directly, I also had a problem with...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I hope it is a DHT11 because it actually looks like one, my sensor is this one which was bought on other site.
Regarding that datasheet it states the following:
So it has to be AT LEAST 18ms and I’m actually getting better results with less than that (1.85ms)🤮
If you need me to test something else just let me know.
P.D: I can also contact me through Discord and probably it would be more faster.
I wanted to add some testing to help give more data. I have a RPi4 that works fine with both the DHT11 and DHT22. I also have a RPi zero w but it has more trouble getting reads from both the DHT11 and DHT22. I thought I would run tests on the zero and see if it helps reveal more on the timings.
Here are some details:
Installed packaged
Board: RPi Zero W Python: 3.7.3
Test Script Results