-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
Wifi not working properly in Pico W. #13370
Description
Discussed in https://github.com/orgs/micropython/discussions/13369
Originally posted by Aman2210200 January 6, 2024
Hello Enthusiasts, I am building a project on pico w and smashed with this problem of Wifi in pico w.
Let's suppose my pico w is connected to a wifi , it has the ssid & psk of the wifi. while pico w being connected to the wifi , if i change the psk of the wifi & reboot it then still pico w shows that it is connected to the same wifi but it does not have the new psk.
I did some trouble shooting & found it disconnects with the internet but its wlan.status does not changes and wlan.isconnected stays true.
this is the code i used :-
import network
import utime
SSID = "XXXX"
PSK = "XXXXX"
wlan =0
def connect_to_wifi(ssid, psk):
global wlan
Enable WiFi in Client Mode
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
Connect to WiFi, keep trying until failure or success
wlan.connect(ssid, psk)
for i in range(5):
while wlan.isconnected() == False:
wlan.connect(ssid, psk)
print(wlan.status())
print("Waiting to Connect")
utime.sleep(5)
if wlan.isconnected():
print("Connected to WiFi")
raise Exception("WiFi not available")
connect_to_wifi(SSID,PSK)
while True:
print(wlan)
if wlan.isconnected():
print(wlan.status())
print("Connected to WiFi")
utime.sleep(1)
else:
print("Wifi not available")
Can anyone help me in this , i dont know why this is happening , i tried changing the module , changing the wifi but nothing works.
But when i change the ssid instead of psk then it gets disconnected instantly.