How to get Battery interrupt in BPI M1?


(Piyush Agrawal) #1

Dear All, I am using Banana Pi M1 for my project, most of the time my system will be running on USB based power, but during power failure I would like my PI to work on battery, so that I can shut down my system properly, Is there any way to know when the system is running on battery and when system is running on mains.

I am running Raspbian OS

Thanks, Piyush


(BPI_Justin) #2

HI: you can try it

cat /sys/class/power_supply/battery/uevent

Output:

POWER_SUPPLY_NAME=battery

POWER_SUPPLY_MODEL_NAME=battery

POWER_SUPPLY_STATUS=Full

POWER_SUPPLY_PRESENT=1

POWER_SUPPLY_ONLINE=0

POWER_SUPPLY_HEALTH=Good