ESP32-S2 Audio I2S library

Sani300
Posts: 1
Joined: Tue Aug 10, 2021 9:13 am

ESP32-S2 Audio I2S library

Postby Sani300 » Tue Aug 10, 2021 9:21 am

Hi,

I am working on the ESP32-S2 and I would like to be able to stream radio from the internet. There are arduino libraries on the ESP32 but not for the ESP32-S2. They are not compatible, I have several errors during the compilation.

I don't use an mp3 codec, but just an amplifier in I2S MAX98360 in I2S.

Has anyone ever managed to do this on the ESP32-S2?
Here are exemple of errors I have with the library https://github.com/schreibfaul1/ESP32-audioI2S

error: 'I2S_MODE_DAC_BUILT_IN' was not declared in this scope
m_i2s_config.mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN );
error: 'i2s_set_dac_mode' was not declared in this scope
i2s_set_dac_mode(m_f_channelEnabled);

Sani300

ESP_Minatel
Posts: 364
Joined: Mon Jan 04, 2021 2:06 pm

Re: ESP32-S2 Audio I2S library

Postby ESP_Minatel » Tue Aug 10, 2021 11:41 am

Hi,

There are work in progress regarding the I2S support on Arduino.

https://github.com/espressif/arduino-esp32/pull/5304

You can track this PR to keep updated.

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP32-S2 Audio I2S library

Postby corz.org » Mon Apr 03, 2023 1:52 pm

I just picked up a few S2 modules and the first thing I try to upload I get

Code: Select all

error: 'I2S_MODE_DAC_BUILT_IN' was not declared in this scope
I don't see any mention of this error on the page linked here.
Does anyone know if there is any progress here?

Agree007
Posts: 103
Joined: Mon Sep 18, 2017 7:11 pm
Location: Copenhagen

Re: ESP32-S2 Audio I2S library

Postby Agree007 » Mon Apr 03, 2023 6:04 pm

What esp32 -s2 module do you have ? and what i2s library, does it support esp32-s2 ?

User avatar
corz.org
Posts: 80
Joined: Fri Feb 03, 2023 10:44 pm
Location: Aberdeen
Contact:

Re: ESP32-S2 Audio I2S library

Postby corz.org » Mon Apr 03, 2023 6:40 pm

I get the same result on all three of my new S2 modules (Muse Lab WROVER (Saola compatible) board, VCC-GND Yo-ESP32-S2-MINI-2 (both dual USB boards) and a skinny WROOM ESP32-S2 with single built-in USB-C).

https://www.aliexpress.com/item/1005001403045642.html
https://www.aliexpress.com/item/1005004983811502.html (came with MicroPython installed)
https://www.aliexpress.com/item/1005004499308167.html ( ditto)

I'm using the built-in libraries. I imagine the relevant ones being..

Code: Select all

#include "driver/dac.h"
#include "driver/i2s.h"
I'm setting up i2S to output via the DAC, which runs fine on all the regular ESP32 chips I've tried..

Code: Select all

i2s_driver_config_t i2s_config = {
  .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX | I2S_MODE_DAC_BUILT_IN),
  .sample_rate = 10000000, // (updated dynamically)
  .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
  .channel_format = I2S_CHANNEL_FMT_RIGHT_LEFT,
  .communication_format = I2S_COMM_FORMAT_STAND_MSB,
  .intr_alloc_flags = 0,
  .dma_buf_count = 2,
  .dma_buf_len = 32,      // updated dynamically
  .use_apll = 0,          
  .tx_desc_auto_clear = false,
  .fixed_mclk = 0,
  .mclk_multiple = I2S_MCLK_MULTIPLE_DEFAULT, // Another parameter added to suppress compiler messages :roll:
  .bits_per_chan = I2S_BITS_PER_CHAN_DEFAULT
};
It's only the final parameter it's getting upset about. When I rummage in the header files I see that the definition is conditional in the S2 headers..

Code: Select all

#if SOC_I2S_SUPPORTS_DAC
    //built-in DAC functions are only supported on I2S0 for ESP32 chip.
    I2S_MODE_DAC_BUILT_IN = (0x1 << 4),       /*!< Output I2S data to built-in DAC, no matter the data format is 16bit or 32 bit, the DAC module will only take the 8bits from MSB*/
#endif // SOC_I2S_SUPPORTS_DAC
I assumed the S2 variant's DAC was fully functional.

Who is online

Users browsing this forum: No registered users and 52 guests