Hi Pimoroni support — WoozyFace here. I just received a Piano HAT and I’m stuck during installation. I suspect either the installer/script is out of date for my distro or there’s a hardware/driver mismatch. Below I describe the exact environment, the commands I ran, the important outputs/errors, and what I’ve already tried. Any pointers appreciated — happy to provide additional logs if wanted.
Environment
-
Board / OS: Debian Bookworm (aarch64), kernel
6.12.47+rpt-rpi-v8PI 3B+ -
Filesystem: overlayroot (read-only boot/overlay present on this system)
-
Python: system Python 3.11, pip available; I created a virtualenv for testing
What I tried (commands & flow)
- Ran the official installer:
curl https://get.pimoroni.com/pianohat | bash
Installer output shows the common PEP 668 error:
Installing Piano HAT library for Python 3...
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install python3-xyz ...
...
Python 3 library install failed!
- Tried the venv approach (created venv with system site-packages to allow
python3-smbususage):
python3 -m venv --system-site-packages ~/pimoroni-venv
. ~/pimoroni-venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install PianoHAT cap1xxx
Pip reports PianoHAT and cap1xxx are installed (from distro site-packages or PyPI), RPi.GPIO present.
- Ensured system packages:
sudo apt update
sudo apt install -y python3-smbus python3-rpi.gpio i2c-tools
sudo modprobe i2c-dev
- I2C device detection & probing:
ls -l /dev/i2c*
# -> /dev/i2c-2 exists
i2cdetect -l
# -> shows i2c-2 (bcm2835)
sudo i2cdetect -y 2
# -> returned addresses on bus 2 (sample output):
# 30: .. 37 .. 3a .. 4a 4b .. 50 .. 54 .. etc
- Ran Python probe script (uses smbus on bus 2). Output for addresses 0x28 and 0x2b:
== addr 0x28 ==
read_byte: ERR: [Errno 5] Input/output error
read_byte_data reg 0x00 -> ERR: [Errno 121] Remote I/O error
...
read_i2c_block_data 0x00 len8 -> ERR: [Errno 5] Input/output error
== addr 0x2b ==
read_byte: ERR: [Errno 5] Input/output error
read_byte_data reg 0x00 -> ERR: [Errno 121] Remote I/O error
...
- Running the library test (monkeypatching
smbus.SMBusto use bus 2) fails with:
Traceback (most recent call last):
...
File "/usr/lib/python3/dist-packages/cap1xxx.py", line 494, in _read_byte
return self.i2c.read_byte_data(self.i2c_addr, register)
OSError: [Errno 121] Remote I/O error
- Kernel logs show repeated undervoltage events:
[ ... ] hwmon hwmon1: Undervoltage detected!
[ ... ] hwmon hwmon1: Voltage normalised
Observations / What’s suspicious
-
Installer fails because pip tries to install system-wide on a distro that enforces
externally-managed-environment(PEP 668). Workaround: use a venv. I used--system-site-packagesso the venv can seepython3-smbus. -
/dev/i2c-2is present (not/dev/i2c-1). I forced the code to use bus 2; the HAT hardware appears on bus 2 on this machine. -
Although
i2cdetectlists several addresses on bus 2, direct reads from the CAP1xxx addresses (0x28, 0x2b) produceRemote I/O error.i2cdumpalso fails withRead failed. -
Kernel shows undervoltage events repeatedly; that can cause I²C instability and failed communication.
-
After reseating HAT and reloading
i2c-dev, the errors persist (same remote I/O behavior and read failures).
Files / scripts I used
-
piano_probe2.py— small smbus probe tryingread_byte,read_byte_dataandread_i2c_block_datafor addresses[0x28, 0x2b] -
piano_test_live.py— monkeypatchessmbus.SMBusto use bus 2 and then importspianohatand callspianohat.auto_leds(False)to trigger CAP1xxx init.
Questions / Requests for Pimoroni support
-
Are 0x28 and 0x2b the expected CAP1xxx addresses for Piano HAT? (I expected CAP1xxx on those, but reads fail.)
-
Does the
cap1xxxorpianohatlibrary assume bus 1 by default? I’ve forced bus 2 with a monkeypatch and imports succeed, but register reads fail. Is there any device-tree overlay or init sequence required that the install script normally sets up on Raspberry Pi OS and that may be missing on a Debian Bookworm aarch64 image? -
Could the CAP1xxx chips be sensitive to undervoltage? My kernel log shows repeated undervoltage events — could that cause the Remote I/O errors I’m seeing? (I can confirm power/adapter and try another cable/PSU.)
-
Is there any known issue with the Pimoroni installer and systems that enforce PEP 668 (system-managed Python)? The installer suggests venv usage; would you consider updating the installer to detect PEP 668 and auto-offer a venv-based install or provide clearer instructions for Debian Bookworm / aarch64 users?
-
Are there low-level registers that are intentionally unreadable on CAP1xxx (causing
i2cgetto fail)? If so, which registers are safe to read to confirm the device is responsive? (I tried0x00and0xFDand got I/O errors.) -
Any device-tree overlays / boot config lines required for Piano HAT on Debian (non-RaspberryPI OS)? If the Raspbian installer normally writes overlays to
/boot/config.txt, that’s problematic on my overlayroot read-only setup — what minimal overlays are required?
Things I’m happy to try next (if you advise)
-
Confirm exact expected I2C addresses and example registers that should respond (so I can test safely).
-
Try with a different power supply and cable (I suspect undervoltage is significant).
-
Provide
dmesgoutput,i2cdetect -y 2output, and the Python probe script logs (I have them and can paste more if helpful). -
Try a fresh Raspberry Pi OS image to see if the issue is distro-related (I can do that but would prefer a pointer first).
Short reproduction steps (what you can run to reproduce my state)
# on Debian Bookworm aarch64 (kernel 6.12.47+rpt-rpi-v8)
curl https://get.pimoroni.com/pianohat | bash # shows PEP668 error when pip tries to install system packages
# create venv and install libs:
python3 -m venv --system-site-packages ~/pimoroni-venv
. ~/pimoroni-venv/bin/activate
pip install PianoHAT cap1xxx
sudo apt install -y python3-smbus python3-rpi.gpio i2c-tools
sudo modprobe i2c-dev
i2cdetect -y 2 # shows devices on bus 2
# run probe script that tries to read registers -> get Remote I/O errors
Attachments / Logs I can paste if helpful
-
dmesgoutput (shows undervoltage events) -
i2cdetect -y 2output (shows several addresses on bus 2) -
piano_probe2.pyoutput (shows Remote I/O error on 0x28 / 0x2b) -
piano_test_live.pytraceback (shows OSError 121 during cap1xxx init)
Thanks in advance — please let me know the minimal next checks I should run, or whether you expect the HAT to require any specific device-tree overlay or boot config on Debian Bookworm aarch64. If you want me to try a different power supply first, tell me what voltage/current you recommend.
— WoozyFace (on behalf of a test bench in the Netherlands)