← index #12313PR #10607
Likely Duplicate · high · value 3.277
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 · PULL REQUEST

ports/RTC: Attempt to reduce the inconsistencies between the port's RTC implementation.

mergedby robert-hhopened 2023-01-28updated 2024-12-20
portsdocs

This PR follows the issue #10578 and #5553 and other discussions about the topic. It consists of the commits:

  • docs/quickref: Fix the documentation of rtc.datetime(), which makes the documentation of rtc.datetime() consistent to the implementation for all ports.
  • mimxrt/machine_rtc.c: Drop rtc.now() Keep it at the WiPy port for legacy,
  • ports/RTC: Rework the availability and interface of rtc.init(), which drops rtc.init() from the SAMD port and makes it consistent to the documentation and the WiPy port for the ports ESP32 and MIMXRT. But rtc.init() could as well be dropped for the latter ones and just kept for WiPy.

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