Note

This is the documentation for the latest development branch and may refer to features that are not available in released versions. If you are looking for the documentation for a specific release, use the drop-down menu on the left and select the desired version.

RTC Module API Manual#

Overview#

The current CanMV K230 provides an RTC (Real-Time Clock) module, which users can use to set and get the current system time.

API Introduction#

The RTC class is located under the machine module.

Example#

from machine import RTC

# Instantiate RTC
rtc = RTC()
# Get current time
print(rtc.datetime())
# Set current time
rtc.init((2024, 2, 28, 2, 23, 59, 0, 0))

Constructor#

rtc = RTC()

Parameters

None

init Method#

rtc.init(year, month, day, hour, minute, second, microsecond, tzinfo)

Parameters

  • year: Year

  • month: Month

  • day: Day

  • hour: Hour

  • minute: Minute

  • second: Second

  • microsecond: Microsecond, this parameter is ignored

  • tzinfo: Timezone, value range [-12 ~ 12]

Return Value

None

datetime Method#

print(rtc.datetime())

Parameters

None

Return Value

Returns the current date and time information, including:

  • year: Year

  • mon: Month

  • day: Day

  • wday: Day of the week

  • hour: Hour

  • min: Minute

  • sec: Second

  • microsec: Microsecond

Comments list
Comments
Log in