Pymate-RealTime-Clock
RealTime Clock
The microcontroller have a real time clock using a dedicated crystal at 32.768 KHz and external coin cell.
The coin cell maintain the internal clock up to date when the Core is unpowered.
Read RTC time
Use the MicroPython RTC class to access RTC date and time.
Key-in the following line into the REPL session to get the current date and time.
from machine import RTC
rtc = RTC()
current = rtc.datetime()
print( current ) # Displays datetimetuplewhich produce the following results
(2026, 5, 4, 0, 0, 3, 58, 902343)
The datetimetuple contains the following information:
- year
- month
- day
- day-of-week (0=Monday .. 6=Sunday)
- Hour (0..23)
- Minutes
- seconds
- subseconds (the meaning is hardware dependent).
As stated in the printed tuple, it is right now May 4, 2026 at 00:03:58
Update RTC time
The clock can be be reconfigured in 3 differents way:
- with Thonny IDE
- with MPRemote tools
- with MicroPython instructions
Thonny IDE
Connecting the shell pane to Pymate REPL will automatically initialize the Pymate RTC with computer time.
MPRemote tool
If you have installed the MPRemote command line tool on your computer, the Pymate RTC can be initialized with computer time.
Use the following command line:
mpremote connect /path/to/com_device rtc --set
MicroPython code
Need to change the RTC datetime from REPL?
Just define the datetime to set in an initialized datetimetuple then set the RTC time.
The day-of-the-week and subseconds doesn't need to be accurate when setting a new datetime, the RTC will fix it.
from machine import RTC
rtc = RTC()
new_time = (2026, 5, 5, 0, 13, 45, 30, 0)
rtc.datetime( new_time ) # Update the RTC clockDoc & limitation
MicroPython documentation on machine.RTC class mention additional functions.
Most of those additional features are not available to Pymate.
The following are available:
- calibration : for tuning clock compensation. May be useful when running into hot or cold area.
- wakeup : used with sleep mode to wakeup the microcontroler.
PymateIO all right reserved © 2026 - Written by MCHobby for PymateIO