Raspberry Pi Pico W: WiFi connection issues after UART reads
I've had trouble getting a Pico W to connect to WiFi after the UART has
received data.
For example the code below often doesn't connect to the network if
serial data is being sent to pin 2 of the Pico (GPIO 1) when it boots.
If you remove this connection the code works as expected and connects
to the WiFi network within 10s.
Annoyingly, it's all a bit flaky: sometimes the code does work, and
sometimes it crashes with an out of memory error. The most common
outcome is that the WiFi simply fails to connect though.
If you ignore the UART until the WiFi network is connected, it all works
happily.
I'm running "MicroPython v1.19.1 on 2022-11-18."
Please does anyone have any advice for how to investigate this.
import network
import rp2
import time
from machine import UART
uart = UART(0)
for i in range(10):
print(uart.read(6))
rp2.country('GB')
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect("XXXXXX", "YYYYY")
for i in range(300):
c = wlan.ifconfig()
print(f"{i} {c}")
if c[0] != '0.0.0.0':
break
time.sleep(1)
To generate the serial data, I'm using another Pico running this code:
from machine import UART
uart = UART(0)
while True:
uart.write("Hello\n")
Pico W will not connect on WiFi
I have followed several forum threads on Pico W running MicroPython not connecting on WifI without a clear resolution.
My Pico W will get the list of available networks but will not connect.
If I run the Pico W in the Arduino Gui it works perfectly. Connects every time.
So I know the problem is not my router or the hardware of the Pico W. It must be the MicroPython support.
Any help gratefully received.