High-quality DIY Bluetooth speaker built with Raspberry Pi Zero 2W, HiFiBerry MiniAmp, and CamillaDSP equalizer with web interface, sound feedback, and physical rotary controls.
This educational project aims to build a prototype of a Bluetooth speaker that is detachable, reusable, and repairable, using open-source softwares, standards, and norms as much as possible.
GitHub Repository: https://github.com/cstaelen/oakhz-diy-pizero-speaker
-- Written with Claude AI
This complete system includes three main components:
1. ๐ Base System - Bluetooth Speaker (Required)
The core audio system with Bluetooth streaming and CamillaDSP parametric equalizer.
Features:
- โ Bluetooth A2DP streaming (auto-pairing, no PIN)
- โ 10-band parametric equalizer (CamillaDSP 48kHz)
- โ Professional audio pipeline: Bluetooth โ PulseAudio โ Loopback โ CamillaDSP โ HiFiBerry DAC
- โ ALSA loopback for flexible routing
- โ Automatic device pairing (NoInputNoOutput)
- โ Hostname: "OaKhz audio" (visible via Bluetooth)
๐ Read Full Installation Guide โ
2. ๐๏ธ Web Equalizer Interface (Optional)
Web-based control panel for CamillaDSP equalizer with real-time adjustments.
Features:
- ๐ Web interface accessible from any device
- ๐๏ธ 10-band parametric EQ with visual feedback
- ๐พ Preset management (save/load custom configurations)
- โก Real-time updates via WebSocket
- ๐ Frequency response graph
- ๐ฑ Mobile-responsive design (warm wood theme)
- ๐ต Media player controls (Play/Pause/Next/Previous)
- ๐ป Real-time metadata display (Artist, Title, Album, Status)
Access: http://[raspberry-pi-ip] or http://192.168.50.1 (AP mode)
๐ Read Full Documentation โ
3. ๐ Sound Feedback System (Optional)
Audible notifications for system events through PulseAudio.
Features:
- ๐ต Ready sound (Bluetooth discoverable - C major arpeggio)
- ๐ต Connection sound (device connects/reconnects - high chime)
- ๐ต Shutdown sound (system powering off - descending arpeggio)
- ๐ All sounds at 80% volume via
paplay(shutdown at 25%) - ๐ฏ Automatic PulseAudio routing through equalizer
- ๐ Single device mode (auto-disconnect old connections)
๐ Read Full Documentation โ
4. ๐๏ธ Rotary Encoder Control (Optional)
Physical rotary encoder for tactile volume and media control.
Features:
- ๐ Rotate: Volume up/down (ยฑ3% per step)
- ๐ Short press (<1s): Play/Pause (Bluetooth media control)
- ๐ Medium press (1s): Skip track
- โฑ๏ธ Long press (3s): System shutdown
- ๐ฏ BlueZ MediaControl1 integration via D-Bus
- ๐ต Smart play/pause toggle (checks current status)
- ๐ Thread-safe with 150ms throttling
- ๐ค Runs as user
oakhz(gpio + audio groups)
GPIO Pins: CLK=23, DT=24, SW=22
๐ Read Full Documentation โ
5. ๐ก WiFi Access Point Fallback (Optional)
Automatic WiFi client/Access Point switching for equalizer access anywhere.
Features:
- ๐ Auto-connect to home WiFi when available
- ๐ก Auto-switch to AP mode when no WiFi
- ๐ Smart monitoring and switching (every 30s)
- ๐ WPA2 secured Access Point
- ๐ฏ Equalizer accessible in both modes
- ๐ป SSH always available
Access: Home WiFi โ http://[IP] | AP mode โ http://192.168.50.1
๐ Read Full Documentation โ
- Raspberry Pi Zero 2W or Raspberry Pi 4
- Raspberry Pi OS Lite 64-bit
- HiFiBerry MiniAmp (or compatible DAC)
- 2x 4ฮฉ 3W speakers
- KY-040 rotary encoder (optional)
# 1. Base System (Required)
sudo bash scripts/install.sh
sudo reboot
# 2. Web Equalizer Interface (Optional)
sudo bash scripts/setup-equalizer.sh
# 3. Sound Feedback (Optional)
sudo bash scripts/setup-sound.sh
# 4. Rotary Encoder (Optional)
sudo bash scripts/setup-rotary.sh
# 5. WiFi Access Point Fallback (Optional)
sudo bash scripts/setup-accesspoint.sh
sudo reboot- Connect Bluetooth: Look for "OaKhz audio" on your phone
- Access Web Interface (if equalizer installed):
http://[Pi-IP] - Use Rotary Control (if rotary installed): Turn for volume, press for play/pause/skip
| Component | Model | Price |
|---|---|---|
| Raspberry Pi | Zero 2W | ~โฌ20 |
| SD Card | 16GB+ Class 10 | ~โฌ10 |
| Audio DAC | HiFiBerry MiniAmp | ~โฌ25 |
| Power Supply | 5V 3A USB-C | ~โฌ10 |
| Speakers | 2x 4ฮฉ 3W | ~โฌ15 |
| Total | ~โฌ80 |
| Component | Model | Price |
|---|---|---|
| Rotary Encoder | KY-040 | ~โฌ2 |
| Enclosure | 3D printed or custom | Variable |
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Interfaces โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Web Browser โ Bluetooth Device โ Rotary Encoder โ
โ (Equalizer) โ (Audio Source) โ (Volume/Skip) โ
โ Port 80 โ โ GPIO 23/24/22 โ
โโโโโโโโโโฌโโโโโโโโโโดโโโโโโโโโโฌโโโโโโโโโโโดโโโโโโโโโฌโโโโโโโโโ
โ โ โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโ
โ Audio Processing Layer โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Flask Server โ PulseAudio โ pactl (Volume) โ
โ (Python) โ (System Mode) โ (Rotary Control) โ
โโโโโโโโโโฌโโโโโโโโดโโโโโโโโฌโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Sound Feedback & Routing โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Audio Events โ Bluetooth โ Auto-routing โ
โ (paplay 65%/75%) โ Monitor โ (switch-on-connect) โ
โ - Ready โ - Connection โ โ
โ - Shutdown โ - Single dev โ โ
โโโโโโโโโโฌโโโโโโโโดโโโโโโโโฌโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโ
โ โ
โโโโโโโโโโผโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ALSA Loopback Layer โ
โ hw:Loopback,0 โโโโโโโโโโโ hw:Loopback,1 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CamillaDSP (Equalizer) โ
โ 10-Band Parametric EQ @ 48kHz โ
โ WebSocket: 1234 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ HiFiBerry MiniAmp (I2S DAC) โ
โ hw:1,0 (Card 1) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโผโโโโโโ
โ Speakers โ
โ ๐ ๐ โ
โโโโโโโโโโโโ
- 48kHz/16-bit audio pipeline
- Professional DSP with CamillaDSP
- Zero latency Bluetooth routing
- HiFiBerry DAC for superior sound quality
- Auto-pairing Bluetooth (no PIN)
- Web interface with media player controls (natural wood theme)
- Real-time metadata display (Artist, Title, Album, Status)
- Physical media controls with rotary encoder (Play/Pause/Next)
- Audio feedback for system events
- Real-time equalizer adjustments
- Preamp master volume control
- Thread-safe volume control with locking
- Debounced controls (150ms throttling)
- BlueZ D-Bus integration for media controls (MediaControl1 & MediaPlayer1)
- Smart play/pause toggle (status-aware)
- Single device mode (auto-disconnect old devices)
- PulseAudio system mode for stability
- Systemd services for automatic startup
- On your phone, look for "OaKhz audio" in Bluetooth settings
- Connect (no PIN required)
- Play music - audio routes automatically through equalizer
- Open
http://[Raspberry-Pi-IP]orhttp://oakhz.local - Now Playing section shows:
- ๐ต Current track (Artist, Title, Album)
- โฏ๏ธ Playback status (Playing/Paused/Stopped)
- Auto-updates every 2 seconds
- Media Controls:
- โฎ Previous track
โถ๏ธ /โธ Play/Pause (smart toggle)- โญ Next track
- Equalizer:
- 10-band parametric EQ (-12dB to +12dB per band)
- Preamp master volume control (-12dB to +12dB)
- 8 presets: Flat, Rock, Pop, Jazz, Classical, Bass, Treble, Vocal
- Changes apply in real-time
- Turn left/right: Volume ยฑ3%
- Press briefly (<1s): Play/Pause Bluetooth media
- Press medium (1s): Skip to next track
- Hold 3 seconds: Shutdown system
| Service | Purpose | Status Command |
|---|---|---|
| bluetooth.service | Bluetooth stack | sudo systemctl status bluetooth |
| bt-agent.service | Auto-pairing | sudo systemctl status bt-agent |
| pulseaudio.service | System audio | sudo systemctl status pulseaudio |
| camilladsp.service | Equalizer | sudo systemctl status camilladsp |
| oakhz-equalizer.service | Web interface | sudo systemctl status oakhz-equalizer |
| oakhz-audio-events.service | Sound feedback | sudo systemctl status oakhz-audio-events |
| oakhz-rotary.service | Rotary control | sudo systemctl status oakhz-rotary |
No Bluetooth connection? โ See Base System Troubleshooting
No sound output? โ See Base System - No Sound
Sound feedback not playing? โ See Sound Feedback Troubleshooting
Rotary encoder not responding? โ See Rotary Encoder Troubleshooting
Volume control not working? โ See Rotary - Volume Not Changing
Web interface not accessible? โ See Web Equalizer Troubleshooting
OAKHZ_DOC/
โโโ README.md # Project overview
โโโ docs/ # Documentation
โ โโโ README-v2-install.md # Base system installation guide
โ โโโ README-v2-equalizer.md # Web equalizer interface
โ โโโ README-v2-sound.md # Sound feedback system
โ โโโ README-v2-rotary.md # Rotary encoder control
โ โโโ README-v2-accesspoint.md # WiFi Access Point fallback
โโโ scripts/ # Installation scripts
โ โโโ install.sh # Base system installer
โ โโโ setup-equalizer.sh # Web equalizer installer
โ โโโ setup-sound.sh # Sound feedback installer
โ โโโ setup-rotary.sh # Rotary encoder installer
โ โโโ setup-accesspoint.sh # WiFi AP installer
โโโ sounds/ # Audio files
Each component can be customized independently:
- Base System: Change Bluetooth name, adjust CamillaDSP config
- Web Equalizer: Customize web UI theme, add custom presets, change port
- Sound Feedback: Replace WAV files, adjust volumes, change polling intervals
- Rotary Encoder: Modify GPIO pins, adjust volume steps, change button timings
See individual documentation for detailed customization guides.
Base System (Required)
โ
โโโ Web Equalizer (Optional) โ Depends on CamillaDSP from base
โโโ Sound Feedback (Optional) โ Depends on PulseAudio from base
โโโ Rotary Encoder (Optional) โ Depends on PulseAudio from base
โโโ WiFi AP Fallback (Optional) โ Independent, works with all components
Installation order:
- Always install Base System first
- Add optional components in any order
- WiFi AP Fallback is completely independent
- User separation: Services run as appropriate users (
oakhz,pulse,root) - Minimal permissions: Only required groups (gpio, audio)
- Low resource usage: ~50MB RAM total for all services
- No network exposure: Only local web interface (port 80)
- Automatic updates: Use
sudo apt update && sudo apt upgrade
- โจ Added Bluetooth media controls via BlueZ D-Bus (MediaControl1)
- ๐ต Rotary button: Changed from Mute/Unmute to Play/Pause
- ๐ Web interface: Added Now Playing section with Artist/Title/Album display
- ๐ฎ Web controls: Added Play/Pause, Next, Previous buttons
- ๐ Preamp fix: Master volume preamp now properly applied to CamillaDSP
- ๐ Smart toggle: Play/Pause checks current status before sending command
- ๐ก Real-time updates: Metadata refreshes every 2 seconds
- Initial release with 10-band equalizer, rotary controls, and web interface
GPL-3.0 License - Free to use, modify, and redistribute
Software:
- Raspberry Pi OS
- BlueZ (Bluetooth + D-Bus media control)
- PulseAudio (Audio routing)
- CamillaDSP (Equalizer)
- Flask (Web interface)
- gpiozero (GPIO control)
Hardware:
- HiFiBerry (Audio DAC)
- Raspberry Pi Foundation
OaKhz Audio - v4.0 - October 2024




