This class represents the onboard Real Time Clock. It is a singleton and will always return the same instance.
The current date and time of the RTC as a
This must be set to the current date and time whenever the board loses power:
import rtc import time r = rtc.RTC() r.datetime = rtctime.struct_time((2019, 5, 29, 15, 14, 15, 0, -1, -1))
Once set, the RTC will automatically update this value as time passes. You can read this property to get a snapshot of the current time:
current_time = r.datetime print(current_time) # struct_time(tm_year=2019, tm_month=5, ...)