Howto get battery info (pi-top [1], raspi 4, pi-topOS - Bullseye)

Managed to get information about the battery with the actual pi-topOS.

Started with some small bash-scripts.

hexadezimal=$(i2cget -y 1 0x0b 0x0d w)
dezimal=$(printf "%d" "$hexadezimal")
#devided=$(echo "scale=3; $dezimal / 10000" | bc)
echo "State of Charge: $dezimal %"

hexadezimal=$(i2cget -y 1 0x0b 0x11 w)
dezimal=$(printf "%d" "$hexadezimal")
#devided=$(echo "scale=3; $dezimal / 100000" | bc)
if [ "$dezimal" -eq 65535 ]; then
  echo "Powercord connected"
  stunden=$((dezimal / 60))
  rest=$((dezimal % 60))
  #echo "RunTimeToEmpty: $dezimal min"
  echo "RunTimeToEmpty: $stunden h  $rest min"

And ended up with a little hooked up i2c display to show the battery state:


pip3 install board
pip3 install adafruit-circuitpython-ssd1306
sudo apt-get install python3-pil

#!/usr/bin/env python3
import smbus
import time

import board
from PIL import Image, ImageDraw, ImageFont
import adafruit_ssd1306
import time

bus = smbus.SMBus(1)
address = 0x0b
register = 0x0d
timeRegister = 0x11

#Change these
#to the right size for your display!
WIDTH = 128
HEIGHT = 32  # Change to 64 if needed

#Use for I2C.
i2c = board.I2C()  # uses board.SCL and board.SDA

oled = adafruit_ssd1306.SSD1306_I2C(WIDTH, HEIGHT, i2c, addr=0x3C)

#Load default font.
font = ImageFont.load_default()

while True:

    hex_timeValue = bus.read_word_data(address, timeRegister)
    decimal_timeValue = hex_timeValue & 0xFFFF

    if decimal_timeValue == 65535:
        timeText = ("Laden")
        hours = decimal_timeValue // 60
        minutes = decimal_timeValue % 60
        timeText = (f"{hours}h {minutes}m")

    hex_value = bus.read_word_data(address, register)
    decimal_value = hex_value & 0xFFFF
    text = (f"{decimal_value}%")

    #Create blank image for drawing.
    #Make sure to create image with mode '1' for 1-bit color.
    image ="1", (oled.width, oled.height))

    #Get drawing object to draw on image.
    draw = ImageDraw.Draw(image)

    #Draw a white background
    draw.rectangle((0, 0, oled.width, oled.height), outline=255, fill=255)

    #Draw a smaller inner rectangle
        (BORDER, BORDER, oled.width - BORDER - 1, oled.height - BORDER - 1),

    combinedText = timeText + " / " + text



Description=Gibt den SoC auf einem OLED Display aus

ExecStart=/usr/bin/python3 /home/pi/python/


Does this mean that we can’t ever have the battery information and the speaker working with pitop os?

Asumed to my experience, not out of the box.

Well. I found an old bullseye image.

I installed it and the battery is showing and the speaker is working, but it is doing some updates now so it may break again.

Do you have a raspi 3 or 4?

It is a 4.

As suspected the battery monitor broke and doesn’t appear anymore.

The speaker is a weird one. It still works but only as snd_rpi_hifiberry_dac

It was working until the other day. I am not sure if it was because I hadn’t updated it or what.

The supposed hub fix doesn’t work. It needs some python3 common dependencies that can’t be installed.

I tried also adding the pitop devices on raspberry pi os 11 but it is the same.