-
-
Notifications
You must be signed in to change notification settings - Fork 31k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DHT22 / AM2302 does not read sensor data on Pi 4 (likely DHT11 as well) #37382
Comments
dht documentation |
Can confirm it's not working. I'm trying to solve the issue but it seems that the new library does not have support for AM2302 (but i don't have one so I can't try) How do we address that? |
Just passing by, but there are a few issues (e.g. adafruit/Adafruit_CircuitPython_DHT#33) that might point to it being an issue with the library? (AIUI AM2302 is simply a wired and packaged DHT22) |
Hey @edofullin |
Ok, thanks for the info, I'll try to address the problem |
I see you had problems with 0.112.0, I remember 0.112.4 working fine for a while for me, that's odd. |
Hi there, I've a rpi4 with a AM2302 sensor too, my experience is that after a while the sensor holds, I've tried with different setup with both 3.3V and 5V, different resistors and a capacitor as stated in the manual. |
Hi there! I have done an ugly workarround to make it work on RPi4. It works while you wait until somebody updates Adafruit_DHT to latest version. If nobody does, when I have some time and get to know how to do it, I will do it in the proper way. You have to attach to your docker container running homeassistant. First run:
Then you run (replace 241ee026029b with your corresponding container id) :
get_platform() function should look like this:
To exit the container run: That's all, hope it helps you! |
Hi there! i did a fork of homeassistant in order to try and implement the Adafruit_CircuitPython_DHT since the Adafruit_Python_DHT has been deprecated and to make it work on my Pi 4 without any workaround.
anyone can help me ? |
Had the same https://stackoverflow.com/a/63311551/9839378 pointed out that it has to to with a raspbian update. So I did this:
This clearly is only a workaround but I will be looking for updates from Adafruit or a better workaround 😄 |
For me DHT22 is working fine with version 0.114. It is very stable. After upgrade to 0.115 and newer versions the DHT22 sensor stop working after several hours. I see no data for this sensor. Some times reboot helps to get the sensor to send data again. But sometimes reboots doesn't help. Update: I'm using DHT22 and relay on my RPi3. May be there is some conflicts with simultaneous request to DHT22 and changing of relay state. |
Note that there is a PR for this which is not linked: #41525. |
This issue is pretty annoying since more and more people are getting a Raspi 4, and the documentation page of DHT sensor should point out this bug until it is fixed. |
Is there any way to use those sensor on RPI4(b) for now before PR merge? |
from pigpio_dht import DHT11, DHT22 gpio = 4 # BCM Numbering sensor = DHT11(gpio) result = sensor.read() Even I had the same problem..This code worked for me you can also try once. Before running the code enter the commands on the terminal sudo pigpiod #Start daemon pigs pud 4 u # Set internal pull up If pigpio-dht is not installed enter |
this worked perfectly for me, thanks! |
I am using DHT22 with Raspberry Pi 4 in Proteus 8.13 for my simulation. I am still facing "No module named 'adafruit_max7219' [U1] ". Anyone can help ? |
Esta es la respuesta! gracias amigo, te amo jajaja (estuve 7 horas buscando una solución y llegue a tu certero comentario <3 ) |
The problem
DHT Sensor does not appear to work for AM2302 on PI4. The exact same config / pinout /sensor works fine on a Pi3. The issue appears to be the depricated Adafruit_DHT library which has been replace by adafruit-circuitpython-dht
New Library:
https://github.com/adafruit/Adafruit_CircuitPython_DHT
Deprecated Library
https://github.com/adafruit/Adafruit_Python_DHT
Don't be fooled by the "Include Raspberry Pi 4" description on the folder for the deprecated library, though the device name is the same, it does not work.
Testing Done:
This was confirmed by running the AdafruitDHT.py manually FROM THE HOST (not within the container) and not getting any reading info.
pi@Pi4:~/Adafruit_Python_DHT/examples $ sudo ./AdafruitDHT.py 2302 4
Failed to get reading. Try again!
However, after installing the Adafruit_CircuitPython_DHT library and running the example provided in the git from the host (again, not the container):
pi@Pi4:~ $ python3 dht_simpletest.py
Temp: 82.6 F / 28.1 C Humidity: 58.0%
Temp: 82.6 F / 28.1 C Humidity: 58.1%
These findings seem to correlate with the error provided in the homeassistant logs, where HA is using the deprecated library:
Environment
Problem-relevant
configuration.yaml
sensor: AM2302
pin: 4
temperature_offset: 0
humidity_offset: 0
monitored_conditions:
Traceback/Error logs
2020-07-02 17:33:39 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
self.update # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/dht/sensor.py", line 137, in update
self.dht_client.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 239, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/dht/sensor.py", line 173, in update
humidity, temperature = self.adafruit_dht.read_retry(self.sensor, self.pin)
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
humidity, temperature = read(sensor, pin, platform)
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 80, in read
platform = get_platform()
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
raise RuntimeError('Unknown platform.')
RuntimeError: Unknown platform.
2020-07-02 17:33:39 ERROR (MainThread) [homeassistant.components.sensor] dht: Error on device update!
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 319, in _async_add_entity
await entity.async_device_update(warning=False)
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 466, in async_device_update
self.update # type: ignore
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/usr/src/homeassistant/homeassistant/components/dht/sensor.py", line 137, in update
self.dht_client.update()
File "/usr/src/homeassistant/homeassistant/util/init.py", line 239, in wrapper
result = method(*args, **kwargs)
File "/usr/src/homeassistant/homeassistant/components/dht/sensor.py", line 173, in update
humidity, temperature = self.adafruit_dht.read_retry(self.sensor, self.pin)
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 94, in read_retry
humidity, temperature = read(sensor, pin, platform)
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 80, in read
platform = get_platform()
File "/usr/local/lib/python3.7/site-packages/Adafruit_DHT/common.py", line 63, in get_platform
raise RuntimeError('Unknown platform.')
Additional information
uname -a: Linux Pi4 5.4.50-v7l+ #1324 SMP Wed Jul 1 17:06:14 BST 2020 armv7l GNU/Linux
The text was updated successfully, but these errors were encountered: