Open SDMatt2020 opened 1 year ago
I forgot to mention. I've tried this with no resister, a 5K resister, and a 10K resistor (as the pull up). I've also tried running this at 3.3 and 5 volts, as I came across a post somewhere that suggested the DHT22 might run better at 5v.
Looks like the delayMicroseconds function is the problem.
https://forum.seeedstudio.com/t/ds18b20-temperature-sensor-issue/263525
Try adding this to your config:
external_components:
- source: github://Mat931/esphome@rp2040-dht-fix
components: [ dht ]
refresh: always
Looks like the delayMicroseconds function is the problem.
https://forum.seeedstudio.com/t/ds18b20-temperature-sensor-issue/263525
Try adding this to your config:
external_components: - source: github://Mat931/esphome@rp2040-dht-fix components: [ dht ] refresh: always
Thanks, but that didn't help.
Thanks for testing. I'm still waiting for my Pico W. Once it arrives I can take a look with the logic analyzer
My Pico W just arrived and it can read the DHT22 (AM2302) sensor just fine, both with and without the "fix". I'm using a 10k pull-up resistor.
I wonder if there's some manufacturing variance in the DHT22s, and perhaps the micropython library is more forgiving. I'll also put a meter on the resister to verify its resistance, but I doubt the resistor is the issue here.
Where did you get your DHT22? If it's a generic Amazon/AliExpress part can you post a link (unless that's against some Github policy)?
Sorry, my sensor is at least 5 years old and I have no clue where I bought it. I can do some more testing with MicroPython vs. ESPHome later. By the way I saw the same error message for a while and thought I reproduced the issue but turns out the sensor didn't make good contact to the wires.
MicroPython: (18ms delay)
ESPHome: (0.8ms delay)
In MicroPython there's a longer delay before the data is transmitted
@SDMatt2020 Can you try configuring other DHT models in yaml? Available models are: DHT11, DHT22, DHT22_TYPE2, AM2302, RHT03, SI7021
I just tried all those models without success.
At this point I'm planning on buying some more sensors. I'm betting there's something weird about these DHT22s that I have. I have an application that should work fine with the cheaper DHT11s, so I plan on buying some from a reputable seller in hopes they'll work with ESPHome.
The current DHT22s I have were sold under the DWEII brand name. They are 3 pin sensors, rather than the 4 pin that you commonly see from sellers like adafruit.
I'm thinking this is related to manufacturing differences vs. delay before data transmission. Some sensors "wake up" quickly, while others are slow.
I just tested my DHT11 with micropython, and it wouldn't work. I added a 2 second delay after creating the sensor object, and it worked normally. I haven't found a way to add a delay using esphome, so my testing has come to a halt.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Seems like it's still issue. Works file with micropython library but but throwing error on esphome. though.
The problem
My pi pico w isn't getting data from a DHT22. If I put micropython on the pi pico w, it reads the sensor as expected.
This is on ESPHome 2023.6.2
Which version of ESPHome has the issue?
2023.6.2
What type of installation are you using?
Home Assistant Add-on
Which version of Home Assistant has the issue?
2023.6.3
What platform are you using?
RP2040
Board
pi pico w
Component causing the issue
dht sensor
Example YAML snippet
Anything in the logs that might be useful for us?
Additional information
here's the micropython code I used to check the functionality of the setup
from machine import Pin from time import sleep import dht
sensor = dht.DHT22(Pin(5))
while True: try: sleep(1) sensor.measure()
Retrieves measurements from the sensor