-
Notifications
You must be signed in to change notification settings - Fork 7.4k
driver: sensor: aosong,dht: fix sensor protocol #89753
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
driver: sensor: aosong,dht: fix sensor protocol #89753
Conversation
…ephyrproject-rtos#83192 A recent change 9eeb60c improperly removed a critical line in the driver. This commit replaces that line and moves an irq_lock to above any pin value manipulation since the timing is sensitive with the DHT protocol. This should also fix the timing issue 9eeb60c attempted to fix. Signed-off-by: John Shelton <moosery@gmail.com>
Hello @moosery, and thank you very much for your first pull request to the Zephyr project! |
@OmarNaffaa can you please check this with your board setup? Remember to enable the IRQ locks in your prj.conf and use GPIO_ACTIVE_LOW on your GPIO pin. DHT's also require either a MCU pullup (like GPIO_PULL_UP) or a pull up resistor on the data line. |
|
I was able to poll with a DHT22 every second for ~1 hour with these changes if I disable WiFi on my device, but with WiFi on I immediately get a -5 error code when trying to fetch. Since it does work with WiFi off on my board I think your fix is valid, but I would likely need to do some digging on my end to know more (maybe I'm doing something wrong on my project). |
I've tested the driver with DHT11's and DHT22's on the ESP32-Wrover, NXP MIMXRT1060-EVKB, and the Arduino Giga R1. It has executed without fail for days. However, there is some timing issue on that ESP32-Wrover board in regards to using wifi along with the DHT's (I am able to duplicate the issue that @OmarNaffaa sees when using wifi but only on the ESP32-Wrover). I believe we need to go ahead and accept this pull request to get the driver back to working for other boards, and continue to work on figuring out what is causing the problem when wifi is enabled on a separate issue. |
@MaureenHelm this PR has kind of stalled. Is it possible to get it moving again? |
Hi @moosery! To celebrate this milestone and showcase your contribution, we'd love to award you the Zephyr Technical Contributor badge. If you're interested, please claim your badge by filling out this form: Claim Your Zephyr Badge. Thank you for your valuable input, and we look forward to seeing more of your contributions in the future! 🪁 |
Fix DHT sensor protocol broken since previous change
A recent change 9eeb60c for issue #83192 improperly removed a critical line in the driver.
This commit replaces that line and moves an irq_lock to above any pin
value manipulation since the timing is critical in the DHT protocol.
This was tested with both IRQs enabled and disabled on an Arduino Giga R1 using a DHT11.
Fixes #89631
Signed-off-by: John Shelton moosery@gmail.com