Extra 5% OFF Use Code: OL05
Free Shipping over ₹999

ESP32 Bluetooth Audio

Watch the Video Tutorial

This tutorial is available in video format (watch below) and in written format (continue reading this page). 

If you have any problems during the installation procedure, take a look at the ESP32 Troubleshooting Guide.

Introduction

If you’re looking to build a wireless audio system using the powerful and affordable ESP32, this guide is for you. In this post, you’ll learn how to stream high-quality audio over Bluetooth using the ESP32 and output it to an external DAC via the I2S protocol. Whether you’re making a DIY Bluetooth speaker, audio receiver, or just experimenting with wireless audio, this tutorial will walk you through the essential steps.

What You’ll Learn

  • Basics of Bluetooth A2DP audio streaming with ESP32
  • Setting up I2S output on the ESP32
  • Connecting and using an external DAC (like CJMCU1334)
  • Playing audio from your smartphone to ESP32

Hardware Required

  • ESP32 Development Board
  • External DAC (CJMCU1334)
  • Amplifier (PAM8403)
  • Speakers
  • Power supply (USB or battery)
  • Jumper wires and breadboard

Understanding Bluetooth Audio with ESP32

ESP32 supports A2DP (Advanced Audio Distribution Profile), allowing it to act as a Bluetooth sink—receiving audio from phones or computers. It decodes the audio and sends it out via the I2S interface to a DAC or amplifier.

Circuit Diagram / Wiring

  • ESP32 → CJMCU-1334 (I2S Interface)
    • GPIO 26 of ESP32 → BCLK on CJMCU-1334
    • GPIO 22 of ESP32 → DIN on CJMCU-1334
    • GPIO 25 of ESP32 → WSEL on CJMCU-1334
  • CJMCU-1334PAM8403
    • LOUT of CJMCU-1334 → L-IN on PAM8403
    • ROUT of CJMCU-1334 → R-IN on PAM8403
    • GND of CJMCU-1334 → GND on PAM8403
  • PAM8403 Speakers
    • L-OUT → Left Speaker
    • R-OUT → Right Speaker
    • PAM8403 VCC → 5V Power
    • GND → Ground

ESP32 Code


Test It

  • Upload the code.
  • Open Bluetooth on your phone, and connect to MYMusic.
  • Play a song — sound will be heard from both speakers!

Tips

  • Keep wires short between ESP32 and DAC to reduce noise.
  • Mount the PAM8403 and speakers on a small wooden or acrylic enclosure for better sound.
  • Use heat sinks on PAM8403 if driving near max volume.

    Leave a Reply

    Your email address will not be published.

    Need Help?