New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtc - ntp with tz handling leads to error #130

newmindJP opened this Issue Apr 20, 2018 · 3 comments


None yet
2 participants

newmindJP commented Apr 20, 2018

after connecting to WiFi I try following code:

from machine import RTC
rtc = RTC()
rtc.ntp_sync(server="", tz="CET-1CEST-2")

This leads to error -> ValueError: tz string length must be 3 - 64
I tried several options, but when ever I set a tz it leads to this error

after checking the code in file "MicroPython_BUILD/components/micropython/esp32/machine_rtc.c" I guess the problems relates to line 333
if ((strlen(tzs) < 2) && (strlen(tzs) < 64)) {
the correct code has to be
if ((strlen(tzs) > 2) && (strlen(tzs) < 64)) {


This comment has been minimized.


loboris commented Apr 21, 2018

Yes it is a bug. Thank you for noticing that.
I'll fix it in the next update.

Until fixed, you can set the ime zone with"CET-1CEST-2")
and use rtc.ntp_sync(server="") without setting the time zone.

That way the time zone is saved to NVS and will be restored after reset, power off or deepsleep wake up, so you have to set it only once.


This comment has been minimized.

newmindJP commented Apr 21, 2018

thanks for the fast reply and info about the workaround - I'll do it in that way until it is fixed ...


This comment has been minimized.


loboris commented May 14, 2018

It was fixed in the latest update.

@loboris loboris closed this May 14, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment