Skip to content
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

Fixed DHT timing error, Issue #5848 #6044

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seiuvwcdhol
Copy link

I fixed an error in the DHT driver which occurs if the system load is high: If there are many Python threads running, the DHT driver constantly reports a timeout error ETIMEDOUT. If the system load is low, there is no error.

The solution is to wait uninterruptable with mp_hal_delay_us_fast instead of interruptable with mp_hal_delay_ms.

As a further optimization if have added a parameter to the function dht_readinto to know if we have DHT11 or DHT22. The reason: DHT11 needs 18ms waiting after pulling the bus low, but DHT22 needs only 1-3ms waiting after pulling the bus low.

The python classes DHT11 and DHT22 have also been extended to store the DHT version in a member variable.

This solves the issue #5848 as was discussed with dpgeorge.

Stefan Hammes, Karlsruhe

@EddieParis
Copy link
Contributor

The huge problem with this is on low end targets like esp8266, if you block interrupts for such a long time you interfere with PWM, making light flashes when leds are connected (even 3ms is too much here).

On my side, since ESP8266 is not multi threaded, I took opposite approach and removed the interrupt blocking even for reading the values, to avoid these PWM issues.

So the fix you propose is perfectly fine for your issue but is a total no-go for esp 8266 (and maybe other targets ?)

Maybe it is time to differentiate dht implementations across different ports ?

@projectgus
Copy link
Contributor

This is an automated heads-up that we've just merged a Pull Request
that removes the STATIC macro from MicroPython's C API.

See #13763

A search suggests this PR might apply the STATIC macro to some C code. If it
does, then next time you rebase the PR (or merge from master) then you should
please replace all the STATIC keywords with static.

Although this is an automated message, feel free to @-reply to me directly if
you have any questions about this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants