Hi lguapo,
The battery connected to the JST connector on the XIAO_Expansion_Board is not connected to the XIAO port, so the voltage cannot be read. The modification in the link below #1 allows you to read the battery voltage with analonRead(A0).
“XIAO nRF52840(mbed) 1-Central 2-Peripherals Project "Sleeping Posture, Heart rate, Pulse oximetry Monitor"”
The battery voltage connected to the pad on the back side of XIAO can be read with analogRead(P0_31) or analogRead(PIN_VBAT). However, when using Board Service Package:“Seeed nRF52 mbed-enable Borads 2.9.1”, the patch in this post #31 is required; when using “Seeed nRF52 Boards 1.1.1”, no patch is required.