Audio Output I2S XIAO ESP32S3 Not Working

I was trying out I2S audio output however I cant seem to make it work on the XIAO ESP32S3, does anyone have any clue of why? The code does execute and no errors are found, I play a wav file using SPIFFS

Hi there,
and Welcome here.
Post up the code you are trying, Just use the code tags above “</>” Paste it in there
HTH
GL :slight_smile: PJ
:v:

Hi thank you very much
this is the code

#include "glasses.hpp"

#define LRC 0
#define BCLK 1
#define DIN 2

void setup_sound() {
  i2s_config_t i2s_config = {
      .mode = (i2s_mode_t)(I2S_MODE_MASTER | I2S_MODE_TX),
      .sample_rate = 44100,
      .bits_per_sample = I2S_BITS_PER_SAMPLE_16BIT,
      .channel_format = I2S_CHANNEL_FMT_ONLY_LEFT,
      .communication_format = I2S_COMM_FORMAT_I2S_MSB,
      .intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
      .dma_buf_count = 8,
      .dma_buf_len = 1024,
      .use_apll = false,
      .tx_desc_auto_clear = true,
  };

  i2s_pin_config_t pin_config = {
      .bck_io_num = BCLK,
      .ws_io_num = LRC,
      .data_out_num = DIN,
      .data_in_num = -1,
  };

  i2s_driver_install(I2S_NUM_0, &i2s_config, 0, NULL);
  i2s_set_pin(I2S_NUM_0, &pin_config);
}
void writeI2S(const uint8_t* data, size_t len) {
    size_t bytesWritten;
    i2s_write(I2S_NUM_0, data, len, &bytesWritten, portMAX_DELAY);
}

void Glasses::play_audio(uint8_t* buffer) {
    setup_sound();

    const size_t chunkSize = 1024;
    size_t bufferSize = sizeof(bufferSize);
    for (size_t i = 0; i < bufferSize; i += chunkSize) {
        size_t chunk = (bufferSize - i < chunkSize) ? (bufferSize - i) : chunkSize;
        writeI2S(&buffer[i], chunk);
    }
}

Where buffer is the PCM of a WAV File
I am using the max938357a breakout board together with an 8omh speaker 0.3W on 5V

This is the connection https://imgur.com/QwcaR3c

Hi there,
No reason it shouldn’t work, But I do see :face_with_peeking_eye:some Sketchy Soldering on the picture here and the next pin also.
look at those too,
I’ll try to compile it.


Use a little flux(allot) and heat in until it flows, you won’t hurt it if You don’t hold it for long as well.
what is the Z of the Speaker? 4 or 8 ohms?
GL :slight_smile: PJ
:v:

First time soldering for me ahah! Thank you, I’ll order some new break out boards to be safe. Speaker is 8 ohms, should be supported theoretically (right) ?.

Thank you very much

just heat it up and reflow… use flux if you have it

I saw the following discussion post where someone managed to play an audio file through an HTTP request, however he uses different GPIOs are there any specific ones? I didnt test it yet as I am waiting for a new board, but come the library works where as <driver/i2s.h> didn’t at least for me. Because at the end I am aiming to play the audio through a buffer not an MP3 file.

I will try that thank you

i think only specific gpio are capable of sending IIS… also some MCU’s are not IIS capable… need to check the product specs for sure