-
I'm using a ESP32-S3-DEVKIT (WROOM-1 processor). My application (main.py) retrieves a Unix Epoch time from a cell tower and uses it as a call to time.localtime(cell_epoch) in order to set the processor time. Then I use the 8-tuple from time.localtime() later in my program. I do realize that the cell tower time is based from 1970 and micropython uses 2000, so I do a correction before setting the local clock. If I load the code and execute it using the green RUN button in Thonny everything works fine. When I call time.localtime() I get the correct date and time. The problem happens when I cold boot the program using a power cycle, time.localtime() returns Jan 1, 2000, 0:0:0. I'm obviously missing some startup code the Thonny is executing when I use the REPL interface. Any ideas how I fix this? This is the startup output from micropython: Thanks Kevin |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
My understanding is that rshell and Thonny will get the local time from the PC and use that. Get time from a cell tower? Are you using NTP or is there some other method? If that is all you see after a power-on reset then you need some print statements to tell if something else is happening. Or, show us the script that you use to connect to the cell tower and get the time. |
Beta Was this translation helpful? Give feedback.
Figured it out. I need to use the following call to set the internal clock:
rtc.datetime(time.localtime(cell_clock - SECONDS_1970_TO_2000))
After that time.localtime() returns the current time.
Thanks
Kevin