WLAN functions fail on Pico Pi W core1
Reproducible on 1.20 and latest nightly build (as of today)
Attempting to set up the Wifi module on core1 fails at the line ap.active(True) below which hangs. Code works fine on core0
Guarding code with a lock does not resolve the issue.
ssid = 'MicroPython-AP'
password = '123456789'
ap = network.WLAN(network.AP_IF)
ap.config(essid=ssid, password=password)
print("status = ", ap.status())
ap.active(True)
print(ap.ifconfig())
Wifi not working properly in Pico W.
Discussed in https://github.com/orgs/micropython/discussions/13369
<div type='discussions-op-text'>
<sup>Originally posted by Aman2210200 January 6, 2024</sup>
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.</div>