You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here's a little improvement you can do on the NTP script that I do on mine. Occasionally, the first ntptime.settime() call fails, so I retry until the year is no longer 2000.
import time
from micropython import const
NTP_MAX_RETRIES = const(10)
def get_year():
tm = time.gmtime()
return int(tm[0])
def is_synched():
# Epoch is 2000. If year is still epoch it must not yet be synched.
return get_year() > 2000
def sync():
ntptime.host = host
tries = 0
while tries < NTP_MAX_RETRIES:
tries += 1
ntptime.settime()
if is_synched():
break
else:
raise Exception('NTP max retries exceeded')
The text was updated successfully, but these errors were encountered:
Here's a little improvement you can do on the NTP script that I do on mine. Occasionally, the first ntptime.settime() call fails, so I retry until the year is no longer 2000.
The text was updated successfully, but these errors were encountered: