Measuring Battery Voltage

To measure the battery voltage with the BBC micro:bit follow these steps:

1-  Create a program with an  Analog Read Pin P0 block and upload it to the micro:bit. This puts P0 in analog input mode.

2-  Connect a jumper from Battery Voltage Monitor on the Solar Battery to the P0 input on the micro:bit.

3- Create a program that will loop on analog read P0 and printout the results. The reading will be between 0 and 1024

4- The battery voltage will be  equal  to    (( 3.19V ÷ 1024) x 2.4 x reading). For example a 3.7V battery will give a reading of 495.

Notes: 3.19V =( micro:bit A\D reference voltage)  = (Solar Battery Voltage 3.3V – drop in the micro:Bit regulator). If the battery is discharged below 3.45 volts, measure the voltage on the micro:bit 3V terminal to determine the correct value.