XIAO BLE Sense battery level and charging status

4096 : this is the range limit of the 12-bit ADC (so 0=0% and 4095=100%) . (Although I think the code should use 4095 not 4096? :thinking: )

3.3 : this is supposed to correspond to the reference voltage being used by the ADC here, i.e. 100% on ADC corresponds to 3.3v on the analog input pin. Although as I understood it the default vref is actually 3.6v . So readings will be wrong if you have the wrong value here.

510 and 1000 correspond (as noted in the comments in the earlier source code) to the voltage divider in the Xiao schematic (built-in), which lies between the battery output, the vbat pin, and ground. According to the schematic, there’s 1 M Ohm (1000 K Ohm) to battery, and 510K Ohm to ground