# test_VSYS_pico.py

import machine
import time

print("Example output        VBUS       VSYS")
VSYS_ADC_INPUT = 3      # 3 or 29

# Using ADC(3)  - Pin 29 needs to be set as input with no pulls.
# Using ADC(29) - Pin 29 is automatically set as required.

if VSYS_ADC_INPUT == 3:
  Pin = machine.Pin
  Pin(29, Pin.IN)
  vsysChannel = machine.ADC(3)
else:
  vsysChannel = machine.ADC(29)
  
while True:
  adcReading  = vsysChannel.read_u16()
  adcVoltage  = (adcReading * 3.3) / 65535
  vsysVoltage = adcVoltage * 3
  vbusVoltage = vsysVoltage + 0.275 # At 100mA
  print(adcReading >> 4, adcReading, adcVoltage, "|", vbusVoltage, "|", vsysVoltage)
  time.sleep(1)
# end while

#Source:https://www.raspberrypi.org/forums/viewtopic.php?t=301152
#        See near end by hippy 
# test_VSYS_pico.py