XIAO BLE Sense battery level and charging status

I tried to fix the code.
I haven’t used XIAO BLE yet, so I’m not sure if the code below works.

void setup(){
pinMode(P0_14, OUTPUT);
digitalWrite(P0_14,LOW);
// pinMode(P0_31, INPUT);
}

void loop(){
unsigned int TempV = analogRead(P0_31); // Read AD to unsigned integer
float BatV = TempV * 510 / 1510 * ADresolution; // “Adresolution” must be define
}