from rede import Rede
from time import localtime, sleep_ms, time
from ntptime import settime
from machine import Pin, I2C
from ssd1306 import SSD1306_I2C
i2c = I2C(0, scl=Pin(9), sda=Pin(8))
disp = SSD1306_I2C(128, 64, i2c)
def diaSemana(d):
if d == 0:
return 'Seg'
elif d == 1:
return 'Ter'
elif d == 2:
return 'Qua'
elif d == 3:
return 'Qui'
elif d == 4:
return 'Sex'
elif d == 5:
return 'Sáb'
elif d == 6:
return 'Dom'
else:
return ' '
r = Rede('Wokwi-GUEST', '', conecta=False)
r.conectar(tentativas=40, intervalo=500)
ts = localtime()
print(ts)
if r.conectado:
settime()
while True:
t = localtime(time()-3*3600)
data = f'{t[2]}/{t[1]}/{t[0]}'
hora = f'{t[3]}:{t[4]}:{t[5]}'
dia = diaSemana(t[6])
print(data)
print(hora)
print(dia)
disp.text(data, 10, 10)
disp.text(hora, 10, 20)
disp.show()
sleep_ms(1000)
Loading
aitewinrobot-esp32c3-supermini
aitewinrobot-esp32c3-supermini