← index #12313Issue #5361
Duplicate · high · value 4.260
QUERY · ISSUE

ESP32: RTC().init() wrong tuple

openby socketpairopened 2023-08-27updated 2023-08-27
bug

https://docs.micropython.org/en/v1.15/library/machine.RTC.html#machine.RTC.init

image

>>> RTC().init((2023,5,6,10,20,30,0,0))
>>> localtime()
(2023, 5, 6, 20, 30, 2, 5, 126)

as you can see, hour(10) is missing when reading back from RTC.

What helps?
inserting zero after day and before hour.

>>> RTC().init((2023,5,6,0,10,20,30,0))
>>> localtime()
(2023, 5, 6, 10, 20, 31, 5, 126)

Definitely bug in ESP32 port (all ports ?), or documentation is wrong.

>>> sys.implementation
(name='micropython', version=(1, 20, 0), _machine='ESP32S3 module with ESP32S3', _mpy=10502)
CANDIDATE · ISSUE

Class RTC on ESP32 documentation bug

openby sengpwopened 2019-11-26updated 2025-10-17
docsport-esp32

RTC.datetime
Testing showed that the 8-tuple has the following format:
(year, month, dayofmonth, dayofweek (0..6, mon=0), hours, minutes, seconds, subseconds)
Not sure about the content/validity of "subseconds", cause this can be set to any value, even bigger 255.
Tested on firmware versions:
esp32spiram-idf3-20190529-v1.11.bin
esp32spiram-idf3-20191126-v1.11-607-g01e5802ee.bin

But documentation says:
Datetime is a tuple of the form:
(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
This is definitely wrong, documentation of pyb.RTC also does not match, cause there weekday is in range 1-7. Can not test this cause only ESP32 available.

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied