opensourceprojects.dev

A broadsheet for software that doesn't ask for your email

Turn your ESP32 into a Bluetooth speaker with this Arduino-friendly A2DP library
GitHub RepoImpressions4

Project Description

View on GitHub

Turn Your ESP32 Into a Bluetooth Speaker (No Extra Hardware Required)

If you've ever wanted your ESP32 project to stream audio from your phone or laptop, you know it's usually a pain. You either need extra components, complex libraries, or you're stuck with low-quality audio.

This library changes that. It implements the A2DP (Advanced Audio Distribution Profile) protocol directly on the ESP32, using its built-in Bluetooth. That means you can turn your ESP32 into a Bluetooth speaker with just a few lines of code, no external DAC or audio module needed.

What It Does

The ESP32-A2DP library by pschatzmann is an Arduino-friendly implementation of the Bluetooth A2DP source (transmitter) and sink (receiver) profiles. In simpler terms, your ESP32 can:

  • Act as a Bluetooth speaker (receive audio from your phone)
  • Act as a Bluetooth audio source (send audio to another speaker)
  • Handle multiple connections
  • Output audio via I2S, internal DAC, or even just PWM

It's designed to work with the Arduino framework, so if you've used ESP32 with Arduino IDE or PlatformIO, you're good to go.

Why It's Cool

Here's what makes this project stand out:

No external hardware required. You can use the ESP32's built-in DAC to drive a simple speaker directly. No need for a dedicated audio decoder chip like a MAX98357 or PCM5102.

Real A2DP, not fake Bluetooth. This isn't some stripped-down audio protocol. It's proper A2DP with SBC codec support, so audio quality is comparable to a standard Bluetooth speaker.

Simple API. You can literally get audio playing in 5 lines of code. Check this:

#include "Audio.h"
#include "BluetoothA2DPSink.h"

BluetoothA2DPSink a2dp_sink;
Audio audio;

void setup() {
    a2dp_sink.start("ESP32_Speaker");
}

void loop() {
    // nothing needed
}

Works with both source and sink mode. You can stream audio from your ESP32 to a Bluetooth speaker, or receive audio from your phone. Both directions work.

Good documentation. The repo has working examples for I2S, internal DAC, even a web-based volume control.

How to Try It

You have two options:

Option 1: Arduino IDE

  1. Install the library via Library Manager (search "ESP32-A2DP")
  2. Open File > Examples > ESP32-A2DP > SimpleSink
  3. Upload to your ESP32
  4. Connect your phone's Bluetooth to "ESP32_Speaker"

Option 2: PlatformIO

  1. Add lib_deps = pschatzmann/ESP32-A2DP to platformio.ini
  2. Copy one of the examples from the repo
  3. Build and upload

For the simplest test, just connect a small speaker to GPIO25 (DAC output) and GND. That's literally all you need.

Final Thoughts

This library fills a real gap. A lot of ESP32 audio projects focus on voice assistants or MP3 playback from SD cards, but streaming audio from your phone is something people actually want.

If you're building a retro radio, a custom Bluetooth speaker, a smart mirror that plays podcasts, or just want to learn about A2DP on embedded hardware, this is a solid choice. It's not perfect (SBC only, no AAC or aptX), but for casual audio it works surprisingly well.

Give it a shot. You'll probably have audio playing in under 10 minutes.


Brought to you by @githubprojects

Back to Projects
Project ID: 08de836b-6597-4ea1-91a8-94450fec752eLast updated: July 12, 2026 at 05:47 AM