It’s a Squeezebox built from a Tivoli Audio alarm speaker, and for the impatient ones among you, here are the key features and a picture:
- Tivoli Speaker and case using the original speaker and 3W output;
- runs on battery for a whole day (more than 12h);
- rotary and push controller for volume and play/pause;
- separate alarm clock;
- fully Squeezebox compatible player using a Raspberry Pi zero and SqueezeLite;
- very simple and power-efficient 5V design.
And since Coolio and I do software in the first place, the whole project has its own software as well, in this case our open-sourced solution to power the volume and play/pause control. It’s quite cool, too :), you can find it on GitHub at https://github.com/coolio107/SqueezeButtonPi-Daemon
Since Logitech discontinued the Squeezeboxes a long time ago, Coolio and I – like many other iPeng users – are sometimes in need of new and cool hardware to use our favorite app with. But today powerful computing hardware is easily available (for example in the form of the Raspberry Pi), so I decided to take the do-it-yourself route and build my own one.
In this particular case, the goal was to have a stylish replacement for a Squeezebox Radio as a Christmas present. It was supposed to be used as additional player for the Squeezebox setup my mother uses. She’s been using a Tivoli Radio for years and loves its design and sound, but it’s only AM/FM and doesn’t run on battery, so the idea was born to build something more modern based on this classic device.
The Requirements Specification
Being an engineer, I started the whole project by compiling a set of requirements for the radio.
- It should be built into a Tivoli Radio housing, keeping the Tivoli design and sound where possible.
- It should of course work as a Squeezebox device to be used with iPeng.
- It should be portable and run on battery so that it could be used in the garden or carried around the house.
- Obviously #3 meant it also had to run on WiFi, not a wired network.
- It should be quick and easy to use, which meant it needed on-device controls for volume and to start and stop playing.
- Since it had to be small and music would typically be selected using an iPad, there was no need for a display. It would still be nice to have, but if space is too limited (and it turned out to be this way), it’s optional.
- The whole design should make it sufficiently easy to use: simple power button, charging simply by connecting it to a power supply…
So I went on and started to search for solutions and components to build these features.
Tivoli Alarm Speaker
One thing that I quickly realized was that the Tivoli Radio is not the best fit for the project. It’s pretty small and already crammed with electronics, and it has this big radio station controller that can’t really be made into a volume controller because it has all the frequency information on it.
But I discovered something else: There’s a version of the Tivoli Radio called “Model 3”, and for that one there’s an optional second speaker to get stereo sound (the Tivoli Radio is mono). It also doubles as an alarm clock, which I also found intriguing (but before getting all too excited about this, please have a look at the “Lessons Learned” chapter, too, since the alarm clock feature came at a price…). This thing looked just perfect as a base, and so I bought one on eBay (a new one, but used ones can easily be found, too).
Raspberry Pi and HiFiBerry MiniAmp
The next problem was to find the right computer and audio. The Tivoli speaker is a passive design that is normally powered by the amplifier in the main radio. This is a pretty big amp running on 12V, so the original idea was to use an amplifier board for a Raspberry Pi (which usually also runs on 12V), but that would have required a 12V battery with matching charging electronics. All of that is readily available, but it’s not all that simple and also usually quite bulky, and the housing is really small.
That’s when I learned about the HiFiBerry mini amp. It’s a small amplifier with only 3W output, but it runs on 5V, can be powered through the Raspberry Pi, and it comes in the Pi zero form factor.
This seemed to be exactly what I was looking for. I could use the small Pi zero – really helpful with the available space in the speaker –, stack the mini amp on top of it and – very important – run it all with a standard USB power bank like they are being offered as backup batteries for mobile phones (available in all kinds of sizes).
The only question was: would this be powerful enough? Thanks to Maker Faire (at the time the Pi zero was still hard to get) and to HiFiBerry (who gave me an early model of the Mini Amp), I could build a test setup early on and connect it to the Tivoli Speaker… et voilà… it worked just fine. The volume will probably not be enough for a dancing party, but for normal use, especially indoors, it’s more than loud enough, and the speaker characteristic sounds just fine even with the low-power output.
One important remark: unlike their bigger brethren, neither the Pi zero nor the Mini Amp come with the extension connector soldered onto the device, so you need some minimum soldering skill to solder on the pin and socket connectors banks.
There’s one more critical component, and that’s the battery. As stated before, power banks for 5V USB output are readily available, but I had an additional requirement: I also wanted to power the alarm clock, and it should be independent of the radio being on or off. This meant I needed two USB outputs.
Additional requirements were that the power bank should be able to charge while operating the outputs, and it should automatically detect a device on the output so that it would turn on the power if the Raspberry Pi gets switched on because I wanted to place the battery inside the housing without being accessible.
In the end, this limited my choices a lot, and the smallest power bank I found was a 10,000 mA model that took up significant space in the radio.
On the upside, the 10,000mA are an awful lot of power for a 5V system that typically draws well below 1A, so this gave me an incredible battery life. In my tests I got a 24h operation for the player with around 7h of playback at 75% volume and 17h of “standby” or more than 12h of playback at full volume. More than enough for any reasonable use case and plenty of margin for aging battery cells.
The other critical component was a rotary encoder for volume control. I decided to use a model with an additional “push button” functionality, which I use for the play/pause functionality. So you can just push the button to start/stop playing and rotate it to change the volume.
Rotary encoders are easy to find, but a button that fits the design of the radio was much more difficult. You can see the result in the pictures above and below.
The rotary encoder can be connected to three unused GPIO-pins of the Raspberry Pi (please refer to the HifiBerry web site as to which pins are being used by the Mini Amp), two for the rotary encoder and one for the push-button. I used BCM 23 and 24 for the rotary encoder and BCM 25 for the button.
One great feature of the Raspberry Pi is that it has software-activatable pull-up resistors in its design. So you don’t really have to create a signal level for the GPIO pins yourself, you just connect the signal pins of the encoder/button to the GPIO pin and the reference pin to ground and the Pi does the signal creation. No additional pull-up resistors, and no connection to 3.3V needed.
These were the major components, but in addition there’s also a lot of “small” stuff that’s needed to make the whole thing work. Here’s an overview and a description of the components:
- The Tivoli Speaker;
- Raspberry Pi zero;
- HiFiBerry mini amp;
- the rotary encoder and knob;
- a USB-Wifi adapter with external antenna. The Pi zero doesn’t have any network hardware on board, so you need an external WiFi dongle. I wanted really good reception, and the housing of the radio significantly shielded the signal, so I used an external antenna and needed an additional antenna cable to connect the WiFi dongle;
- a 12V step-up converter. One thing that was still running on 12V, albeit on very low power (10mA), was the alarm clock. To supply this, I used a USB-to-12V step-up converter (a small dongle). Those devices are a bit critical to use with anything that draws significant power since they are not very efficient and can get really hot, but fortunately the alarm clock only has a very low power draw so it was not a problem in this case. I removed the output connector and replaced it with a pin-connector directly soldered to the alarm clock board.
- USB cables. Several. The Pi zero has micro-USB connectors for power and USB bus (here used for WiFi), so I needed USB-to-micro-USB adapter cables to connect the power bank and the WiFi dongle. The cable to the power bank isn’t directly connected but leads to a switch first which switches the 5V line to provide hard power on/off capability.
To connect external power, I used a USB-B connector (the one used in printers) I mounted into the back of the radio because it’s much easier to plug/unplug than micro-USB. That connector then connects to the micro-USB charging input of the power bank.
A long USB-A-to-B cable (“USB printer cable”) is used to connect the radio to the power supply.
- Power supply. A standard 2A USB power supply.
- Power switch. Connects to the power-bank-to-Raspberry-Pi connection cable and switches the 5V line.
- Boards, pin connectors and wires to connect all of the components.
- A micro-SD card for the operating system and software.
Even though the Tivoli Speaker has much more empty space than a normal radio and even though the Pi zero and Mini Amp are so small, all components together turned out to fill out the available space quickly.
Especially the big battery and all the cables took up a lot of space so that packaging all the components efficiently was really important and required several tries until I finally got it right.
Here are some images of the pre-assembled subassemblies: the radio frame looks empty, but that’s without the battery and the cables. Note that this image still shows the antenna inside the housing, something I eventually changed.
I mounted the battery using velcro, for the small boards I used existing mounting points, plus I glued some additional ones to the housing (for the two boards seen at the bottom).
Getting all the small connectors in place for the final assembly turned out to be the most difficult activity, and I had to try and re-start it several times until everything finally fitted.
Another important aspect: My design doesn’t have the SD card accessible without opening the housing of the radio, so I had to pre-configure the software for working WiFi access before assembling all components. See chapter “Software”.
With all the packaging finally completed, the end result doesn’t show how difficult the assembly was:
Some of you might also be interested to learn what the whole thing cost. Here’s an overview. Considering the difference in VAT/sales tax and exchange rates 1 € currently roughly equals 1 US$ so I’d expect price figures to be similar in the US and Europe:
- Tivoli Alarm Speaker: 37€ (new devices currently offered by the manufacturer at 69€, mine – also new but bough off eBay – cost 37€)
- HiFiBerry MiniAmp: 20€
- Powerbank: 19€
- WiFi-Adapter with external antenna: 14,50€
- Power supply: 10€
- WiFi antenna cable: 9€
- Micro-SD-Card, 8GB: 8€
- Knob: 6€
- USB-A-B-cable (for power supply), 2m long: 6€
- Raspberry Pi zero: 5€
- USB-to-12V-Step-up-converter: 5€
- Rotary/Push Encoder: 3,50€
- 3x Micro-USB adapter cable: zusammen 7,50€
- USB-B socket: 2€
- Power switch: 2,50€
- Miscellaneous (connector pins, distance bolts, wiring…): 8€
So overall the radio cost around 163€ worth of material. Using the new Raspberry Pi Zero Wireless (see “Learnings”) alone could reduce this by around 21€ (albeit only when using the internal antenna). Money you could spend in a more fancy rotary encoder if you like 😉
The hardware is the more visible part of the project, but some software was needed, too.
Since this device should only be a player, not a server, I decided to use piCorePlayer (pCP) as a software distribution.
The main advantage over other distributions is that it is designed to completely run in memory and doesn’t use the SD card while running. The advantage is that you can always turn the device off by cutting the power without leaving the system in an undefined state. No shutting down, no problems when the battery runs out.
piCorePlayer is easily configurable through a web interface once it’s connected to your network.
Since I don’t have the SD card accessible from the outside, I had to pre-configure it before assembly – including the WiFi setup. This is a bit unfortunate, it would be good if pCP or some of the other Squeezebox-based Raspberry Pi software distributions provided a setup mode that automatically creates an access point whenever they can’t connect to WiFi, the way e.g. Volumio does it. This would make such a radio much more accessible.
It worked for me, but it’s probably the biggest inconvenience for Pi-based DIY solutions.
Another problem for which I didn’t find a satisfying solution was the control button.
I found some scripts to use buttons and rotary encoders with Squeezebox players on a Raspberry Pi, but most of them either seemed to assume that the server was running on the same device, or they used a complete user interface like JiveLight, or they hard-coded the server connection – something I didn’t like because the target network setup used dynamic addresses for the server, too.
Also, the solutions I found didn’t really give me the volume characteristic I wanted.
So I wrote my own, called SqueezeButtonPi Daemon or sbpd.
You can find it on GitHub at https://github.com/coolio107/SqueezeButtonPi-Daemon
And if you use piCorePlayer, too: For Version 3.1x there is now a ready-made beta version of an extension module for sbpd: Details can be found in the Slimdevices-Forum.
As you might expect from the penguin, it does have a number of nice features that can make your life easier when building a radio:
- If you run any Squeezebox player on the device, sbpd can automatically detect which server the player is connected to. This even works if you switch servers during operation, so if you use more than one server, you can switch your radio around as you like.
- sbpd autodetects the MAC address used. It uses the same algorithm as SqueezeLite, so if that’s what you use as a player, and you haven’t manually configured it, sbpd should automatically find the right player-id.
- I only used volume and play/pause, but sbpd can be configured to use more buttons if you have them.
- It can run as a daemon on system startup and will then be readily available when you start the player.
- Of course you can also configure it manually through the command line.
- It can work with authenticating servers (username/password).
If you think about making your own Pi-based radio with buttons and rotary knobs, have a look at it, it may be useful for you.
As usual with such a project, some things didn’t turn out as expected, some things turned out not to be not the best choice and some things might get improved.
Here’s a list of these findings.
- Alarm clock radio. This looked like a nice idea, but with hindsight I would probably prefer to use one of the Tivoli speakers without the alarm clock (there are some, too). The alarm clock takes up more space in the housing than I originally thought, but more importantly it resulted in a number of additional requirements: the power bank needed a second output, due to this the power bank had to be bigger, I needed the step-up converter and all of this took up lots of space. The alarm clock is nice and it works fine, but it made it a challenging project for the packaging aspect, without the alarm clock it would probably have been really simple.
OTOH: in the end having such a huge battery is nice, of course…
- WiFi. It would be really helpful if any of the available distributions allowed automatic WiFi configuration without WPS (which requires access to the WiFi dongle).
- Good rotary encoder and knob. Finding a good rotary encoder and knob is hard. I searched for quite a while, and I’m not 100% happy with the haptics of the result. For my next project, I plan to search for a better one; but if you want to do the same: expect the rotary encoder to be the single most expensive component in your project. More expensive than the Pi or the audio card and probably even more expensive than the radio you are modifying.
- Raspberry Pi zero Wireless. Just in time after the publishing of this article, the Raspberry Pi foundation announced the new Raspberry Pi Zero Wireless. It comes with a built-in WiFi adapter that would simplify (and cheapen) the whole setup quite a bit. At least, if the integrated antenna works well enough for you, I would strongly recommend to use this new Pi.
But that’s already it. Of course there’s always more you can change, like having more buttons, adding a small display… But for this project, I’m really happy with the result. It looks stylish, it has its own controls, it works very table and reliably, and it sounds fantastic for such a small radio, too.
So if you consider building one yourself: do it!