However, the Sonos One is a fairly pricey $200. But, if you have a speaker you like just lying around, you can turn it into an inexpensive Sonos speaker using a Raspberry Pi. Here’s how.
How I’m using the Raspberry Pi in my smart home
The Raspberry Pi kicked off a revolution, offering makers and tinkerers an inexpensive single-board computer that packed a punch. Fast forward to now and we’re on the fourth iteration of the Pi. You can run basically anything on it, even Windows (though why you would is your own business). For the longest time, I wanted a Raspberry Pi, but I had no idea what I’d do with one. But as I’ve expanded the technology in my house, and as I’ve locked everything down, I started having ideas for a Pi. The first project I did was to make a Pi-Hole device, which is basically a network-wide ad blocker. If you don’t want your smart TV or streaming stick collecting data on your viewing habits, Pi-Hole is an absolute must. My second Raspberry Pi served as my Home Assistant host. Going into detail about Home Assistant is outside the scope of this article, but it’s basically a home automation and smart home platform. But I quickly learned that my Raspberry Pi 4 wasn’t up to the task. So I converted the XDO Pantera Pico I reviewed a while back into my new Home Assistant host and it’s been great. But that left me with a spare Raspberry Pi, sitting in a drawer doing nothing. That was, until I stumbled on a new project to fill my free time. Enter balenaSound.
balenaSound: What is it?
If the prefix ‘balena’ sounds familiar, it’s probably because you know the developer’s most popular software, balenaEtcher (opens in new tab). This is a flashing tool, perfect for making live Linux USBs or Raspberry Pi SD cards. It’s one of the default recommendations right now since it’s cross-platform. Windows, Mac, Linux, it doesn’t matter. But Etcher isn’t the only project that balena has going on. In fact, there are several others, but one in particular caught my eye (well, two, but I digress). This is balenaSound (opens in new tab), an audio streamer that supports single- and multi-room layouts. When coupled with a Raspberry Pi, it turns regular old speakers into Wi-Fi speakers with multi-room capabilities like Sonos. It’s a Docker container that runs on top of balenaOS (opens in new tab), an operating system designed specifically for deploying Internet of Things (IoT) in containers. To manage your instance of balenaSound (or any other balena IoT project), you’ll control it through the balenaCloud portal. The OS uses the OpenVPN protocol to create a secure connection to your dashboard for deployments and management. Getting up and running is super easy. You’ll walk through the steps of creating a project, customize the OS image, and flash it to your microSD card. Slap that into your Raspberry Pi, hook up the speakers, and boom. You have Wi-Fi speakers that support AirPlay, Spotify Connect, UPnP and Bluetooth (and there’s snapcast support, too). In fact, the only thing I wish balenaSound had is Google Cast. I’d be more than happy to cover the licensing fee Google charges to turn my speakers into Cast targets. Keep in mind that with the free tier, you’re limited to 10 devices on balenaCloud. That should be fine for most residential purposes. Assuming you have the parts I’ll layout below, you can be up and running in about 10 minutes. There are configurations you can tinker with, but the basics are quite easy to deploy. It also helps that the documentation for balenaSound is quite solid, so don’t be afraid to do some reading.
How to make your own Sonos-like smart speaker using a Raspberry Pi
You will need the following parts to get started:
Raspberry Pi (3B+ or 4B is best)A power supply (check which one you need for your Pi)microSD card (8GB)Speakers3.5mm or RCA audio cables (if using a supported DAC)
Furthermore, you will need the following software:
An image writer (like balenaEtcher)A free balenaCloud accountYour customized balenaSound image
- Using the provided link, deploy balenaSound (opens in new tab). This will take you to a fleet creation dialog. Change the name if you wish.
- Select your device from the Default Device Type dropdown menu. Use the search function to find it quickly.
- Click Create and deploy.
- You will see your new dashboard for the fleet you just created. To start provisioning your Raspberry Pi, click + Add Device.
- In the dialog that appears, change your device type if necessary. Leave OS type, version and edition as default. If you plan to connect your Raspberry Pi to Ethernet, click the Flash button to flash with Etcher, or click the arrow and select Download balenaOS to flash it the program of your choice. If you want your Raspberry Pi to instead work off of Wi-Fi, click the Wifi + Ethernet radio button. Input your network’s SSID and password, then click the Flash button.
- Insert your microSD into your computer. Flash the image, either through the Flash button or with the downloaded image file.
- Eject the microSD card and install it into the Raspberry Pi’s slot (on the underside of the board).
- Plug in the power supply and connect the audio cable to your speakers. With the basic configuration, you will use the Raspberry Pi’s onboard audio via the 3.5mm headphone jack. If you have a DAC hat like the IQAudio DAC Pro (opens in new tab), you can use RCA audio cables.
balenaSound configuration and settings
Out of the box, balenaSound should work as long as you have the network settings correct. You should see it appear on your dashboard after the Raspberry Pi boots (this can take a few minutes). From here, you can manage the balenaSound instance and control the host. But you may not necessarily be satisfied with how things are. For me, I didn’t like the random target name in Spotify Connect and AirPlay. I wanted to change it to something different, which requires setting an environment variable. From the left menu of your balena-sound fleet dashboard, click Variables. Click the blue Add a variable button. Leave the Service section as All services. In the Name section, type SOUND_DEVICE_NAME. In the Value box, set whatever your want your speaker group to be. Bear in mind that this is global for the whole fleet. If you have multiple Raspberry Pis and you want them all to be separate names, go back to the dashboard and click the blue hyperlink with the device’s name. Click the Device Variables menu option You’ll see the SOUND_DEVICE_NAME variable here that you just set, but then there’s an Override button. Click that, and set a new name for that particular Pi. In addition to the fleet summary, there’s a device summary section where you view each device’s stats. This is where you’ll find the logs, access to the terminal (over SSH), service status, and the local (and public) IP address. There are several more variables to play with, like setting a custom input loopback latency to help with skipping. I have noticed that there’s a delay with Spotify Connect, but I’m still playing with my config to see what I can figure out. And when my DAC hat arrives, there are some things I need to tweak to get balenaSound to play with that properly.
Making my own Sonos alternative
All told, I spent less than $80 on this project. Compare that to the entry-level Sonos One SL, which costs $199. I have two decent speakers running a multi-room server, with the only pain point being a lack of Cast support. Of course, with the chip shortage, you’ll be hard-pressed to find a Raspberry Pi — my two local Micro Centers are completely sold out. And on the resell market, they command a pretty penny like every other piece of tech these days. I plan to run balenaSound on a separate machine in a Docker container to act as the multi-room master device and have each of my speaker Raspberry Pi groups act as clients. Thankfully, I have a dedicated server that is more than up to the task (it also handles my Plex server and will bear the brunt of my next project, Rhasspy). I don’t think balenaSound is a perfect solution, but it’s a work-in-progress. It’s not quite as plug-and-play as Sonos, but you can pick up excellent standard speakers on Craigslist or Facebook Marketplace and go with this method instead, likely saving money or outdoing what an price-equivalent Sonos can do. (You might even get lucky and score a great deal on some older speakers.) Plus, you get to manage the whole thing and tweak it to your liking. You can’t say that for Sonos. When I started out on this project, I had no idea how much fun it would be. Now, I significantly upgraded the audio in my office and my Raspberry Pi’s DAC hat hasn’t even arrived yet. I’m looking forward to hearing the boost in sound quality. I’m thrilled with how this turned out and I can’t wait to deploy more Wi-Fi speakers. When I eventually get rid of all of my Google Home speakers, I want to have easily streamable music in most rooms. Now I can sit back and enjoy better sound quality than what my MacBook Pro speakers or Nest Hub can provide.