class RTC – real time clock¶
The RTC is an independent clock that keeps track of the date and time.
rtc = machine.RTC() rtc.datetime((2020, 1, 21, 2, 10, 32, 36, 0)) print(rtc.datetime())
Create an RTC object. See init for parameters of initialization.
Get or set the date and time of the RTC.
With no arguments, this method returns an 8-tuple with the current date and time. With 1 argument (being an 8-tuple) it sets the date and time.
The 8-tuple has the following format:
(year, month, day, weekday, hours, minutes, seconds, subseconds)
The meaning of the
subsecondsfield is hardware dependent.
Initialise the RTC. Datetime is a tuple of the form:
(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
Get get the current datetime tuple.
Resets the RTC to the time of January 1, 2015 and starts running it again.
alarm(id, time, *, repeat=False)¶
Set the RTC alarm. Time might be either a millisecond value to program the alarm to current time + time_in_ms in the future, or a datetimetuple. If the time passed is in milliseconds, repeat can be set to
Trueto make the alarm periodic.
Get the number of milliseconds left before the alarm expires.
Cancel a running alarm.
irq(*, trigger, handler=None, wake=machine.IDLE)¶
Create an irq object triggered by a real time clock alarm.
handleris the function to be called when the callback is triggered.
wakespecifies the sleep mode from where this interrupt can wake up the system.