I’ve noticed that the local timestamps on my ESP32 fleet are drifting quite a bit (10s of minutes) vs. actual UTC.
In the past, the mDash device drivers would periodically sync to a network time source to correct for local drift. Now it appears this is no longer happening as evidenced by timestamps in mdash.log and a lack of any network timing synchronization events in these same logs (which used to appear in the past).
Is there something on the mdash backend that may have broken here?
OK, makes sense. Agreed that the ESP32 free-running clock definitely drifts a lot on its own.
NOTE:
There definitely is some inconsistent mDash time sync behavior when ESP32 devices reboot. If a device power-cycles then the initial NTP time sync is fine. If, however, you initiate a reboot via the mDash console then the device local time is significantly skewed on the order of 25mins or so. This is repeatable across numerous devices in our fleet.
Would you happen to have an example function call of an NTP sync? That seems like a must-have right about now.
It should be noted here that this question is not, strictly speaking, mDash related.
mDash has nothing to do with ESP32 clock drift.
Alleviating this issue is the firmware’s task, not mDash.
When a device reconnects to mDash, mDash sends a Sys.Info request. That RPC request accepts an optional parameter: utc_time. You could send that request manually. Thus, triggering device reconnect (not necessarily a reboot) should re-sync the clock.
mDash library does not currently perform periodic NTP syncs.
It seems the NTP sync updates implemented in mDash 1.2.14 are no longer working as they once were. We have observed that all of our devices in the field have an offset of 30-32 minutes vs. UTC which causes some headaches.
Can Cesanta look at this once again and see if something with NTP sync has broken?
After extensive testing, we can definitely confirm the issue is related to the mDash 1.2.14 update. If you use this version then every 2 hours or so, mDash will apply a timing offset to the local clock on your device. Even if you periodically initiate an NTP time sync mDash will override this and apply a timing offset. The exact mechanism of how this happens I will need to leave to Cesanta, but the effect is very deterministic.
If you revert back to mDash 1.2.13 this will not happen. For those of you that care about the accuracy of your local clock I’d recommend reverting as we have and occasionally call an NTP sync to account for slow ESP32 timing drift (we do this every 24 hours). This method works well and we’ve successfully implemented this on our fleet.
@lsm - Recommend that you back out your changes that you applied when you moved from 1.2.13 to 1.2.14