• The MDBT42Q breakout?

    Unfortunately the problem is it's connected to a voltage regulator, so it only 'sees' the regulated voltage. You'll be able to use code like that to see when the voltage starts to drop from 3.3v (meaning the LiPo voltage is near or below that), but by that time the battery is only 10% full or so.

    Best bet is to add two 1MOhm resistors to the battery voltage to create a 'potential divider', then feed the new (halved) voltage into an analog pin - and then you can use some code a bit like you posted (even in JS) to work out how much battery is left

About

Avatar for Gordon @Gordon started