from network import WLAN, STA_IF
from time import sleep_ms, localtime
from ntptime import settime
from machine import Timer
rede=WLAN(STA_IF)
rede.active(True)
rede.active(True)
if not rede.isconnected():
rede.connect('Wokwi-GUEST','')
tentativas= 0
while not rede.isconnected() and tentativas <20:
sleep_ms(500)
tentativas +=1
tim = Timer(0)
taNaHora = False
def atualizaRelogio(t):
global taNaHora
taNaHora = True
settime()
print(rede.ifconfig())
tim.init(period=6000, mode=Timer.PERIODIC, callback=atualizaRelogio)
while True:
if taNaHora:
print('hic')
taNaHora = False
sleep_ms(1000)
print(localtime())