Skip to content

Instantly share code, notes, and snippets.

@neosarchizo
Created November 23, 2022 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neosarchizo/bab85a5a41775e18963fce7f8e769cb4 to your computer and use it in GitHub Desktop.
Save neosarchizo/bab85a5a41775e18963fce7f8e769cb4 to your computer and use it in GitHub Desktop.
MicroPython - RPi Pico W WiFi 사용하기
from network import WLAN, STA_IF
from time import sleep
SSID = 'devicemart'
PASSWORD = 'devicemart1'
wlan = WLAN(STA_IF)
wlan.active(True)
wlan.connect(SSID, PASSWORD)
max_wait = 10
while max_wait > 0:
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print('waiting for connection...')
sleep(1)
if wlan.status() != 3:
raise RuntimeError('network connection failed')
else: # wlan.status() == 3
print('connected')
status = wlan.ifconfig()
print('ip = ' + status[0])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment