datetime / localtime

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
User avatar
MostlyHarmless
Posts: 147
Joined: Thu Nov 21, 2019 6:25 pm
Location: Pennsylvania, USA

Re: datetime / localtime

Post by MostlyHarmless » Mon Dec 16, 2019 2:56 pm

pythoncoder wrote:
Wed Dec 11, 2019 8:48 am
It is rather rudimentary. If you felt like writing an improved version and hosting it on GitHub I'm sure there would be quite a few takers.
It is indeed.

I'll start separate threads discussing details of that effort.


Regards, Jan

jedie
Posts: 247
Joined: Fri Jan 29, 2016 12:32 pm
Contact:

Re: datetime / localtime

Post by jedie » Mon Dec 16, 2019 4:36 pm

MostlyHarmless wrote:
Tue Dec 10, 2019 2:30 am
completely ignores fractional seconds,
The RTC on the ESP8266 (Maybe on other board, too?) is totally inaccurate. That's why i think the precision of ntp sync is totally sufficient.
Or do i see it wrong?

User avatar
MostlyHarmless
Posts: 147
Joined: Thu Nov 21, 2019 6:25 pm
Location: Pennsylvania, USA

Re: datetime / localtime

Post by MostlyHarmless » Mon Dec 16, 2019 5:56 pm

jedie wrote:
Mon Dec 16, 2019 4:36 pm
MostlyHarmless wrote:
Tue Dec 10, 2019 2:30 am
completely ignores fractional seconds,
The RTC on the ESP8266 (Maybe on other board, too?) is totally inaccurate. That's why i think the precision of ntp sync is totally sufficient.
Or do i see it wrong?
If you only intend to sync the internal clock at boot time and leave it at that, then that is certainly true.

I didn't measure an ESP8266 yet, but the ESP32 I have on the desk right now is gaining 37us per second on average. "inaccurate" is one word for that. I believe that micropython on the ESP32 is using one of the 8MHz XTAL based clock sources by default. Switching to the internal 150kHz oscillator makes things worse.

The ESP32 at least implements adjtime(3) (see viewtopic.php?f=18&t=7403). With that I can keep the internal clock accurate enough for my taste. A maximum difference of 370us is good enough for me, considering that a single threaded system using uasyncio cannot guarantee sub millisecond scheduling of tasks anyway.

So now that I can sync the thing to a DS3231 within less than a millisecond, I want better precision than 1 second from NTP. I'm working on that.


Regards, Jan

Post Reply