rtc.ntp_sync restart after 30 seconds?
-
How can it be done, that no internet connection to the time server will cause a restart after 30 seconds?
This is my current code.rtc.ntp_sync("de.pool.ntp.org")
while not rtc.synced():
machine.idle() # save power while waiting
utime.timezone(TimeDiff)
time1 = utime.localtime() # Übergabe Datum und
break
-
@Wolli01 The break in your code should simply cause an error while parsing:
SyntaxError: 'break' outside loop
-
@robert-hh Apart from the last line, what's the difference?
-
@Wolli01 SO I extended your code snippet to a short test script:
import utime import machine rtc=machine.RTC() TimeDiff = 0 rtc.ntp_sync("de.pool.ntp.org") while not rtc.synced(): machine.idle() # save power while waiting utime.timezone(TimeDiff) time1 = utime.localtime() # Übergabe Datum und print(time1)
That works, does not restart after 30 seconds, but waits forever, if not WiFi is present. I disabled WIFi by calling disconnect().
Pycom MicroPython 1.20.0.rc13 [1211d6c-dirty] on 2019-08-23; FiPy with ESP32
-
@robert-hh No there are no more loops
-
@Wolli01 So I understand that you code is:
rtc.ntp_sync("de.pool.ntp.org") while not rtc.synced(): machine.idle() # save power while waiting utime.timezone(TimeDiff) time1 = utime.localtime() # Übergabe Datum und break
So why the break at the. Is there another while loop which you do not show?