Problems with libraries

I'm not experienced in doing projects in ESP or Arduino nor making topics on forums so please do say things I need to correct and ask for more information about the project if necessary.

My project idea is for a ESP32 S2 play audio files, to do this I have a speaker, the ESP32 S2 and the I2S module MAX98357A. The major problem is that almost every library I've found and tried, ends up having various problems.

The libraries i've tried:

1.ESP32-audioI2S-master
2.Esp8266Audio

And some that I can't find, but those are the most important/commonly used ones.

Have you checked with Google to see what others have done?

It would help us to help you if you would describe the problems that you are having.

Provide links to any libraries that you use that are not included with the IDE.

If there was one code that came close, post that code. Please format the code with the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in a code block.

Please read the how to get the most from the forum post. The post contains information on what we need to know in order to help you.

A schematic of your wiring can be helpful.

No surprise there, but the fix might be trivial. The world moves on, and old tutorials rarely work "out of the box".

Post the code, using code tags, links to the libraries used, a wiring diagram, and describe the problems.

1 Like

Thank you for the replies and using your time to help me.
I've watched different tutorials as @groundFungus stated, but even then it had different problems ranging from uncorrected file paths, incorrect code in the library or outdated libraries.

Then I tried ESP32-audioI2S-master again and for some reason it worked, I believe it was where the files were or the folder Arduino IDE was using for the libraries.

It really was trivial. I mean i'm not even sure what the error was.

Here is the code and circuit if anyone is interested. I also take suggestions and help on these too:

The code is a example where a SD file is read and then played:

#include "Arduino.h"
#include "WiFi.h"
#include "Audio.h"
#include "SPI.h"
#include "SD.h"
#include "FS.h"

// Digital I/O used
#define SD_CS         2
#define SPI_MOSI      4
#define SPI_MISO      5
#define SPI_SCK       3
#define I2S_DOUT      7
#define I2S_BCLK      8
#define I2S_LRC       9

Audio audio;

const char* ssid = "SSID";
const char* password = "PASSWORD";


void setup() {
    pinMode(SD_CS, OUTPUT);      digitalWrite(SD_CS, HIGH);
    SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
    SPI.setFrequency(1000000);
    Serial.begin(115200);
    SD.begin(SD_CS);

   WiFi.begin(ssid, password);
    while (WiFi.status() != WL_CONNECTED) {
        delay(1000);
        Serial.println("Connecting to WiFi...");
    }
    Serial.println("Connected to WiFi");
      
    audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
    audio.setVolume(5); // 0...21

    audio.connecttoFS(SD, "WAV-FILE.wav");

void loop()
{
    audio.loop();
    if(Serial.available()){ 
        audio.stopSong();
        String r=Serial.readString(); r.trim();
        if(r.length()>5) audio.connecttohost(r.c_str());
        log_i("free heap=%i", ESP.getFreeHeap());
    }   
}

Circuit:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.