class RTC – real time clock
The RTC is and independent clock that keeps track of the date and time.
Example usage:
rtc = machine.RTC()
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
print(rtc.datetime())
Constructors
class machine.RTC(id=0, ...)
Create an RTC object. See init for parameters of initialization.
Methods
rtc.init(id, datetime)
Initialise the RTC. Datetime is a tuple of the form:
(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
Code: Select all
>>> rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: no such attribute
>>>
>>> rtc.datetime()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: no such attribute
>>>
Code: Select all
>>> rtc = RTC(id=0, datetime=(2015, 10, 22, 19, 9))
>>> rtc.now()
(2015, 10, 22, 19, 9, 7, 685000, None)
>>> rtc.now()
(2015, 10, 22, 19, 9, 10, 655000, None)
Code: Select all
>>> rtc.init(id=0, datetime=(2015, 10, 22, 19, 9))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: argument num/types mismatch
>>>