from machine import Pin, SoftI2C from lcd_api import LcdApi from pico_i2c_lcd import I2cLcd from time import sleep from random import randint from network import WLAN, STA_IF I2C_ADDR = 0x27 filas = 2 columnas = 16 i2c = SoftI2C(scl=Pin(22), sda=Pin(21), freq=10000) lcd = I2cLcd(i2c, I2C_ADDR, filas, columnas) wlan = WLAN(STA_IF) wlan.active(True) ssid = 'Tu SSID' password = 'Tu password WiFi' def conectar(): contador = 0 while not(wlan.isconnected()) and contador < 10: wlan.connect(ssid, password) contador += 1 lcd.clear() sleep(2) while True: lcd.move_to(0, 0) if wlan.isconnected(): lcd.putstr('IP: '+wlan.ifconfig()[0]) else: lcd.clear() lcd.putstr('DESCONECTADO') conectar() sleep(2)