RTC
The RTC is used to keep track of the date and time.
Quick Usage Example
Constructors
class machine.RTC(id=0, ...)
Create an RTC object. See init for parameters of initialisation.
Methods
rtc.init(datetime=None, source=RTC.INTERNAL_RC)
Initialise the RTC. The arguments are:
datetime
when passed it sets the current time. It is a tuple of the form:(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
.source
selects the oscillator that drives the RTC. The options are RTC.INTERNAL_RC and RTC.XTAL_32KHZ
For example:
rtc.now()
Get get the current datetime
tuple:
rtc.ntp_sync(server, * , update_period=3600)
Set up automatic fetch and update the time using NTP (SNTP).
server
is the URL of the NTP server. Can be set toNone
to disable the periodic updates.update_period
is the number of seconds between updates. Shortest period is 15 seconds.
Can be used like:
rtc.synced()
Returns True
if the last ntp_sync
has been completed, False
otherwise:
rtc.memory([data])
Reads RTC memory contents or write data in passed Buffer in to RTC memory
Example:
Output:
Constants
Clock source:
RTC.INTERNAL_RC
,RTC.XTAL_32KHZ
Last updated