13.ESP32-WIFI
from machine import Pin
import time
import network
led=Pin(2,Pin.OUT)
ssid="Mi10S"
password="jjh18776489677"
def wifi_connect():
wlan=network.WLAN(network.STA_IF)
wlan.active(True)
start_time=time.time()
if not wlan.isconnected():
print("WIFI connect ......")
wlan.connect(ssid,password)
while not wlan.isconnected():
led.value(1)
time.sleep_ms(250)
led.value(0)
time.sleep_ms(250)
if time.time()-start_time>10:
print("WIFI connect FAIL")
break
else:
led.value(0)
print("network information:",wlan.ifconfig())
if __name__=="__main__":
wifi_connect()