The team at Pi Supply was kind enough to send me a Justboom Amp Zero pHAT to play with. The Amp Zero combines both DAC (Digital to Analog Converter) and Amp (Amplifier), making it a great choice for a DIY Pi Zero speaker build. To distinguish this build from the many other existing Pi related audio projects, I decided to give it a special twist, literally. The build is inspired by the spiral plywood vase by Bob from I Like to Make Stuff.
The electronics are centered around the Amp Zero, but to add a bit of dynamicity to the whole, a Scroll pHAT is used to display the spectrum of the audio in real time.
This makes the list of electronics components, the following:
- Raspberry Pi Zero
- Justboom Amp Zero pHAT
- Pimoroni Scroll pHAT
- Raspberry Pi wifi dongle
- microUSB converter shim
- Dayton Audio PS95-8 Speaker
Justboom Amp Zero
In the Box
When unboxing the Amp Zero, following items were included in the box:
- two Justboom stickers (yay stickers!)
- getting started link
- Max2Play 30-day voucher, a Pi OS for home-entertainment
- Roon Labs 60-day voucher
- Amp Zero pHAT
- DC barrel jack adapter
- IR receiver
- four spacers with screws
Connecting the Amp Zero to a Pi Zero requires standard male header pins to be soldered on the Pi. After having screwed on the spacers, the pHAT slides on top of the header pins, onto the Pi Zero, resulting in a very slim package capable of fitting in a small Altoids-like tin.
This is how the Pi Zero and Amp Zero pHAT will be integrated into my speaker build.
If you don’t feel like building your own enclosure, it is possible to purchase a case to accommodate the Pi Zero and Amp Zero. It makes for a very compact controller for your speakers!
For detailed assembly instructions, be sure to check out the official guide!
I’m using the latest Raspbian image, as I require the Scroll pHAT software and some custom scripts to run. If you are using only the Amp Zero, other distributions like OSMC or Volumio for example, already have integrated support for the pHAT.
Enabling support for the Amp Zero is a piece of cake though, as it only requires you to add or comment following lines in the /boot/config.txt file:
The Scroll pHAT is used to display the spectrum of the audio. I based myself on an example by Pimoroni, which also contains the installation procedure. Pimoroni’s example processes audio files, but with some minor modifications, I was able to have it display the spectrum of an audio stream instead.
To feed the spectrum analyser with an audio stream, a loopback device has been created. This was achieved by modifying the ALSA config in /etc/asound.conf:
This means that by default, audio is sent to output device “both”, which consists of two outputs: the DAC and a loopback device. The loopback device’s counterpart will then be used to feed the stream to the spectrum analyser.
The modified code, visualising the spectrum on the Scroll pHAT:
To take into account possible crashes of the spectrum analyser, a script has been created to restart it in case it is not or no longer running.
sudo modprobe snd-aloop sleep 5 while true do if ps aux | grep -v "grep" | grep "spectrum" 1>/dev/null;then sleep 1 else sudo /home/pi/spectrum.py & fi done
Inspired by Bob’s spiral vase, I attempted to recreate something similar for the speaker. By offsetting square pieces of wood, a spiral is obtained. One of the pieces is larger, serving both as a stand and a place to install the Scroll pHAT in.
The Pi Zero and Amp Zero are housed inside the speaker, exposing the wifi dongle and power connector at the back.
Too special? You be the judge!