Turning off WIFI radio on the Pico W
Discussed in https://github.com/orgs/micropython/discussions/9135
<div type='discussions-op-text'>
<sup>Originally posted by UsuallyErrored August 29, 2022</sup>
I'm trying to use an HTML server, as a temporary initial configuration UI, and then once the post request from the client is received, shut down and deep sleep. I'm chasing efficiency as this is a battery application and Im noticing that
wlan.disconnect()
wlan.active(False)
Does not shut down the radio, as I'm .07mA higher than without ever starting it during deep sleep. Doing some searching I've found that this is somewhat to be expected as the esp8266 required additional commands ( https://forum.micropython.org/viewtopic.php?t=2734 ) to be sent to completely shut off the WIFI radio. Basically I'm on the hunt for how to turn this radio off, without completely shutting down the cpu.
Greatly appreciate any time or info you might give.
</div>
The recently added
machine.lightsleep()
Doesn't seem to shutdown the radio either.
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>