import time
import network
import rp2
import requests
#connect network
#rp2.country("CA")
#ssid = "TEE Home"
#psk = "Cyn816230"
#wlan = network.WLAN(network.STA_IF)
#wlan.active(True)
#wlan.connect(ssid, psk)
#while not wlan.isconnected() and wlan.status() >= 0:
# print("Waiting for Wi-Fi connection...")
# time.sleep(1)
#print(wlan.ifconfig())
#print(wlan.isconnected())
#connect_robust
rp2.country("CA")
ssid = "Wokwi-GUEST"
psk = ""
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, psk)
max_wait = 30
while max_wait > 0:
print(wlan.isconnected())
print(wlan.status())
if wlan.status() < 0 or wlan.status() >= 3:
break
max_wait -= 1
print("Waiting for Wi-Fi connection...")
time.sleep(1)
if wlan.status() != 3:
raise RuntimeError("Network connection failed")
else:
print("Connected to Wi-Fi network.")
print(wlan.ifconfig())
#requests not working since free plan does not have private gateway
response = requests.get("https://text.npr.org")
print(response.content)
#for x in response.content.splitlines():
# print(x)
response.close()Loading
pi-pico-w
pi-pico-w