time() drift backwards after s/w reset
Posted: Tue Jun 19, 2018 2:03 am
Hi,
I'm building on ESP32 (v0) w/o external xtal. On h/w reset we sync time to NTP server, but I find that after s/w reset, the time() reading is often quite off, sometimes by 6 or 7 minutes if the board has been up for a long time. Specifically, I print out the time() value just before esp_reset(), e.g. 1526923411 and then immediately after boot, e.g. 1526923378, and the latter is sometimes even a few hundred below the former (i.e. in the past).
It seems that shortly thereafter, it syncs back w/ NTP and the ship rights itself, but any messages we send during this interval have the wrong time. What could be causing this, and how can it be avoided? My reading is that the RTC is calibrated on boot and I have seen some posts that talk about significant drift, but didn't quite understand how it is addressed, if at all.
Thanks
I'm building on ESP32 (v0) w/o external xtal. On h/w reset we sync time to NTP server, but I find that after s/w reset, the time() reading is often quite off, sometimes by 6 or 7 minutes if the board has been up for a long time. Specifically, I print out the time() value just before esp_reset(), e.g. 1526923411 and then immediately after boot, e.g. 1526923378, and the latter is sometimes even a few hundred below the former (i.e. in the past).
It seems that shortly thereafter, it syncs back w/ NTP and the ship rights itself, but any messages we send during this interval have the wrong time. What could be causing this, and how can it be avoided? My reading is that the RTC is calibrated on boot and I have seen some posts that talk about significant drift, but didn't quite understand how it is addressed, if at all.
Thanks