This project was originally based on the “Build your own Concrete Bluetooth Speaker” (how-to) YouTube video by DIY Perks. From there a few different paths were explored and ultimately a 2.1 system was conceived.
Portability was sacrificed and the concrete form slated to become a standalone subwoofer for the system. As for the electronics and mid/high-range speakers, custom 3D-printed enclosures were designed.
This project is based on the popular Raspberry Pi ARM-based computer. The model and auxillary components required are outlined below:
- Raspberry Pi Zero W
- HiFiBerry DAC+ 2.6. (Digital-to-Audio-Converter)
- Dayton Audio RS75T 8 Ohm full-range speakers
- Adafruit class D audio amplifier build around the MAX9744 chip
- Power supply providing 5V and 12V
- 5-Pin rotary encoder for volume and playback control
- 3D printed enclosures for full range speakers
The software required to build this project is broken down into quite a few parts
- Raspberry Pi Operating System
- Headless WiFi and SSH connectivity
- Security and hardening
- Soundcard installation
- DAC drivers for high quality audio output
- Bluetooth drivers for additional wireless connectivity options
- Linux command line setup for audio streaming connectivity
- Python3 development environment
- Global volume control
- VLC playback control
- Sound equalization
- Script automation setup
For ease of installation, I’ve provided all software used in the Downloads section at the bottom to prevent any configuration issues between future updates of the software. The original maintainer links are, however, still provided for those that prefer the latest releases.
Operating system, connectivity and security software installation
An official light Rasbian OS build (obtained from the official Raspberry Pi homepage) was chosen as this will be a standalone and headless installation.
The Raspberry Pi foundation seems to have recently developped their own USB installation tool. The older guides recommended, if I recall correctly, Balena Etcher.
The installation of Rasbian is very straightforward and streamlined into 3 steps:
- Download the USB SD card imager program
- Download a Rasbian OS build as a
- Prepare and flash the OS onto your micro SD card using the imager application
Following this, you should eject and re-insert your newly minted SD card.
Enabling SSH and headless WiFi
One newly accessible partition should appear in your drive listings named “Boot”. Here you must create two files as follows:
ssh- Without any extension or content. This will enable the ssh server with default settings on your Raspbian OS
wpa_supplicant.conf- Make sure to fill the file with your relevant WiFi network details
That’s all there is to it!
To access your Raspberry Pi over your local network, you will need to find the LAN address that was assigned to your Pi by your router. Logging into the administrative interface of your router will allow you to see all LAN ip address allocations.
Accessing your Pi:
- Download, for example, an SSH client like Putty
- Use the default Raspbian OS settings
Once you first log into your Raspberry Pi, run the standard Raspberry Pi config script with
sudo raspi-config to create a new password and disable unecessary system functions (camera interface, etc). The original guide goes through each option in great detail.
A detailed guide can be found in a dedicated post on the matter.
The sound utility that setup is based on is
It should be included with the Raspbian OS distribution but running the following may install any missing dependencies
sudo apt-get install alsa-utils
DAC driver setup
In order to properly route audio through the HiFiBerry DAC+, the appropriate overlay drivers must be configured. The default audio
overlay must be disabled and the correct one chosen. Raspbian OS has build-in support for this DAC out-of-the-box.
Configuration changes are done on
config.txt on the
Boot partition. Raspbian OS mounts this at
/boot. Based on the original HiFiBerry general setup, the DAC+ 2.6 instructions are:
- Remove the existing audio configuration
- Comment out the
- Comment out the
alsa-utils package features will be used, a few things must to be added to ALSA’s configuration. For a more detailed look at ALSA utilities, the following blog post by SC Phillips goes into great details.
/etc/asound.conf with the following contents:
Bluetooth connectivity setup
The Bluetooth portion is not as straighforward to implement as some of the other steps. Each device must be
trusted and an appropriate
audio sink enabled to pass audio to the predefined sound card.
In order to pass audio through Bluetooth to
ALSA the following needs to be set up and configured:
Configuration now requires an additional parameter to be added to the
ExecStart=... line should be changed to
ExecStart=/usr/bin/bluealsa -p a2dp-sink to pass on the
-p flag and paramter. A
reboot is required.
To successfully connect an audio source to the Raspberry Pi, the standard
bluetoothctl command line interface is used.
sudo privileges are required to access the Bluetooth radio.
To clarify any of the following commands, issue
help at the
- Enable Bluetooth on the Pi
- Enable pairing agent and turn on discovery mode
- Place your audio device in pairing mode and turn on the Pi’s scanning mode
- Make a note of your audio device’s MAC address
- Pair your two devices making sure to accept prompts for passcode confirmation on both devices (if applicable)
- Trust your newly added device for future connections
- Connect your audio device to the Raspberry Pi
- Quit the Bluetooth manager
Although a new device is successfully paired, trusted and connected, audio will not be passed through to
ALSA unless you explicitly enable it per MAC address
Audio will be passed along to
ALSA as long as that command runs. Note that you may run this command without an existing connection (ie. at startup)
A well-known linux application for streaming audio from the terminal is
mplayer. For the official documentation, follow this link
Install on your Raspberry Pi with
sudo apt-get install mplayer.
Listening to a stream is as straightforward as passing the stream url to
However, depending on the stream bitrate, you should define and pass on a
cache parameter to cache loaded streams.
Note: The optional
iPv4 flag ensures compatibility with more local network configurations.
Python environment and control scripts
The volume control uses a rotary encoder (like this one) and a python script to interpret movement and modify the volume through
ALSA. Volume and interface controls will use the GPIO pins of the Raspberry Pi and, by means of Python scripts, control our parameters on the Raspberry Pi.
The principal requirements are
pip package manager for Python3 and the
Raspberry Pi GPIO python packages. Install using the following:
The script was forked from a gist by Andrew Dupont on GitHub and the GPIO pins defined. Modifications will be made to allow digital control of the audio amplifier board.
In order to successfully connect your rotary encoder to the Pi, browse the excellent ..[C]omprehensive GPIO Pinout guide for the Raspberry Pi. Make note that the numbering can be relative to the physical RPi header or the system-on-chip pinout. Either is fine as long as it is consistentily used and appropriately defined in the python script.
Adding sound equalization to alsamixer
Adding equalization to alsa mixer requires the installation of a plugin and configuring alsa to use it.
As we already known the hardware allocation id for this project’s soundcard (
0), we can directly modify the global
alsa.conf file as follows:
Following the configuration, it is necessary to restart the Raspberry Pi. Afterwards, call up
alsamixer with the following parameters to enter the equalization mode for the HiFiBerry soundcard:
The original guide on the HiFiBerry website, which itself was based on a Dutch website’s guide, did not work as originally outlined and required the addition of
controls "/home/pi/.alsaequal.bin" parameters.
Once testing yields satisfactory results, the volume python script can be automatically executed at boot using the
nano as the default crontab editor, the following entry is added:
Other setups by others include this project by Nico Kaiser on GitHub. It offers install scripts to install and setup the various components.
Material on this site is licensed under a Creative Commons BY-NC-SA 4.0 license unless specified otherwise.