/*ADC channel 3 reads the internal VSYS voltage through a built-in 1/3 voltage divider.
The raw ADC value (0-4095) converts to an internal voltage between 0V and 3.3V.
Multiply by 3 to get the actual VSYS supply voltage.
GPIO29 is not exposed externally; this input is internal only.
Use this to monitor the board’s input power voltage programmatically.*/
#include "pico/stdlib.h"
#include "hardware/adc.h"
#include <stdio.h>
int main() {
stdio_init_all();
adc_init();
// GPIO29 is ADC input 3 (VSYS voltage monitor) - not physically exposed
adc_select_input(3);
while (true) {
uint16_t raw = adc_read();
// Convert ADC reading to voltage - scale depends on internal divider
// VSYS voltage connected via 1/3 voltage divider internally
float vsys_voltage = (raw * 3.3f / 4095) * 3;
printf("Raw ADC: %d, VSYS Voltage: %.3f V\n", raw, vsys_voltage);
sleep_ms(1000);
}
}