I finally came across a speaker setup that I could try out for relatively inexpensively, that also uses open source software, and can be used for multi-room audio. I found the ESP32 A1S audio kit that is supported by squeezelite-esp and has a simple web installer. On top of that, there are a decent number of forum posts using it and providing details on configuration. This gives me a potential holy grail, open source, locally based, multi-room audio speaker. The main problem I will end up having is putting something together with good audio quality, and appliance level ease of use and stability, but thats a future problem, for now, lets check out squeezelite on the ESP32 A1S.
Goals
My goals for the speakers are pretty much the same for my main goals of the multi room audio system as a whole. An entire open stack, streaming music, podcasts, and audio books to anywhere in the house. For my initial delve into using them, I’ll be focusing on music alone since that will be the simplest use case.
- All Local
- Music
- Podcasts
- Audiobooks
- NFC control (via the NFC Deck, or Tag Readers)
- Sync between devices/rooms
Software options
There are a decent number of software options out there for open source multi-room audio. The problem mostly ends up being ease of setup and support. I ended up looking into the following options for server/client software on the speakers and home assistant.
- Client
- Esphome
- Squeezelite-esp32
- Snapcast
- Server
- Music Assistant
- Snap Cast
- Logitech Media Server
- Home Assistant
For my software stack, I’ll be using squeezebox as my client side software and music assistant for the server. These seem to be the most straight forward, and I already have music assistant setup and hooked into my Plex library. I’ve nosed at snapcast over the years but never got around to figuring out how to set it up and interact with it. I considered using home assistant as the main server but that doesn’t support multi room audio / sync yet with squeezebox, the integration is still pretty simple. According to the forums, the ESPHome firmware can’t output via the audio jack on the board, and I’m unsure of it’s compatibility with music assistant and multi room audio. Snapcast clients on the other hand have sync capabilities second to none, I just would need to learn a lot more before trying to install the server, let alone the clients which aren’t as well supported on ESP devices.
Design
The main data flow path will be feeding my music and playlists from Plex to the speakers, using music assistant as the mediator to control playback, etc. Music assistant can also source from other music providers like Spotify or just an NFS share of music files. This will let me expand the sources to hopefully include audio books, podcasts, and more in the future.
The primary control flow for my system is going to be from an NFC Deck in each room. These have rotary encoders in them that will be used for volume control and mute, button inputs for play/pause/group/ungroup, and an NFC reader that will be used to select the music to be played on the speakers. The home assistant app will also be available to use as well, directly controlling them through music assistant.
Hardware Features
I found the esp32-audio-kit through some forum posts which mentioned it supported squeezelite and had a small 3 watt amp. This fit what I wanted for some initial hardware, inexpensive, built in amp, pre-assembled, and squeezelite support. Even though I’ve made quite a few things using ESPs, I didn’t want to try and custom build these myself.
The board variant I ended up with was v2.2 A402. All the specs and features from the product are below. For some preliminary testing I got some tiny speakers to use with it. These won’t be the final speakers but are something I can play with while looking for better speakers. I can also make use of the little speakers in future projects where audio quality doesn’t matter as much.
Case
I found a few potential cases I could use to hold the ESP32-A1S units.
In the end, I used the case design by Edward Krayer and gave it a bit more flair. I added a music logo to it, which when I printed it multi-color with a clear-ish PLA, it glows with the LEDs on the A1S inside it. My updated case design can be found on printables.
I plan on building two speakers to start with. The first will use some slightly more powerful speakers I picked up some speakers on amazon to try out. These should be close to the max output of the A1S. I’ll also have to redesign the case to hold these and make a nice compact all in one unit.
My second speaker also needs a case modeled up, this one will be using an old Bluetooth speaker for it’s speaker.
I’ll provide a full write up of my custom speaker cases in a separate blog post, here are the final photos of them.
Flashing
Use the top USB port (marked for UART) to flash the board. The bottom port provides power but no data signal to the ESP.
On the road to flashing my ESPs with squeezelite, I did run into one hiccup with a web installer. The first squeezebox web installer I tried had an option to install the I2S version, but no matter what option you chose for the installer, it installed the muse version which won’t correctly run on our ESP. So just FYI, don’t use this web installer: Squeezelite-ESP32 installer (paulusschoutsen.nl)
For the unit I flashed with this installer, I ended up using the OTA updater built into squeezelite to flash the correct version of the firmware. For the second unit, I used the next web installer. This one did flash the correct firmware (I2S), so use this installer: Squeezelite-ESP32 Installer (sle118.github.io)
Configuration
Once the flashing is done and the ESP boots back up, you’ll find a new WiFi network you can connect to and set it up with. The network will have squeezelite in the name and the password is “squeezelite”. Once on the Wi-Fi, select the network you want it to connect to and provide the password.
Audio Configuration
The next step in our configuration is to give squeezelite the IP and Port for the Music Assistant slimproto server. To get this information, we go into the Music Assistant settings, find the slimproto player provider, and go to it’s configuration.
Now we just go into the advanced configuration options and find the slimproto port. We don’t need to change anything here, just note the port number we’ll be using to communicate over.
Now provide the IP of home assistant and the port number of music assistant in the squeezelite webui.
Hardware Configuration
For the hardware configuration, I first tried the built in configuration for the esp32-audio-kit, however I found that configuration lacking. Instead I found a configuration on the home assistant forums here that worked out well. I’ve included the comment with the configuration below.
dac_config: model=ES8388,bck=27,ws=25,do=26,sda=33,scl=32,i2c= 16
set_GPIO: 21=amp,22=green:0,39=jack:0
stereo speaker connecth through headphone-jack.
Music Assistant
Once I had the audio settings setup in squeezelite. The units rebooted automatically. I then went into music assistant to look at the players that were available and I found my two demo units.
I was also able to activate them and start streaming to them. Next up is setting up the group player in music assistant and trying to run them both at the same time.
Group Player
Setting up a player group in music assistant is straight forward to do. Go to the settings in music assistant. Select players and the UI will give you the following:
From here, we can add a new group player.
Since we’re using all squeezelite speakers, we’ll be making a slim proto group player.
Add all our current speakers to the group and we’re good to go.
Now when looking in the sidebar player list in music assistant, we can find our group player with all the squeezelite speakers in it.
Playing to a group of players is done in the exact same way as playing to an individual one. Individual volume can be controlled, or volume of the entire group.
I had both of them set apart by just a few feet so I could judge the audio sync and it was actually pretty good. Easily good enough for multi room audio, even within the realm of running them in one room and not wanting to rip out their power cables. We’re getting close to having multi room audio!
OTA Update
The web UI allows you to load new versions of squeezelite or any other firmware onto the unit. It also provides a nice little interface for finding new versions too.
It does require Internet access to work, which means my IOT VLAN won’t let me update directly that way, but I can still upload a new firmware. There are also options to pull the firmware from a specified URL, which means you could host it on a LAN webpage for squeezelite boxes to pull from when they don’t have internet access, or do a direct upload of the firmware to the device.
Automations
My automations are focusing around the NFCDeck capabilities, so button presses, rotary encoder, and NFC are the main drivers for controlling everything. The play/pause and play music (artist/playlist) automations basically match the ones I made for controlling PlexAmp. In this case, they are just calling the advanced Music Assistant action because that simplifies some of the actions needed.
Play/Pause Automation
Music Assistant and Squeezelite players can be controlled similar to other media players with the play pause media player action. These can be used on both the group players and individual ones.
Play Playlist Automation
Music Assistant has an easy to use action that can be used when building out these automations.
For actually selecting and playing the music, we’ll be using the Music Assistant play music advanced action. This has a nice to use set of features letting us select what device we want to play the music on, what the name is, and what type of media we want to play.
Play Artist Automation’
One thing I did find out about the play artist automation is that I could not enable the radio mode. With it enabled, the automation would fail and not run due to an error. I didn’t dig into this further, just noted it so that I wouldn’t run into it in the future.
Mono settings
Squeezelite doesn’t have the ability to change mono/stereo options in itself. However Music Assistant does have that ability to change how it sends the music to the players. Here we can choose whether or not our players are mono or stereo. It can be accessed by going to the Settings -> Players menu, clicking on the drop down menu for a player you want to update, and hitting Configure. Below are the settings for one of my demo units that will be mono.
ESP32 A1S onboard switch settings
I’ve yet to use the buttons on the ESP32-audio-kit, but I did run into some information about them. According to the forums, the optimal settings for these switches are:
If you’re having issues with keypresses, try setting your dip switches to: ON – OFF – OFF – OFF – ON.
Future Work
I still have a lot of work to do in making a fully functioning multi-room audio system. This includes:
Hardware
I need to make enough NFC decks and squeezelite units in order to cover all the rooms that I want to have in the multi-room audio system. On top of that, I will need to make quite a few NFC tags in order to cover the options needed, and preferably, make them unique/recognizable.
Automations
The future updates to my automations will be to write the NFC tag to have all the data needed for the automation call. I think a format for that data along the lines of
Music: <Type>: <Name>
With this, I should be able to parse the strings in home assistant and build the automation call on the fly for music assistant, the current tags that I have would then be formatted this way:
Music: Artist: Avenged Sevenfold
Music: Playlist: Instrumental
This way, I can make an automation listening to all NFC tag events, check if they’re music related, then parse the necessary data for the automation to run. This should make it simple to both have multiple copies of the same NFC tag, but to also have potentially dozens of unique NFC tags for this. There are also music assistant supported data formats provided by the TagReader source that will provide play URLs for different types of sources, these might also be useful to use.
I also need to create automations tying the rotary encoder into the squeezelite volume control, group join/unjoin, and media player on/off. The on/off controls will be tied into the main play/pause and play music controls to ensure the device is ready to go when you want to play some music. The group join/unjoin will be tied into some of those controls as well to ensure the units join the rest of the audio playing in the house when needed.
Stability
I’ve seen some odd things happen when I unplug players to move them, and odd glitches where they’ll stop playing. For this to have a good approval in the house, and to be generally useful, it does have to be stable. If I can’t get it to run consistently and in expected ways, I’ll end up not using it due to it being buggy. So I need to hunt down bugs, and build more intelligent automations to keep the system reacting as expected.
Some Additional Side Notes
- The play automations seem to take a few seconds to execute
- The pause automation is near immediate
- The squeezelite players can either connect to home assistant or music assistant but not both
- They have an IP:port setting and both home and music assistants need that port to talk to the devices, so it prevents them from talking to both
- I only connected them to music assistant so I’m not sure what it would look like to hook them up to home assistant and then use them in music assistant
- Music assistant let’s you set mono or stereo, while Squeezelite doesn’t have a setting for that. Make sure your speakers are configured right in both locations.
Conclusion
I’m pretty happy with how far I’ve gotten in the multi-room audio journey so far. There’s a long road ahead to get to a full NFC controlled multi-room jukebox, but I feel like these first steps will be the hardest along the path there. For now, I’ll be making minor tweaks and optimizations in the automations and start building out more of the hardware needed for controls and playback.
Related Posts
Resources
- Blog Posts, Threads, Etc
- Parts
- Other ESP Audio Products