Basic SoundReactive Setup w/ ESP32-A2DP

Sound-reactive effects for a backlit Honeycomb wall panel. Check this YouTube vid out:

SR Honeycomb wall panel

Original LED wall panel idea from here.

Two ESP32’s involved – one for ESP32-A2DP Bluetooth (which also runs the custom sound reactive module) and the other for WLED-WiFi; check this discussion out for Bluetooth/WiFi coexistence issues on the same ESP32 radio in A2DP setups. These two ESP32s are connected via UART. Using WLED JSON API over ArduinoSerial communication to update WLED presets upon beat detection.

Bluetooth audio streaming presents several advantages over, say, traditional mic capture. For example:

  • Better audio source signal fidelity can be maintained by digital/electrical (rather than acoustic) transmission
  • Input signals are received electrically (rather than sonically), eliminating the need for a loud/audible audio source

Nevertheless, traditional audio capture methods still retain several advantages including:

  • Mic capture works transparently with any system that outputs audible sound above a certain threshold
  • Line-in and mic capture are not subject to the latencies associated with Bluetooth audio

The ESP32-A2DP project supports audio output via i2s. A basic setup could include an external audio interface, e.g. PCM5102 DAC, as shown below (ESP32 internal DAC not recommended). Check a more generic architecture out for other sound output options.

Can u provide a circuit diagram for this Project.
If also the source code.

Also is the stereo cable for input or Output


The Bluetooth ESP32 is in A2DP sink mode (i.e. an audio receiver). In turn, it outputs PCM to an external PCM5102 DAC via I2S. So the stereo cable is output from the PCM5102 to a power amplifier/speaker system.

See section A2DP Sink (Music Receiver) for details on how to configure I2S for PCM output to a DAC. See link for ESP32-to-DAC physical pin mappings.

The author provides code samples that work right out of the box. In fact, the only thing I had to change was my ESP32 I2S pin assignments since I was using an ESP32-CAM which supports fewer GPIOs than the standard ESP32 dev board: I assigned 14 for .bck_io_num, 15 for .ws_io_num and 13 for .data_out_num (rather than using the default 26, 22, and 25 GPIOs, respectively). Here is my i2s_config:

i2s_pin_config_t my_pin_config = {
  .bck_io_num = 14,
  .ws_io_num = 15,
  .data_out_num = 13,
  .data_in_num = I2S_PIN_NO_CHANGE
a2dp_sink.start("GoodTech", true); 

Hope this helps!

Thank you
Since i relatively new to this can you explain the UART connection and DAC to the WLED ESP32.

Indeed the ESP32-A2DP sends WLED JSON preset commands to the ESP32-WLED over UART, but your other statement, “DAC to the WLED”, don’t make sense – I think you mistyped.

About the serial/UART comms, WLED supports a serial interface for WLED JSON commands. For instance, and assuming you got a WLED-ESP hooked to your computer, entering the following command on the serial monitor, {"v":true, "ps":9}, should result in WLED switching to preset 9 – and printing out some feedback on the monitor’s console.

Once you get this done, then you may attempt programmatic control:

  • On the hardware side, simply crisscross the RX/TX pin connections (and share a common ground) between the non-WLED ESP that will be sending the WLED JSON preset cmds and the ESP-WLED.
  • See this example code for serial comms between a non-WLED ESP and a WLED ESP. Also check this discussion out for more on Arduino-core serial communications issues – particularly Hardware vs. Software serial.

This looks really interesting - nice build too.

Please could you answer a couple of questions…

Why do you use two esps for this project? can it not be done with just one?

Also the DAC, is that just for output? I am using a mic on my sound reactive esps but I want to have the option of using a line in so there is no background noise interference and looks like a DAC is the answer…

this is a sketch of the setup i am planning, any thoughts on this welcome :slight_smile:


Why do you use two esps for this project? can it not be done with just one?

I already answered this question (and provided an external link) in the project description above.

Also the DAC, is that just for output?

In this setup, yes. Audio input is via Bluetooth A2DP. If you wish to use Line-in instead, you could check this link out for a discussion on using line-in with ESP (and an external DAC).

Might I also impose on you to visit this page which presents a generalized extension of the architecture used here – and includes something similar to your drawing.

Hope this helps!