-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
I have a setup with Pico W + pimoroni lipo shim.
I am trying to run it on batteries, measure some sensors and submit the data via wifi.
I am also trying to check battery status from time to time to get an idea when charging is needed. There is a micropython example here, but I found that this also does not work for Pico W.
I also looked on this forum thread where others also struggle with doing this with python in combination with using WIFI.
https://forums.raspberrypi.com/viewtopic.php?p=2078340#p2078340 (my username = Darkness)
I am trying to accomplish this using the SDK.
From the datasheet:
`GPIO29 OP/IP wireless SPI CLK/ADC mode (ADC3) to measure VSYS/3
GPIO25 OP wireless SPI CS - when high also enables GPIO29 ADC pin to read VSYS
WL_GPIO2 IP VBUS sense - high if VBUS is present, else low
Due to pin limitations, some of the wireless interface pins are shared. The CLK is shared with VSYS monitor, so only
when there isn’t an SPI transaction in progress can VSYS be read via the ADC. The Infineon CYW43439 DIN/DOUT and
IRQ all share one pin on the RP2040. Only when an SPI transaction isn’t in progress is it suitable to check for IRQs. The
interface typically runs at 33MHz`
So it is clear that due to pins being shared with the wifi chip, it is not possible to measure VSYS using GPIO29+GPIO25.
- is there a way to know if an SPI transaction is in progress or not to make sure an ADC3 measurement can be done?
- Is there a reliable way to repeatedly enable and disable wifi to make GPIO29 and GPIO25 available? I tryied calling cyw43_arch_deinit() but afterwards cyw43_arch_init() seems to fail and hang the pico.
- is cyw43_arch_gpio_get(2); the correct way to read WL_GPIO2/VBUS sense? pico_w.h does not contain a definition for these pins, unlike the #define CYW43_WL_GPIO_LED_PIN 0
This seems like a very common use case, so an example would be very useful for the community.