SunFounder ESP32 Starter Kit
6. Modify the code.
Modify the line of code file = new AudioFileSourceSD_MMC("/To Alice.mp3"); to reflect
your file’s name and path.
Note:
• Open the 7.5_mp3_player_sd.ino file under the path of esp32-starter-kit-main\c\
codes\7.5_mp3_player_sd. Or copy this code into Arduino IDE.
• After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.
• Always displaying “Unknown COMxx”?
• The ESP8266Audio library is used here, refer to Manual Installation for a tutorial to install.
7. Select the appropriate port and board in the Arduino IDE and upload the code to your ESP32.
8. After successfully uploading the code, you will hear your favorite music playing.
How it works?
• The code uses several classes from the ESP8266Audio library to play an MP3 file from an SD card through I2S:
#include "AudioFileSourceSD_MMC.h"
#include "AudioOutputI2S.h"
#include "AudioGeneratorMP3.h"
#include "SD_MMC.h"
#include "FS.h"
– AudioGeneratorMP3 is a class that decodes MP3 audio.
– AudioFileSourceSD_MMC is a class that reads audio data from an SD card.
– AudioOutputI2S is a class that sends audio data to the I2S interface.
1.42. 7.5 MP3 Player with SD Card Support 157