This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
PR2: How to use ADC channel 3/GPIO pin 29 to measure VSYS on Pico W board #10406
Comments
Have you tried the provided solution here? Looking through this thread there seems to be problems restarting the wifi modul again, after changing GPIO29 and 25 to be able to read VSYS with ADC 3 https://forums.raspberrypi.com/viewtopic.php?p=2062543&hilit=ADC+29#p2062568 |
Thank you, that recommendation worked. Test code: import machine
import sys
print("sys.implementation:{}".format(sys.implementation))
print("sys.version:{}".format(sys.version))
wl_cs = machine.Pin(25) # WiFi chip SDIO_DATA3 / gate on FET between VSYS divider (FET drain) and GPIO29 (FET source)
print("Initial WL_CS (GPIO25) state:{}".format(wl_cs))
wl_cs.init(mode=machine.Pin.OUT, value=1)
pin = machine.ADC(29)
adc_reading = pin.read_u16()
adc_voltage = (adc_reading * 3.3) / 65535
vsys_voltage = adc_voltage * 3
print("""ADC reading:{}
ADC voltage:{}
VSYS voltage:{}""".format(adc_reading, adc_voltage, vsys_voltage))
wl_cs.init(mode=machine.Pin.ALT, pull=machine.Pin.PULL_DOWN, alt=31)#try to restore initial WL_CS state and output
It means that MicroPython initializes GPIO used for WiFi module even if module is never used.
|
There is a call to initialize the cyw43 driver directly in /ports/rp2/main.c when the rp2 firmware is build with the MICROPY_PY_NETWORK_CYW43 flag.
This means, to use a WL_GPIO pin in a alternative mode, it must always be reconfigured manually |
It seems that I have not read Pico W datasheet carefully enough. There is a section about pins used for WiFi module and explanations about need to put GPIO25 high when using GPIO29 to read VSYS voltage:
RP2 port now has 15 different boards. I think there is no need to add something to MicroPhyton documentation about Pico W pin usage. Documentation chapter General information about the RP2xxx port needs section "Multitude of boards" as other ports has it:
This issue can be closed after someone will add |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
firmware: rp2-pico-w-20221220-unstable-v1.19.1-782-g699477d12.uf2
board: rp2-pico-w
version information: MicroPython v1.19.1-782-g699477d12 on 2022-12-20; Raspberry Pi Pico W with RP2040
MicroPython program
on Raspberry Pi Pico W outputs
on Raspberry Pi Pico it outputs
equivalent CircuitPython program
on Raspberry Pi Pico W (same board) it produces output
I know that on Pico-W this pin is shared with WiFi module. But I can not get correct output from Pico-W event after fresh .uf2 firmware upload with 0 WiFi module usage.
CircuitPython made special case for this pin. And it works perfectly. CircuitPython indicates active REPL with onboard LED. On Pico-W that LED is controlled by WiFi module, but event with active LED I can get ADC values from REPL prompt.
Maybe this solution can be ported to MicroPhyton?
Also it can be regression with new Pico SDK or latest changes in rp2 MicroPython port. In older forum posts I can find examples that VSYS measurement was working even while using WiFi module. But I don't know where can I get older MicroPython .uf2 files
Some related discussions:
https://forums.raspberrypi.com/viewtopic.php?t=339994
https://forums.raspberrypi.com/viewtopic.php?t=301152
The text was updated successfully, but these errors were encountered: