machine.RTC
Classes
Create an RTC object. See init for parameters of initialization. |
Module Contents
- class machine.RTC.RTC(id=0, *args, **kwargs)
Create an RTC object. See init for parameters of initialization.
- alarm(id, time, *, repeat=False) None
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.
- datetime(datetimetuple: Any | None = None) Tuple
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.
- init(datetime) None
Initialise the RTC. Datetime is a tuple of the form:
(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
- irq(*, trigger, handler=None, wake=IDLE) Incomplete
Create an irq object triggered by a real time clock alarm.
triggermust beRTC.ALARM0handleris the function to be called when the callback is triggered.wakespecifies the sleep mode from where this interrupt can wake up the system.
- memory(data: Any | None = None) bytes
RTC.memory(data)will write data to the RTC memory, where data is any object which supports the buffer protocol (includingbytes,bytearray,memoryviewandarray.array).RTC.memory()reads RTC memory and returns abytesobject.Data written to RTC user memory is persistent across restarts, including
machine.soft_reset()andmachine.deepsleep().The maximum length of RTC user memory is 2048 bytes by default on esp32, and 492 bytes on esp8266.
Availability: esp32, esp8266 ports.
- now() Tuple
Get get the current datetime tuple.
- ALARM0: Incomplete
irq trigger source