-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
CircuitPython version
Adafruit CircuitPython 9.2.1 on 2024-11-20; Adafruit QT Py ESP32S2 with ESP32S2Code/REPL
#===========boot.py:
import storage
storage.remount("/", readonly=False, disable_concurrent_write_protection=True)
#===========code.py:
import adafruit_connection_manager
import adafruit_ntp
import os
import time
import wifi
import rtc
wifi_ssid = os.getenv("CIRCUITPY_WIFI_SSID")
wifi_password = os.getenv("CIRCUITPY_WIFI_PASSWORD")
wifi.radio.connect(wifi_ssid, wifi_password)
pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ntp = adafruit_ntp.NTP(pool, tz_offset=1, cache_seconds=3600)
path = "/sd/hello.txt"
print(time.localtime())
print(ntp.datetime)
rtc.set_time_source(ntp)
print(time.localtime())
while True:
print(time.localtime())
with open(path, "w") as f:
f.write("hello")
stats = os.stat(path)
file_size = stats[6]
file_date = stats[9]
print("file_date:",time.localtime(file_date))
time.sleep(5)Behavior
file date is not synchronized with the system time.
code.py output:
struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=1, tm_min=0, tm_sec=14, tm_wday=5, tm_yday=1, tm_isdst=-1)
struct_time(tm_year=2024, tm_mon=12, tm_mday=28, tm_hour=21, tm_min=56, tm_sec=10, tm_wday=5, tm_yday=363, tm_isdst=-1)
struct_time(tm_year=2024, tm_mon=12, tm_mday=28, tm_hour=21, tm_min=56, tm_sec=10, tm_wday=5, tm_yday=363, tm_isdst=-1)
struct_time(tm_year=2024, tm_mon=12, tm_mday=28, tm_hour=21, tm_min=56, tm_sec=15, tm_wday=5, tm_yday=363, tm_isdst=-1)
file_date: struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=1, tm_min=0, tm_sec=18, tm_wday=5, tm_yday=1, tm_isdst=-1)
struct_time(tm_year=2024, tm_mon=12, tm_mday=28, tm_hour=21, tm_min=56, tm_sec=20, tm_wday=5, tm_yday=363, tm_isdst=-1)
file_date: struct_time(tm_year=2000, tm_mon=1, tm_mday=1, tm_hour=1, tm_min=0, tm_sec=24, tm_wday=5, tm_yday=1, tm_isdst=-1)
Description
No response
Additional information
This bug does not happen on XIAO ESP32-C3 with the same code. On XIAO ESP32-C3 there seams to be an background worker that syncronizes with ntp as soon as connection to internet is made. It does not need a manual ntp request.