from network import WLAN, STA_IF
from time import localtime, sleep_ms
from ntptime import settime
rede = WLAN(STA_IF)
rede.active(True)
if not rede.isconnected():
rede.connect('Wokwi-GUEST','')
tentativas = 0
while not rede.isconnected() and tentativas <= 20:
sleep_ms(200)
tentativas += 1
ts = localtime()
print(ts)
try:
if rede.isconnected():
settime()
except OSError as e:
print ("Deu ruim")
print (e)
ts = localtime()
print(ts)