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

Needs more explanation about usage/synchronisation #15

Open
HubKing opened this issue Dec 10, 2023 · 3 comments
Open

Needs more explanation about usage/synchronisation #15

HubKing opened this issue Dec 10, 2023 · 3 comments

Comments

@HubKing
Copy link

HubKing commented Dec 10, 2023

So.... if I call DateTime.begin() once in setup() just like the top page's example, does it periodically re-synchronise the time, or does it only do that once at begin() and never re-synchronise?

@mianos
Copy link

mianos commented Dec 31, 2023

No, seems you need to call begin() again.

unsigned long lastInvokeTime = 0;
const unsigned long dayMillis = 24UL * 60 * 60 * 1000; // Milliseconds in a day
...
// in loop()
  if (currentMillis - lastInvokeTime >= dayMillis) {
      DateTime.begin(1000);
      lastInvokeTime = currentMillis;
  }

@HubKing
Copy link
Author

HubKing commented Dec 31, 2023

How much does an ESP's timer generally deviate in a day?

@mianos
Copy link

mianos commented Dec 31, 2023

I have seen a second or so over time time.
I don't know but it is just the 'vibe' to me.

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

No branches or pull requests

2 participants