← Projects
electronics advanced 6 days ago ◑ 33 views ◯ 5 min read

Build a Bluetooth A2DP Audio Transmitter with ESP32: Turning Any Line-Out Device Wireless

Build time: 4-6 hours
Tools needed: Soldering iron, ESP-IDF toolchain installed on a computer, small Phillips screwdriver, wire strippers
ESP32BluetoothA2DPaudio transmitterESP-IDFI2Swireless audio
Parts List

Our guide on turning a Raspberry Pi into a Bluetooth speaker receiver solves the opposite problem from this one: that build takes Bluetooth audio from your phone and plays it on wired speakers. This project goes the other direction — taking a wired line-out source (a mixer, an old stereo receiver, a turntable's phono preamp output, a TV's headphone jack) and broadcasting it as an A2DP Bluetooth source to any standard Bluetooth speaker or headphones. It's the DIY version of the little Bluetooth transmitter dongles sold for exactly this purpose, but built on an ESP32 so you can add features like multi-device pairing memory or a physical source-select button.

Why a Transmitter Is a Different Problem Than a Receiver

Acting as an A2DP sink (the receiver project) is the easier half of Bluetooth audio — your device just needs to accept an incoming audio stream and play it. Acting as an A2DP source means your firmware has to behave like a phone or media player from the Bluetooth stack's perspective: advertise correctly, handle pairing and connection to a sink device, encode outgoing audio into SBC (or a higher-quality codec if the ESP32 and your chosen library pair support it), and keep that stream synchronized without underruns. This is a meaningfully different code path on the ESP32's Bluetooth stack, not just the receiver example run backwards.

Wiring the Line-In

You're capturing a line-level analog signal and need to get it into the ESP32's ADC or, for better fidelity, into an I2S ADC module rather than the onboard analog-to-digital converter. The onboard ESP32 ADC is usable for a quick proof of concept but has real nonlinearity and noise floor limitations for audio work; a dedicated I2S ADC breakout gives you a cleaner signal path and makes the rest of the firmware's audio pipeline symmetrical with a typical I2S playback project.

SignalConnection Line-out L/R from sourceInto the I2S ADC module's stereo line input, through a simple voltage-divider or line-level attenuator if your source outputs more than the ADC's expected input range I2S ADC BCLK/LRC/DOUTTo three ESP32 GPIOs, matching the pin assignment in your firmware's I2S config GroundCommon ground between source device and ESP32 — use a ground-isolated line input if your source and the ESP32 are powered from different circuits, to avoid hum from a ground loop

Firmware: ESP-IDF Bluetooth A2DP Source

Build this with ESP-IDF rather than the Arduino framework — ESP-IDF's Bluedroid Bluetooth stack has a documented A2DP source API (`esp_a2d_source_init` and related calls) that gives you direct control over the connection and streaming state machine. The firmware structure is roughly: initialize Bluetooth in classic BT mode (A2DP is a Bluetooth Classic profile, not BLE), scan for or accept a pairing request from your target sink speaker, establish the A2DP connection, then feed PCM audio frames from your I2S input buffer into the A2DP source callback as they arrive. Keep your I2S sample rate at a standard 44.1kHz or 48kHz to match what your downstream Bluetooth speaker expects without resampling.

Pairing and Multi-Device Memory

Add a physical button or a short boot-hold gesture that puts the ESP32 into pairing/discoverable mode on demand, rather than always being discoverable — this avoids it accidentally reconnecting to the wrong speaker if you have several Bluetooth A2DP sinks in range. Store the MAC address of your most recently paired device in NVS (ESP32's non-volatile storage) so the transmitter auto-reconnects to the last speaker it successfully paired with on every power-up, which is the behavior people actually expect from a Bluetooth transmitter rather than needing to manually re-pair every time.

Dealing With Latency

A2DP was designed for music, not for synchronized video or anything latency-sensitive — expect somewhere in the range of 100-250ms of audio delay depending on your target speaker's own buffering, which is the same delay you'd see from any commercial Bluetooth transmitter dongle. This is a non-issue for a turntable, stereo receiver, or background music source, but worth knowing before you plan to use this for anything synced to on-screen video.

Enclosure

Keep the build in a small enclosure with a 3.5mm or RCA line-in jack on the outside and the pairing button accessible, and power it from a simple USB power bank or wall adapter depending on whether you want it portable. If you're tapping it permanently into a stereo receiver's tape-out or aux-out, a wall-powered build tucked behind the equipment is the more practical long-term setup.

This project fills the gap the other direction from a standard Bluetooth receiver build: instead of getting audio onto wired speakers, it gets audio off a wired source and onto any standard Bluetooth speaker or headphones you already own, without needing both ends of the link to be your own hardware. Once the pairing memory and auto-reconnect logic are dialed in, it behaves exactly like the commercial transmitter dongles it's replacing, just with firmware you control.