VBUS_DETECT and BAT_SENSE on the new Pico Lipo

doing a dir(board) after importing board gives the list of pins on the new PICO LIPO, two in particular VBUS_DETECT and BAT_SENSE are not exactly clear to me

I assume VBUS_DETECT is a digital input, but what about BAT_SENSE?

Testing with CircuitPython on USB power with no battery connected:

import board
import digitalio
import analogio

import time

vbus_detect = digitalio.DigitalInOut(board.VBUS_DETECT)
vbus_detect.direction = digitalio.Direction.INPUT

bat_sense = analogio.AnalogIn(board.BAT_SENSE)

while True:
    time.sleep(0.5)
    print(bat_sense.value, vbus_detect.value)

Sample output

28496 True
28544 True
28512 True
28544 True
28544 True
28560 True
28512 True
28544 True
28576 True
28544 True
28544 True
28544 True
28544 True

VBUS_DETECT is digital only, it raised an exception when I tried to configure it as an analog pin.

I haven’t tried to figure out the calibration on the BAT_SENSE and I can’t quickly find a reference online.

I think from what i have seen the voltage will be bat_sense.value * 3.3/65535

that will give a voltage from a divider circuit as the battery charge voltage will be higher than 3.3v, have seen a factor of 3 mentioned, and when i measured my battery voltage at 3.87v the bat_sense.value was reading 25800, so (25800 * 3.3/6535) * 3 = you end up with 3.89v - close enough - if all the assumptions i’ve made are correct