Time and RTC auto sync?

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
Post Reply
ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Time and RTC auto sync?

Post by ajie_dirgantara » Fri Jul 14, 2017 9:15 am

Ok, what I want to share here is not a question to a problem, but more like a wonder. After connecting VBAT using battery and reboot micropython in NUCLEO board, when I try :

>>> time.localtime()
(2017, 7, 14, 16, 6, 22, 4, 195)

>>> pyb.RTC().datetime()
(2017, 7, 14, 5, 16, 7, 27, 239)

it return current time and date. problem is, I've NEVER set it before. How can the time is auto synced with current time? what kind of sorcery is this? :lol:

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Time and RTC auto sync?

Post by ajie_dirgantara » Fri Jul 14, 2017 9:30 am

Ok after do a bit investigation, the RTC is synced to my PC date time after connecting through REPL. neat! but might be troublesome in case the REPL host current date and time is incorrect/tampered with. will look at how to disable this auto sync feature and use manual sync. any pointers?

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: Time and RTC auto sync?

Post by pythoncoder » Fri Jul 14, 2017 12:08 pm

How are you connecting? Dave Hylands' rshell does this, partly to ensure that file datetimes are correct for synchronisation.

To avoid this behaviour connect with a terminal application. Result: no sorcery ;)
Peter Hinch
Index to my micropython libraries.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Time and RTC auto sync?

Post by dhylands » Fri Jul 14, 2017 4:56 pm

If you're using rshell, there currently isn't a command line option to disable the time sync. You can comment out this line:
https://github.com/dhylands/rshell/blob ... n.py#L1271
and that will cause rshell to no longer sync the time on the device.

ajie_dirgantara
Posts: 81
Joined: Fri Sep 02, 2016 9:26 am

Re: Time and RTC auto sync?

Post by ajie_dirgantara » Sat Jul 15, 2017 5:53 am

Yes, I am connect to the board using rshell..

thanks!

Post Reply