I've got an app (NightDriverLED.com) that relies on syncing time amongst multiple ESP32s via NTP. I've found they cam remain accurate to 1/1000000th of a second (0 microseconds) over 30 minutes, but sometimes, something happens that they shift several seconds, like 6.
I have no idea what causes it. I "fix" it by checking NTP time periodically, but it's still weird, and was wondering if anyone knows what might play havoc with the clock as reported by gettimeofday()?
Thanks!
Dave
Clock skew
Re: Clock skew
Thanks, ChatGPT!
But I'm embarassed to say my bug was a floating point precision issue. I had a stray float in my time_t -> double calculation, and when SECONDS was large enough, the fractional MICROSECONDS was being discarded, and was internally always zero. That's why it always matched!
So... my bug.
Thanks!
Dave
But I'm embarassed to say my bug was a floating point precision issue. I had a stray float in my time_t -> double calculation, and when SECONDS was large enough, the fractional MICROSECONDS was being discarded, and was internally always zero. That's why it always matched!
So... my bug.
Thanks!
Dave
-
- Posts: 9765
- Joined: Thu Nov 26, 2015 4:08 am
Who is online
Users browsing this forum: No registered users and 148 guests