2

How to Stream Music with Home Assistant Using a DIY ESP32 Bluetooth Transmitter

Share

Introduction

In this blog post, I’ll walk you through how to stream audio from Home Assistant to any traditional Bluetooth speaker without breaking a bank. It’s perfect for repurpose an older, non-smart audio equipment, giving them new life in your modern smart home system.

Streaming music with Home Assistant allow you to centralized control all your audio devices from a single interface. You can easily set up multi-room audio by streaming synchronized music across multiple speakers. Moreover you can also create an automations to create a routine streaming or link to other smart home actions.

To connect the Bluetooth speaker to Home Assistant, I’ll use a ESP32 module with Squeezelite-ESP32 firmware to create a DIY Wi-Fi to Bluetooth transmitter. I also designed a compact dongle-style 3D print enclosure to house the module, making it even more convenient to use.

Tivoli Model One Upgrade Feature Image

For this project, my goal is to automate internet radio streaming to my original Tivoli Audio speaker, which I upgraded it with DIY Bluetooth module.

If you’re interested, you can check it out in my previous post: Tech Upgrade for Tivoli Audio Model One

About Squeezelite-ESP32

The Squeezelite-ESP32 is a client software for Logitech Media Server (LMS) that run on ESP32 microcontroller. It allows the ESP32 to act as a network audio player, receiving and playing audio streams from LMS.

Additionally, LMS supports sending audio to a variety of devices, including UPnP, Sonos, Chromecast, and AirPlay, and can synchronize multi-room audio by streaming to multiple devices simultaneously.

Squeezelite-ESP32 support any esp32-based hardware with at least 4MB of flash and 4MB of PSRAM. The ESP32-WROOM modules will not work as they didn’t include PSRAM.

COMPONENTS FOR THIS PROJECT

  • ESP32 WROVER-B Module: Aliexpress | Shopee Thailand
  • USB Male Breakout Board: Aliexpress | Shopee Thailand
  • M2 Self-tap Screws: Aliexpress | Shopee Thailand

3D Print Parts:

3D Print Enclosure

I’ve designed the enclosure to be as compact as possible to ensures that the transmitter are fits into your space without adding clutter.

I’ve included two versions: a dongle style with a USB type-A male connector, and a more compact version powered by a USB cable.

The dongle style eliminates the need for a separate power cable, making it very convenient to use. You can simply plug it directly into a USB outlet.

Both versions feature a slot that snugly fits the ESP32 module, with the top and bottom parts secured together using M2 self-tap screws.

For the dongle type, you’ll need to connect the power from a USB male breakout board, as shown in the following diagram.

The breakout board is secured to the bottom of the enclosure with M2x6 self-tap screws, and three additional M2x8 screws are required to secure the dongle-type enclosure.

Flashing Squeezelite-ESP32 Firmware

To install Squeezelite firmware, I follow instruction shared by Nuthand posted on Home Assistant Community. I found out that it work after flashing without needed for any update. Just make sure that you use I2S-4MFlash 16 bit version.

1. Install Squeezelite Firmware:

Start by navigate to Squeezelite-ESP32 Installer page. Connect the ESP32 module to your computer with a USB cable.
Once the ESP32 module is detected, select Generic/I2S and click “Connect to device” and choose INSTALL I2S-4MFLASH-16.

2. Connect to Wi-Fi:

After successfully install, connect to the ESP32 access point. The AP name typically starting with “squeezelite.”
Open Wifi setting page (http://192.168.4.1). Select your home wifi hotspot from the list and enter your wifi password, then click to Join.

When connected it should show the network status. Make note of the Device IP address. And reset the device.

3. Configure Audio Settings:

After the device connect to your home network. Navigate to the device setting page using the device IP address.
Now you should enter setting page in recovery mode. Go to Audio tab and switch output to Bluetooth. Click Save.

Optionally you can change device name appear in Home Assistant by change device name in System tap. I also disable both cspot and Airplay since I didn’t plan to use both services.

4. Finalize Setup:

Press the Exit Recovery button at the bottom of the page, and the system will reboot.
After reboot, if your Bluetooth speaker is in pairing mode it should show up in Status tab.

5. Connect to Bluetooth Speaker:

Select your speaker from the list of available Bluetooth audio device name in Audio tab. Click Save and Apply. The ESP32 should now connect to the selected Bluetooth device. If it doesn’t, you may need to power cycle your device once more.

If everything is working as expected, the ESP32 should automatically pair with the selected Bluetooth speaker whenever both devices are available.

For full automation, I recommend connecting your speaker to a smart plug so you can automate your streaming through Home Assistant. This ensures seamless, hands-free music playback as part of your smart home setup.

Trouble Shooting:

  • If you found Option error: when boot up. You can fix it by remove the option that raise the error from autoexec1 field in NVS Editor tap. You can turn on NVS Editor tap in Credits page.
    In example below I will remove only -d and leave the rest of the line as is. Don’t forget to save change before reboot the device.
  • If your bluetooth speaker not show up in the list in Audio tap. You can set it manually by fill in its name (as show in your phone) to a2dp_sink_name in NVS Editor tap.

Integrate to Home Assistant

To use the Squeezelite-ESP32 player, you’ll need to have a LMS server running. I didn’t plan to use LMS to manage any music library, so I’ll be using the LMS server add-on in Home Assistant for this purpose. If you already have an LMS server running, you can skip this step.

To install LMS Lyrion Music Server add-ons.

  1. Navigate to Home Assistant Settings -> Add-ons.
  2. In add-on store, add custom repository using this link (https://github.com/pssc/ha-addon-lms/).
  3. Now LMS add-on should appear in add-on store. Install it and start the add-ons.

Add player to Home Assistant.

  1. Navigate to Home Assistant Settings -> Devices & services.
  2. Add new integration, search for “Logitech”. And add Squeezebox (Lyrion Music Server).
  3. The LMS server IP address should detect automatically and then you can add it to Home Assistant. The player will be show as a media player device in the integration.

Conclusion

This DIY ESP32 Bluetooth transmitter is affordable solution to connected traditional Bluetooth speaker to Home Assistant. It’s very compact and easily integrates into your current system, just plug it into any available USB outlet, and you’re ready to stream audio throughout your home.

By integrating it with Home Assistant, you can centralize your audio streaming and easily create automations that link your music to various smart home actions, resulting in a fully integrated and efficient system.

Whether you want to wake up to your favorite playlist, sync music across multiple rooms, or trigger specific audio responses based on different events in your home, this setup makes it all possible with minimal effort.