WiFiへ接続する
ssid, passwordを自宅の無線LANルーターに合わせて接続します。
コード
import network
import time
def connect_to_wifi(ssid, password):
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
while not wlan.isconnected():
print('Connecting to network...')
time.sleep(1)
print('Network connected:', wlan.ifconfig())
ssid = 'your_wifi_ssid'
password = 'your_wifi_password'
connect_to_wifi(ssid, password)
参考図