New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pico W - Issue with LED & Wifi Module control #10248
Comments
That is probably related to the fact, that the LED is connected to the WiFi module. So the question is more, what happens at the WiFi module if it is switched on and off in a row. |
Yes absolutely. I believe that it causes intermittent issues with other pins/functionality also, for example the ADC seems affected and gives sporadic results, however the LED is the easiest example to prove the bug. |
Digging a little bit though the code, you should use wlan.active(True) and wlan.active(False) to switch WiFi on and off. That includes the other activities to make the WiFi module's state reliable. |
So, i've read that in order to put the Pico into machine.deepsleep, you need to turn off the wifi module (pin 23), I haven't tested this just yet, but that's my thinking behind turning off the pin and not simply deactivating it with wlan.active(False). Secondly, in order to read the vsys voltage (with ADC3) you must set "machine.Pin(29, machine.Pin.IN", which also comprises part of the wireless module (communication/SPI). Which causes this weird buggy error. So I think that basically setting any of the following pins to low/IN (and back to high/OUT when needed) will cause the wifi module to break and will crash the code, sometimes entirely 'bricking' the pico until you upload a flash_nuke.uf2.
here is an exerpt from the datasheet which might explain to someone who understands it better than I do:
|
The code behind wlan.active() switches GPIO23 as well, in addition to other housekeeping actions. The SPI transfer to the CYW43 module is done with the PIO. The GPIO24, GPIO25, and GPIO29 are assigned as being controlled by the PIO. So you cannot use them for other purposes, unless your re-init the WiFI module, which seems to be done by calling wlan.active(True). |
OK, I've solved it, with robert-hh's help, thank you. There were two issues, pin 29 and pin 23. For anyone reading this, the solution was: Example below:
In addition to this, Pin 23 should be set to pin_23.low() before putting the Pico W into machine.deepsleep. Using just (wlan.active(False)) does not stop the WiFi module power draw during deepsleep. If you don't use pin_23.low() then the Pico W draws about 21mA while deepsleeping. I have been unable to use the LED again after setting pin_23 to low, even after setting the pin back to high, the LED does not work. The only solution to this is a machine.reset() OR a machine.deepsleep(1000) |
When setting pin 23 to low and high (or IN and OUT) during a script (wifi module on and off), the LED control is lost and the script often fails completely.
Example below will run once, then crash.
The text was updated successfully, but these errors were encountered: