Show the Battery Status of the CrowPi L in Raspberry Pi OS

Show the Battery Status of the CrowPi L in Raspberry Pi OS

CrowPi L user made a APP to show the battery status of the CrowPi L in the system tray of the native Raspberry Pi OS. It is available on github. Battery status for the CrowPi L laptop, with the native Linux Raspberry Pi OS, standing in the system tray, written with python3 and python3-pyqt5.

Features

  • Running on the native Linux Raspberry Pi OS,
  • standing in the system tray,
  • 7 state icons of the battery from 0% to 100%,
  • icon when charging,
  • alert icon when battery is very low,
  • tooltip to view the percentage of the battery load and its voltage,
  • contextual menu to properly quit the app,
  • based on the official python script delivered by CrowPi (/usr/local/sbin/getPowerBattery.py),
  • multi-threaded app to access the battery data with I2C.

Installing and starting the application

From a terminal, install python3-pyqt5
sudo apt install python3-pyqt5
Clone this projet (the first time only), go to its directory, make it executable (the first time only), run it and enjoy!
git clone git@github.com:ppyne/crowPi-L_BatteryStatus.git
cd crowPi-L_BatteryStatus/
chmod +x ./batteryStatus.py
./batteryStatus.py

There're several problems you need to notice when install this APP.

1.'git clone git@github.com:ppyne/crowPi-L_BatteryStatus.git' returns fatal error:

Please change 'git clone git@github.com:ppyne/crowPi-L_BatteryStatus.git' to

git clone https://github.com/ppyne/crowPi-L_BatteryStatus.git
Then the APP will be installed successfully

2.'./batteryStatus.py' returns

Please enable I2C interface.
Then the APP will work properly.

Warning: to quit the app properly, you must right click on its icon in the system tray and click the menu "Quit".

How to achieve automatically open battery monitor at boot-up?

Step1: Modify code in batteryStatus.py

Comment out the following code by adding #

QIcon("battery_0.png"),
QIcon("battery_1.png"),
QIcon("battery_2.png"),
QIcon("battery_3.png"),
QIcon("battery_4.png"),
QIcon("battery_5.png"),
QIcon("battery_6.png"),
QIcon("battery_7.png"),
QIcon("battery_charging.png"), # 8
QIcon("battery_alert.png"), # 9
QIcon("battery_unknown.png"), # 10

Then add the following code to change the icon image from a relative path to an absolute path: (Notice: Please change 'elecrow' to your user name)

QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_0.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_1.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_2.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_3.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_4.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_5.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_6.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_7.png"),
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_charging.png"), # 8
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_alert.png"), # 9
QIcon("/home/elecrow/crowPi-L_BatteryStatus/battery_unknown.png"), # 10

Step 2: Create a .desktop file named 'laptop-battery' and put it in the directory "/ home / elecrow /. config / autostart". The contents of the file are:
Notice: The user name in the path should be changed according to yours

[Desktop Entry]
Type=Application
Name=laptop-battery
Comment=Start battery
NoDisplay=true
Exec=sudo /home/elecrow/crowPi-L_BatteryStatus/batteryStatus.py
ShowIn=LXDE;

RELATED ARTICLES

1 thought on “Show the Battery Status of the CrowPi L in Raspberry Pi OS

t4s-avatar
Colin

The autostart functionality doesn’t appear to work when using 64 bit Pi OS…

September 27, 2022 at 10:21am

Leave a comment

Your email address will not be published. Required fields are marked *

Please note, comments must be approved before they are published