Stream audio from HA to your bluetooth receiver with an ESP32

I managed to get a bluetooth receiver playing audio from Home Assistant. It uses a pretty bare ESP32 which functions as an A2DP Source (Music Sender) which itself receives its input audio from Home Assistant via WiFi.

Like this:
Internet radio → Home Assistant → local WiFi → ESP32 → Bluetooth receiver / speaker

I couldn’t find any clear tutorial on the web and setting up the ESP was pretty confusing as there are tons of options in the ESP32 squeezelite project and most users want to build a whole audio kit with the ESP. I just wanted the WiFi - BT “translation”.

Hopefully I can help someone by writing down my steps to get it working.

There are three main activities

  1. Get the ESP, flash and configure it
  2. Install LMS addon in HA
  3. Setup Squeezebox media player integration in HA

1. Get the ESP, flashing and configuring.
I found these the most complex steps

  • get ESP32 WROOM unit (ESP32-WROVER-B 4Mb Flash 8Mb Psram) like this one on AliE
    https://a.aliexpress.com/_dY83WTf
    an ESP32-A1S might work similar, I haven’t tested.
  • flash the ESP via the website
    Squeezelite-ESP32 Installer
    pick generic
  • connect to its WiFi AP, pwd: squeezelite
  • go to 192.168.4.1
  • connect it to your own WiFi, reboot
  • go to the ESP web interface on your network
  • menu updates → pick a 16 bits version, I selected I2S-4MFlash-1335 (don’t know what version is the best, this worked for me)
    not sure how I selected it but after quitting recovery mode it displayed at the bottom:
    fw: I2S-4MFlash-1335, mode: Squeezelite-ESP32
  • menu Credits → show NVS Editor
  • menu NVS editor appears and open it.
    a2dp_sink_name → is the name of you bluetooth receiver (as you see it in your phone when it outputs to that receiver)
    bt_name → unclear if it has to be set? just do it
    a2dp_dev_name → unclear if it has to be set?
    enable_bt_sink → possibly, i guess not needed, but try it.
    telnet_enable → y
    → Commit, reboot
  • menu hardware, no adjustments
  • menu system, no adjustments
  • menu audio, (for some reason this page keeps forgetting my adjustments, not sure if its faulty flash on the ESP or something I’m doing. Once i’ve set it, plus the NVS editor, my ESP works though)
    select output to bluetooth
    resample to Default
    rate to 44100

2. Install LMS addon in HA
Add Phillip Camp’s repository

install the LMS Addon
Not much to configure, start it and it should detect the ESP unit automatically

3. Setup Squeezebox media player integration in HA
Add, search for logitech, then pick the Squeezebox (Logitech Media Server), it will scan and find your media player which can now be accessed thoughout Home Assistant! yay

Troubleshooting

  • Connect to the ESP via telnet (or serial if all fails) to discover what’s happening on the ESP.

Useful resources

4 Likes

Thanks very much for this write-up, this worked very well for me! i have the same “issue” with the audio page not remembering my settings, but it works.

Any video tutorial for this setup?

Kindly reply

Do you have a video tutorial?

If i have a dac connected to esp32 with a speaker. will this process work?

Is the antenna architecture of the wrover chip different to the wroom, since with wroom it’s impossible to use wifi and bluetooth simultaneously as they share the same antenna. I can’t see different antennas with wrover chip. But since you already get this to work, I think it’s possible or did you expirienced any issues?

Thank you in advance.

Thanks for sharing this! It worked perfectly with my setup, and I found that the latest I2S-4MFLASH-16 version doesn’t require any updates.

I’ve also designed a compact 3D-printed enclosure for the ESP32 and documented the firmware installation process. I’m sharing it here in case anyone finds it helpful:

Have you tried the above with Music Assistant by any chance? Since it has inbuilt LMS running can we utilize that along with esp32 running Squeezelite?

I can confirm that esp32-wrover-b flashed with Squeezelite firmware is working fine with Music Assistant. We have to make sure the player provider Slimproto(squeezebox players) is added for it to detect the esp32. The only issue I am facing is, the name of esp32 is not getting reflected. It is showing as “unknown device along with MAC address” of its WiFi. However the playback is not impacted. I am able to play TTS notification as well as music without any glitch over Bluetooth Audio.

I am waiting for DAC to be delivered by this week end. Have you made any progress with this?

(Editing my previous one as per the forum rule asking me not post more than 3 posts)
I can confirm that esp32 running with squeezelite is running great with external DAC (UDA1334A) perfectly in stereo mode. I can share the details if anyone is interested.

My esp32 does not work when I hit install, I got failed.my board from the same recourse in this post. do I need to do something or my board damaged?

Which model is your esp32? The squeezelite requires SRAM, it will work fine in esp32 wrover-b boards and not in esp32 wroom. If it is esp32 wroom, try the esphome I2S yaml method that may work. I have found the I2S works fine for announcements, it frequently hangs when you play music. YMMV.