I use a power bank to power my Raspberry Pi, and I want to create script to turn off the Raspberry Pi when the battery level is low, but I cannot find any command to visualize the battery level.

I don't know if is possible. Does such a command exist?


2 Answers 2


No Raspberry Pi can correctly measure its input voltage without at least one additional component.


Some Raspberries can detect whether the input voltage is below 4.65 V or not - and provide a simple answer of yes/no , true/false. They use this binary distinction to display the undervoltage symbol.

  • This is using a sledge hammer to crack a nut! An ADC to convert voltage then a program to monitor voltage is overkill. If you wanted to do this all you need is a comparitor and 2 resistors. Using a linear regulator is inefficient, and 1A inadequate for the Pi.
    – Milliways
    Jul 27, 2016 at 7:09
  • 4
    That gives only a yes/no answer to "Is the voltage too low ?'" , doesn't it ? I think the Pi can already "measure" that : raspberrypi.org/forums/viewtopic.php?t=82373
    – flakeshake
    Jul 27, 2016 at 7:16
  • 3
    As @MohammadAli said in the comments, monitoring the output voltage of a power bank is meaningless: the output will stay close to 5V until the cell is empty and you have to shut down. Feb 7, 2017 at 8:48

Ideally you would need access to the battery terminals (not the 5V) to be able to measure it and feed into the software. For that I have been using the analog-to-digital converter ADS1115 and this tutorial from Adafruit https://learn.adafruit.com/adafruit-4-channel-adc-breakouts/python-circuitpython .

You would the need to know which voltage is "low enough" and then issue a shutdown command to the Pi. I've seen some solutions posted here, like this one: How to check how much battery is left on my Raspberry Pi in the terminal?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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