import machine
import socket
import ssd1306
import network
import utime
# Configura la conexión Wi-Fi
manera de conectar
print("Connecting to WiFi", end="")
ssid = "Pantoja"
password = "$48201206"
wifi = network.WLAN(network.STA_IF)
wifi.active(True)
wifi.connect(ssid, password)
'''
print("Connecting to WiFi", end="")
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("Pantoja", "$48201206")
'''
'''
while not wlan.isconnected():
print(".", end="")
time.sleep(0.1)
print(" Connected!")
print(wlan.ifconfig())
'''
# Espera a que se establezca la conexión
while not wifi.isconnected():
utime.sleep(1)
# Configura el OLED Display
i2c = machine.I2C(scl=machine.Pin(5), sda=machine.Pin(4)) # Ajusta los pines SCL y SDA según tu conexión
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
while True:
# Obtiene la hora de Internet (PST-8)
rtc = machine.RTC()
rtc.ntp_sync("pool.ntp.org")
utime.sleep(2)
current_time = rtc.now()
# Calcula la hora en el huso horario deseado (América/Tijuana)
time_in_pst = current_time[0] + 8, current_time[1], current_time[2], current_time[3], current_time[4], current_time[5], current_time[6], current_time[7]
# Limpia la pantalla
oled.fill(0)
# Muestra la hora en el OLED Display
oled.text("Hora PST-8:", 0, 0)
oled.text("{:02d}:{:02d}:{:02d}".format(time_in_pst[3], time_in_pst[4], time_in_pst[5]), 0, 20)
oled.show()
utime.sleep(60) # Actualiza la hora cada minuto
Loading
pi-pico-w
pi-pico-w