Show battery status of CrowPi L in Raspberry Pi OS

edited December 2022 in Raspberry Pi & CrowPi

Here's a little app to show the battery status of the CrowPi L in the system tray of the native Raspberry Pi OS:


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".

«1

Comments

  • 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;
    


  • Working great, but I've got a little quirk - the top quarter of the icon is background-clear (taskbar color), while the rest of the icon is background-white. anybody else seeing this, or is it just my install?
    Chris
    PS - I love this CrowpiL!! it's exactly what I've been looking for for several years, (since Pi2 days)!
  • Never mind, the problem went away. I think it had something to do with right clicking the icon, then NOT quitting, but moving the mouse focus away. I will tinker some more..

    Chris

  • Well, darn, the problem is back again. I'll see if I can make it show up consistently.
  • uh-oh. Now I'm in trouble...
    I did apt-get update and apt-get upgrade on both my images last night (pi os and whatever you guys are using). Now, I'm getting an IIC error on the battery monitor on both images!
    qt5ct: using qt5ct plugin
    qt5ct: D-Bus system tray: no
    Message: IIC read failed, reread
    I checked, and the i2c is turned on...
    Additionally, Pi-Panel crashes on startup, and says I've got to be on a CrowPi!
    I'm lost here, can anybody help?
  • Okay, now I'm in REAL trouble.
    It appears Elecrow is using i2c to talk to their hardware, and now their hardware isn't answering.
    Process so far:
    1. burn new image of elecrow version of Linux, and install. - no change
    2. install alternate pi4. - no change
    How do I get warranty service on this unit?
  • Yay! Fixed it. This probably needs to be a sticky somewhere...
    If the CrowPi-L stops talking to the battery-monitor/Pi-Panel, try unplugging the battery for a minute. That unstuck something in mine!

    Chris
  • I installed today. It works well and I get a nice blue icon responding to the state of the battery and giving the % of charge and the voltage BUT I do not succeed in getting it to start automatically everytime I start my CrowPi-L, even if I have done what is written above, including this laptop-battery file in the .config/autostart folder.
  • How do you create a working .desktop file? My laptop-battery file is stored in the .config/autostart folder and works when I double-click on it but does not work when I start my CrowPi-L. Waiting for a finer solution I have created a shortcut on my desktop with which I can start a working battery icon.
  • @pierre
    Hello Pierre, When you create a. desktop file, please remember to add the suffix ". desktop".
    Then right click the file and enter the required code in the file as text editor.
Sign In or Register to comment.