Display Raspberry Pi Battery Indicator
Share
If you're using a PiSugar 2 (Plus) or PiSugar 3 (Plus) battery pack with your Raspberry Pi, you may want to display a Raspberry Pi battery indicator in the Raspbian desktop status bar. This tutorial will guide you through installing the necessary kernel module to achieve this.

Why We Need A Raspberry Pi Battery Indicator?
Having a battery indicator on your Raspberry Pi desktop provides real-time information about your device's battery level and charging status. This can help you:
- Monitor power levels without opening a terminal.
- Get a visual alert before the battery runs out.
- Check charging status at a glance.
Prerequisites
Before proceeding, ensure you have the following:
- A Raspberry Pi running Raspberry Pi OS (Desktop version).
- A PiSugar 2 (Plus) or PiSugar 3 (Plus) battery module installed.
- Internet access on the Raspberry Pi.
Step-by-Step Installation
Installing the PiSugar Kernel Module
PiSugar provides a kernel module that integrates battery monitoring into the system. The installation process differs for PiSugar 2 and PiSugar 3.
For PiSugar 2 Series
Congratulations if your PI is running a linux distribution that has /lib/modules/$(uname -r)/build/
directory, e.g. ubuntu-server or latest pi os, you don't need to manually build RPI kernel, and that will save a lot of time. Manually build kernel:
sudo apt update
sudo apt install -y build-essential linux-headers-$(uname -r) git
Next, clone the PiSugar 2 kernel module repository and install it:
git clone https://github.com/PiSugar/pisugar-power-manager-rs.git
cd pisugar-power-manager-rs/pisugar-module/pisugar-2
make
# if you are using the Plus version, use bat_module=1
sudo make install i2c_bus=0x01 i2c_addr=0x75 bat_module=0
sudo insmod pisugar_2_battery.ko
sudo reboot
For additional details, refer to the official repository:
PiSugar 2 Kernel Module
For PiSugar 3 Series
Run the following commands in the terminal, you can skip this step if you are using the latest and full version of Raspberry Pi OS (64 bit):
sudo apt update
sudo apt install -y build-essential linux-headers-$(uname -r) git
Next, clone the PiSugar 3 kernel module repository and install it:
git clone https://github.com/PiSugar/pisugar-power-manager-rs.git
cd pisugar-power-manager-rs/pisugar-module/pisugar-3
make
sudo make install
sudo insmod pisugar_3_battery.ko
sudo reboot
For additional details, refer to the official repository:
PiSugar 3 Kernel Module
Enabling the Battery Indicator on the Desktop
Once the kernel module is installed, you can display the battery indicator in the Raspberry Pi OS status bar using LXPanel.
- Open a terminal and check if the battery is detected:
cat /sys/class/power_supply/BAT0/status
- Enable the battery monitoring applet:
- Right-click on the Panel in the Raspberry Pi OS desktop.
- Select Add / Remove Panel Items.
- Click Add and choose Battery Monitor.
- Configure it to read from
/sys/class/power_supply/BAT0
.
- Restart LXPanel for the changes to take effect (run this command on Raspbain Desktop terminal):
lxpanelctl restart
Troubleshooting
- If the battery indicator does not appear, verify the module is loaded:
lsmod | grep battery
- Check system logs for errors:
dmesg | grep battery
- Ensure you are using the correct module for your PiSugar version.
Conclusion
By following this guide, you can easily add a battery indicator to your Raspberry Pi's desktop when using a PiSugar 2 (Plus) or PiSugar 3 (Plus) battery pack. This enhances usability and ensures you always have power information at a glance.
For more Raspberry Pi battery management tips, stay tuned for future guides!