Transform your Raspberry Pi Zero W with Pirate Audio HAT into a Bluetooth audio receiver for any stereo system.
- Raspberry Pi Zero W (original with BCM2835)
- Pimoroni Pirate Audio HAT (any variant with headphone amp)
- MicroSD card (8GB minimum)
- Power supply (5V 2A recommended)
- 3.5mm audio cable (to connect to your stereo)
- Raspberry Pi OS Lite (Legacy, 32-bit) - based on Debian Bullseye
- SSH enabled
- WiFi configured
Use Raspberry Pi Imager to flash the SD card:
- Choose Device: Raspberry Pi Zero
- Choose OS: Raspberry Pi OS (other) → Raspberry Pi OS Lite (Legacy, 32-bit)
- Choose Storage: Your SD card
- Configure Settings (click gear icon):
- Set hostname:
piorbt-receiver - Enable SSH with password authentication
- Set username:
piand password - Configure WiFi (SSID and password)
- Set locale and timezone
- Set hostname:
- Insert SD card into Pi Zero W
- Power it on and wait ~60 seconds for first boot
- Connect via SSH:
ssh pi@pi.local # or ssh pi@<IP_ADDRESS>
Copy the script to your Pi and run it:
# From your computer
scp setup-bt-receiver.sh pi@pi.local:~
# SSH into the Pi
ssh pi@pi.local
# Run the setup script
bash setup-bt-receiver.shThe script will:
- Update system packages
- Install Pirate Audio HAT drivers
- Install and configure Bluetooth and PulseAudio
- Set up automatic Bluetooth discovery
- Create systemd service for auto-start on boot
- Configure the device as "BT-Audio-Receiver"
After the script completes, reboot when prompted:
sudo reboot- Open Bluetooth settings on your phone
- Search for available devices
- Connect to "BT-Audio-Receiver" or "pi"
- Pair (no PIN required)
- Play audio - it will output through the Pirate Audio HAT
- The Pi will remain discoverable at all times
- Previously paired devices will automatically reconnect
- Only one device can stream audio at a time
- Audio quality: 44.1kHz/48kHz, 16-bit stereo
Check if Bluetooth is powered and unblocked:
# Check rfkill status
sudo rfkill list
# Unblock if necessary
sudo rfkill unblock bluetooth
# Power on Bluetooth
bluetoothctl power on
bluetoothctl discoverable on
bluetoothctl pairable on
# Check status
bluetoothctl showShould show:
Powered: yesDiscoverable: yesPairable: yes
Check if Pirate Audio HAT is detected:
# List audio devices
aplay -l
cat /proc/asound/cards
# Should show "sndrpihifiberry" or similar, not just HDMIIf HAT not detected, verify /boot/firmware/config.txt:
sudo nano /boot/firmware/config.txtEnsure these lines exist:
#dtparam=audio=on # Must be commented out
dtoverlay=hifiberry-dac
gpio=25=op,dh
Then reboot:
sudo rebootSet the correct default audio device:
# Check current sinks
pactl list sinks short
# Set HiFiBerry as default
pactl set-default-sink <SINK_NUMBER_OR_NAME>Or configure ALSA default:
sudo tee /etc/asound.conf > /dev/null <<EOF
pcm.!default {
type hw
card 0
}
ctl.!default {
type hw
card 0
}
EOFMonitor Bluetooth events in real-time:
bluetoothctl
# Watch for connection attempts and errorsCheck service status:
# Bluetooth service
sudo systemctl status bluetooth
# Audio receiver service
sudo systemctl status bt-audio-receiver
# View recent logs
journalctl -u bt-audio-receiver -n 50# Check status
pulseaudio --check && echo "Running" || echo "Not running"
# Restart PulseAudio
pulseaudio --kill
pulseaudio --start
# Check for errors
journalctl --user -u pulseaudio -n 50# Make discoverable again
bluetoothctl discoverable on
# List paired devices
bluetoothctl devices
# Remove a device
bluetoothctl remove <MAC_ADDRESS>
# Trust a device (auto-reconnect)
bluetoothctl trust <MAC_ADDRESS># Check Bluetooth service
sudo systemctl status bluetooth
# Check receiver service
sudo systemctl status bt-audio-receiver
# Restart receiver service
sudo systemctl restart bt-audio-receiver
# View logs
journalctl -u bt-audio-receiver -f# Test audio output
speaker-test -c2 -t wav
# List audio devices
aplay -l
# Check PulseAudio sinks
pactl list sinks short
# Monitor audio routing
pactl list sinks- Bluetooth config:
/etc/bluetooth/main.conf - Boot config:
/boot/firmware/config.txt - PulseAudio user config:
~/.config/pulse/client.confand~/.config/pulse/default.pa - PulseAudio system config:
/etc/pulse/default.pa - Bluetooth service:
/usr/local/bin/bt-speaker-init.sh - Systemd service:
/etc/systemd/system/bt-audio-receiver.service
Edit the init script:
sudo nano /usr/local/bin/bt-speaker-init.shChange this line:
hciconfig hci0 name "BT-Audio-Receiver"Then restart:
sudo systemctl restart bt-audio-receiverEdit PulseAudio config:
nano ~/.config/pulse/default.paModify:
default-sample-format = s16le # or s24le for 24-bit
default-sample-rate = 44100 # or 48000
alternate-sample-rate = 48000 # or 96000
Restart PulseAudio:
pulseaudio --kill
pulseaudio --startTo remove the Bluetooth receiver setup:
# Stop and disable services
sudo systemctl stop bt-audio-receiver
sudo systemctl disable bt-audio-receiver
# Remove files
sudo rm /etc/systemd/system/bt-audio-receiver.service
sudo rm /usr/local/bin/bt-speaker-init.sh
# Reload systemd
sudo systemctl daemon-reload
# Optional: Remove packages
sudo apt-get remove --purge bluez pulseaudio pulseaudio-module-bluetoothThe Raspberry Pi Zero W has limited resources:
- Single-core 1GHz CPU
- 512MB RAM
- Bluetooth 4.1
Expected performance:
- ✅ Streaming from phone/tablet
- ✅ Standard audio quality (44.1kHz/48kHz)
- ✅ Low latency for music playback
⚠️ High-res audio may have dropouts⚠️ Multiple simultaneous connections not supported
- The device is always discoverable (no timeout)
- Auto-pairing is enabled (no PIN required)
- Consider setting
DiscoverableTimeoutin/etc/bluetooth/main.conffor better security - Add PIN pairing by changing the agent type in the init script
MIT License - Feel free to modify and distribute
- Pimoroni for the Pirate Audio HAT
- Raspberry Pi Foundation
- BlueZ Bluetooth stack
- PulseAudio project
For issues or questions:
- Check the Troubleshooting section
- Review system logs:
journalctl -xe - Check Pimoroni support forums
- Verify hardware connections
- v1.0 - Initial release with automatic setup script
- Bluetooth audio receiver functionality
- Pirate Audio HAT support
- Auto-discovery and pairing
- Systemd service for persistence