ESP32 as I2S (Audio) slave - Page 1
Forum section: electronics / general

author: jmibk
author_rank: Regular Contributor
timestamp: May 26, 2022, 07:15:55 pm
content: I'm trying to use the ESP32 as a simple bluetooth audio receiver that is connected to an ADAU1701 DSP via I2S.The ESP32 works perfectly on the PCM5102 DAC when the ESP32 is running in Master Mode ( .mode = (i2s_mode_t) (I2S_MODE_MASTER | I2S_MODE_TX) )So, every pin spits out the correct signals.Now my problem is, that the DSP acts as a master and the ESP32 should receive the main clock from the DSP.With the following code I have following signals on its pins (bluetooth device is connected and streaming audio):Pin3, Masterclock: 11,28MHzPin13, I2S Data: no signalPin14, LRCK: 48kHz (coming from the DSP, MP10, LRCK OUT)Pin15, BitClock: 3,07MHz (coming from the DSP, MP11, BCK OUT)Someone is running such configuration and knows how to configure that thing?BT Library used:https://www.pschatzmann.ch/home/2020/03/27/1255/Board used: Olimex ESP32-PoECode:#include "BluetoothA2DPSink.h"BluetoothA2DPSink a2dp_sink;void setup() {static const i2s_config_t i2s_config = {.mode = (i2s_mode_t) (I2S_MODE_SLAVE | I2S_MODE_TX),.sample_rate = 48000, // corrected by info from bluetooth.bits_per_sample = (i2s_bits_per_sample_t) 16, /* the DAC module will only take the 8bits from MSB */.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,.communication_format = I2S_COMM_FORMAT_I2S_MSB,.intr_alloc_flags = 0, // default interrupt priority.dma_buf_count = 8,.dma_buf_len = 64,.use_apll = false};a2dp_sink.set_i2s_config(i2s_config);static const i2s_pin_config_t pin_config = {//.mck_io_num = 3,.bck_io_num = 15,.ws_io_num = 14,.data_out_num = 13,.data_in_num = I2S_PIN_NO_CHANGE};a2dp_sink.set_pin_config(pin_config);a2dp_sink.i2s_mclk_pin_select(3);a2dp_sink.start("MyMusic", true);}void loop() {delay(1000); // do nothing}

author: zsoltyfm
author_rank: Newbie
timestamp: June 26, 2022, 02:45:18 pm
content: HI!The ESP32 must be the master and the DSP the slave! Perhaps an ADAU1452 would be more suitable for this task because it contains ASRCs and thus can process multiple master sources properly at the same time.

author: fmsndx
author_rank: Newbie
timestamp: September 07, 2022, 04:00:49 pm
content: Hey,got the same problem with a simliar setup. I don't get it working when the ESP32 is the Master. When the ADAU1701 is the Master, I can stream audio via A2DP over I2S on the DSP and over analog to a headphone. But the problem is, that the audio is pitched. I think there is a problem in some of the CLOCKs (maybe BCLK?). I tried a lot of diffrent configuration in ESP with the library from pschatzmann or the DSP with SigmaStudio.My Current best working Config is:Code:static const i2s_config_t i2s_config = {.mode = (i2s_mode_t)(I2S_MODE_SLAVE | I2S_MODE_TX),.sample_rate = 44100, // corrected by info from bluetooth.bits_per_sample = I2S_BITS_PER_SAMPLE_32BIT,.channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,.communication_format = i2s_comm_format_t(I2S_COMM_FORMAT_I2S_MSB | I2S_COMM_FORMAT_I2S),.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,.dma_buf_count = 8,.dma_buf_len = 256,.use_apll = false,.tx_desc_auto_clear = true};sigmastudio_hardwareconfig.png(270.29 kB. 1102x774 - viewed 354 times.)Did you fixed it @zsoltyfm?