I’m often running into an issue where it seems turning on WLAN STA causes the entire board to hang. My code is very basic at this point following the wiki. Restarting the code a bunch of times, it seems like atleast 50% of the time the WLAN library crashes everything and I have to unplug.
I’ve narrowed it down to setting wlan.active(True) as where its hanging. Surrounding the code with prints shows it sometimes never gets past setting it active:
self.wlan = network.WLAN_SPI(network.STA_IF)
print('[WIFI]', 'Init')
self.wlan.active(True)
print('[WIFI]', 'Active')
This often causes it to print out ‘Init’ but never ‘Active’. Pressign the stop button in thonny tells me the backend terminated:
Unable to connect to COM3: could not open port 'COM3': PermissionError(13, 'Access is denied.', None, 5)
If you have serial connection to the device from another program, then disconnect it there first.
Backend terminated or disconnected. Use 'Stop/Restart' to restart.
Only way out of this is to unplug it and reconnect. The next time it very well may init just fine.