I want to use a USB power bank for powering my RPi3B but I need to display how much charge is left. What is a good set up of measuring the battery level of the power bank?


1 Answer 1


USB power banks vary, but mostly they will have a single 3.7V cell and a boost converter to bring that up to 5V. The cell will be charged to, say, 4.2V and decrease to, say, 3.1V. The boost converter takes this varying voltage and boosts it up to 5V for use by USB devices.

The power level is a function of the voltage of the cell. The output voltage will stay the same regardless until the cell is discharged and it shuts off. Unless you take the power bank apart you won't be able to measure the cell voltage from the output.

Some power banks do have a few LEDs to indicate level, so you might be able to interface with those, or if you want something more accurate use an ADC (analog to digital converter) to measure the cell voltage. If you've gone that far, you might be better off just using the cell and finding something like a lipo shim rather than designing your own circuit (I don't know off-hand of any that do give more than a simple low battery warning).

  • This is a handy answer; do you know if half-way between 3.1 and 4.2V corresponds to anything near 50% remaining power, or is it mostly spent by that time? Of course every battery is different, but without calibrating this, is it somewhat linear?
    – uhoh
    Jun 4, 2018 at 12:50
  • @uhoh see the curves at electronics.stackexchange.com/questions/32321/… or batteryuniversity.com/learn/article/… the voltage has a linear region, but the position and gradient of that region depends more on the current being drawn than the state of charge. Jun 4, 2018 at 13:36
  • Super, thanks for those. I get the idea now, to do it right, it really requires something (microcontroller and/or algorithm) that "knows" something about how the battery behaves.
    – uhoh
    Jun 4, 2018 at 14:31

Not the answer you're looking for? Browse other questions tagged or ask your own question.