8

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?

Steve Robillard
  • 34,988
  • 18
  • 106
  • 110

2 Answers2

3

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

https://github.com/aboudou/picheckvoltage

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.

flakeshake
  • 6,244
  • 1
  • 16
  • 35
0

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?