Machine RTC how to use tzinfo and unknown fields in rtc.now output

All ESP32 boards running MicroPython.
Target audience: MicroPython users with an ESP32 board.
Post Reply
brendanhoran
Posts: 1
Joined: Mon May 31, 2021 3:49 am

Machine RTC how to use tzinfo and unknown fields in rtc.now output

Post by brendanhoran » Mon May 31, 2021 6:28 am

Hi,

I am trying to make use of "rtc.init()" function to set the time, date, and timezone on my ESP32 device.

First question:
Looking at the documentation(1) I see the following:

Code: Select all

(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
However, If I specify any positive value for the field "tzinfo" the time set seems not to change/differ.
I also can not set a negative value, which seems odd.

So how can I set a timezone?

Second question:
If I use valid data and any positive integer for "tzinfo" field to set the RTC.
The output I get from "rtc.now()" confuses me.
Actual output:

Code: Select all

(2021, 5, 29, 5, 10, 40, 23, 238401)
(2021, 5, 29, 5, 11, 0, 38, 88400)
(2021, 5, 29, 5, 17, 29, 2, 578398)
(2021, 5, 30, 6, 9, 49, 12, 348377)
(2021, 5, 30, 6, 18, 35, 39, 248372)
So I read this as:
YYYY MM DD ?? HH MM SS MS

What exactly is the fourth field?

Times and dates reported were correct for my location in the above example.
I think it's defined in the source code in "machine_rtc.c" (2)
Tho I am not 100% sure

References:
(1) https://micropython-docs-esp32.readthed ... e.RTC.html
(2) https://github.com/micropython/micropyt ... hine_rtc.c

Post Reply