date time system

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
User avatar
nebenzahl
Posts: 26
Joined: Mon Jul 01, 2019 5:38 pm
Location: Uruguaiana, Brazil
Contact:

date time system

Post by nebenzahl » Thu Jul 11, 2019 7:53 pm

Hello!
I'm in the development phase of a project so I print the date time each time I reboot my device with the print command (time.localtime ()). And sometimes comes the result (2000, 1, 1, 0, 0, 4, 5, 1) which is the starting time date. But sometimes I get the correct correct date time. However I did not do anything to set this system time. Where does my ESP32 get this time? Is it safe to use it?
Eng. Luiz Nebenzahl

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

Re: date time system

Post by pythoncoder » Fri Jul 12, 2019 8:27 am

What IDE or development environment are you using? Perhaps that is setting the time. Note that the RTC will continue to run through a reboot.

The simple way to set the time is to acquire internet connectivity and run ntptime which gets time from an NTP server:

Code: Select all

import ntptime
ntptime.settime()
Peter Hinch
Index to my micropython libraries.

User avatar
nebenzahl
Posts: 26
Joined: Mon Jul 01, 2019 5:38 pm
Location: Uruguaiana, Brazil
Contact:

Re: date time system

Post by nebenzahl » Fri Jul 12, 2019 11:48 am

Yes, I understand that.
I use vscode.
I was curious because I do not use any way to update the time, however, suddenly the time is correct.
I can not imagine what makes the time right.
In this project I use the time directly from the satellite. and in the device the time is not important.
Eng. Luiz Nebenzahl

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

Re: date time system

Post by dhylands » Fri Jul 12, 2019 2:48 pm

If you happen to be using rshell, it sets the time of the board to match the time of the PC.

User avatar
nebenzahl
Posts: 26
Joined: Mon Jul 01, 2019 5:38 pm
Location: Uruguaiana, Brazil
Contact:

Re: date time system

Post by nebenzahl » Sat Jul 13, 2019 1:26 pm

Yes, that's it, I use rshell.
Great deduction.
Thanks for listening.
Really Thank you so much!
Eng. Luiz Nebenzahl

Post Reply