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 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 breakSo why the break at the. Is there another while loop which you do not show?
-
@robert-hh No there are no more loops
-
@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 Apart from the last line, what's the difference?
-
@Wolli01 The break in your code should simply cause an error while parsing:
SyntaxError: 'break' outside loop
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login