time() drift backwards after s/w reset

0xffff
Posts: 32
Joined: Tue Jun 19, 2018 1:53 am

time() drift backwards after s/w reset

Postby 0xffff » 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

WiFive
Posts: 2048
Joined: Tue Dec 01, 2015 7:35 am

Re: time() drift backwards after s/w reset

Postby WiFive » Tue Jun 19, 2018 2:02 pm


0xffff
Posts: 32
Joined: Tue Jun 19, 2018 1:53 am

Re: time() drift backwards after s/w reset

Postby 0xffff » Tue Jun 19, 2018 8:14 pm

Thanks - looks to be same thing we're grappling with. Will try the RTC-only scenario and see how it goes. Much appreciated.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 26 guests