← index #12313Issue #5733
Related · high · value 3.513
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

machine.RTC.init documentation is incorrect

openby dhylandsopened 2020-03-07updated 2022-10-18

The machine.RTC documentation has some discrepancies.

The ESP8266 machine.RTC modules doesn't appear to have an init function, but rather has a datetime function.
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/esp8266/machine_rtc.c#L127
The order of the arguments to datetime appears to be (year, month, day, wday, hour, minute, seconds, milliseconds)

The ESP32 machine.RTC module
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/esp32/machine_rtc.c#L87
has an init function and a datetime function. The order of the arguments for datetime and init appears to be (year, month, day, hour, minute, seconds, microseconds)

The stm32 machine.RTC module forwards to pyb.RTC
https://github.com/micropython/micropython/blob/8db5d2d1f13aa6413be11bc13c94df72296a0070/ports/stm32/rtc.c#L515
which has an init function and datetime function, but the init function doesn't take any srguments. The datetime function appears to use the order (year, month, day, wday, hour, month, seconds, microseconds)

The documentation documents an init function with arguments in a different order to any of the above and doesnt't mention a datetime function.

And the EPS8266 appears to take milliseconds as the last argument, whereas the others take microseconds.

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