I am trying to let the esp32s3 play a sound locally. But there is no sound coming out. It said it is compiled and uploaded, and I keep hitting RST button, but it does not help. It is also not printing out any message that used as hint in code.
Here is code.
#include "Arduino.h"
#include "Audio.h"
#include "SD.h"
#include "FS.h"
#include "SPI.h"
// I2S Pins (For your DAC/Amplifier)
#define I2S_DOUT 14
#define I2S_BCLK 11
#define I2S_LRC 10
#define I2S_SD 13 // Shutdown pin
// SD Card SPI Pins (Check your specific ESP32 board pinout)
#define SD_CS 5
#define SPI_MOSI 23
#define SPI_MISO 19
#define SPI_SCK 18
Audio audio;
void setup() {
Serial.begin(115200);
// 1. Enable Amplifier (SD Pin)
pinMode(I2S_SD, OUTPUT);
digitalWrite(I2S_SD, HIGH);
// 2. Initialize SD Card
// Note: Adjust pins if your board uses different SPI pins
SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
if (!SD.begin(SD_CS)) {
Serial.println("Error: SD Card mounting failed!");
while (true); // Halt if SD fails
}
Serial.println("SD Card mounted successfully.");
// 3. Setting I2S pins
audio.setPinout(I2S_BCLK, I2S_LRC, I2S_DOUT);
// 4. Audio Settings
audio.setVolume(15); // 0-21
// 5. Play from SD Card
// Ensure the file name matches exactly what is on your card
if(!audio.connecttoFS(SD, "/Giant_U.mp3")){
Serial.println("File not found on SD card!");
}
}
void loop() {
audio.loop();
}
// Optional: Audio info callback for debugging
void audio_info(const char *info){
Serial.print("audio_info: ");
Serial.println(info);
}
I moved your topic to an appropriate forum category @ricky_777.
In the future, when creating a topic please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
That's a completely separate issue from taking forever to compile, isn't it?
If you aren't precise in stating the nature of your problem, no one is going to be able to help you.
So, beginning again, it doesn't play. There is no sound.
All you've told is that you have an ESP32 and an SD card. Do you have a amplifier? Do you have a speaker? How is everything hooked up? Where is your schematic showing that? What SD card (module, I presuming) do you have? What amp? Did you write this code yourself? If not, where's the link to where it came from? I see your code has print statements; what do you see on your Serial Monitor? Did your SD card hookup work when you tested it individually with one of the examples from the SD library? Did your I2S hookup work when you tested it individually with one of the examples from the I2S library?
When I'm having trouble with serial output, I like to do a quick check with the most simple possible sketch. If this works, then I know the problem has something to do with my real sketch. If it doesn't work, then I know the problem is not related to my sketch code. It seems maybe a little silly, but it allows me to be sure I'm focusing my troubleshooting efforts in the right direction.
Please try this experiment and then report the results:
This procedure is not intended to solve the problem. The purpose is to gather more information.
Copy and paste this code as a new sketch in Arduino IDE:
Select Sketch > Upload from the Arduino IDE menus.
Arduino IDE will start an upload operation.
Wait for the upload to finish successfully. If it does not finish successfully, add a reply here on this forum topic to inform us of the failure and we'll investigate further.
Select Tools > Serial Monitor from the Arduino IDE menus to open the Serial Monitor view if it is not already open.
Please add a reply here on this forum topic to tell us whether you now see the word "hello" being printed in the Serial Monitor's output field once a second.
This is my circuit. Also, somehow I am using ESP32 S3 which means I do have a slot for the SD card to be inserted and it is on chip. So do I still need to define the pin for the SD card reader?
That is not any help. Hand draw where every wire goes and take a photo of the diagram.
Your board is an esp32-s3-cam board. Make sure you have the right board selected. Also, make use of post 8.
BTW, the setup in your photo in post 10 can not print to Serial.