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 #594

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Conversation

krzbor
Copy link

@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.
@IgorYbema
Copy link
Contributor

Thanks for finding that bug. I added ASYNC before indeed but I remember I didn't get the result I was expecting back then and forget about bughunting later. I'll review the code.

@Egyras
Copy link
Owner

Egyras commented Dec 10, 2024

Thanks for finding that bug. I added ASYNC before indeed but I remember I didn't get the result I was expecting back then and forget about bughunting later. I'll review the code.

Merge this pull ? :)

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.

3 participants