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")
RPI Pico W: Pin("LED", Pin.OUT).on() crashes/hangs
My Raspberry Pi Pico W worked for a day or so (on rp2-pico-w-20221209-unstable-v1.19.1-740-gbf49a087b.uf2). Then something happened and I don't know what. The following script makes it hang/crash:
from machine import Pin
led = Pin("LED", Pin.OUT)
# all good until here
led.on()
# never reaching this line and the led stays off
If I replace "LED" with 0 it does not crash and the GPIO_0 pin becomes high as expected.
Another hint that something with the wifi module is off:
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
print(wlan.active()) # prints: 'False'
I saw #8904 but I concluded that I have another issue, since it is not related to it being connected to a Mac/Linux USB stack, the mentioned fix there does not help and I ran into it with the latest build.
For a lack of any other idea, a wild guess would be that my external power supply semi-fired it (although I examined it with an oscilloscope and everything looks as it is supposed to from what I can tell). I would appreciate any ideas for further debugging, including using my osci to peak in on the communication between the uC and the wifi module to find out if there is indeed a hardware defect.