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

Asynchronous 1-wire reading #1

Merged
merged 1 commit into from
Nov 30, 2024
Merged

Asynchronous 1-wire reading #1

merged 1 commit into from
Nov 30, 2024

Conversation

krzbor
Copy link
Owner

@krzbor krzbor commented Nov 30, 2024

Currently, 1-wire is read synchronously, which means the program is paused for up to 750ms. During this pause, a yield is called, ensuring that WiFi works correctly. However, other issues may arise, such as UART read buffer overflow. I have modified the code so that everything operates asynchronously. The previous solution to this problem contained a bug:
if ((DALLASASYNC) && ((unsigned long)(millis() - dallasTimer) > ((1000 * dallasTimerWait) - 1000)) ) {
DS18B20.requestTemperatures(); // get temperatures for next run 1 second before getting the temperatures (async)
}
The author assumed the code would execute only once, while in reality, it was executed multiple times per second before the reading.

Currently, 1-wire is read synchronously, which means the program is paused for up to 750ms. During this pause, a yield is called, ensuring that WiFi works correctly. However, other issues may arise, such as UART read buffer overflow.
I have modified the code so that everything operates asynchronously.
The previous solution to this problem contained a bug:
  if ((DALLASASYNC) && ((unsigned long)(millis() - dallasTimer) > ((1000 * dallasTimerWait) - 1000)) ) {
    DS18B20.requestTemperatures(); // get temperatures for next run 1 second before getting the temperatures (async)
  }
The author assumed the code would execute only once, while in reality, it was executed multiple times per second before the reading.
@krzbor krzbor merged commit 52238fa into master Nov 30, 2024
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant