The demo code for [XTronical]The ESP32-based SD card music player doesn’t even do 40 lines, although it also requires a few budget parts before everything works. Still, getting a microcontroller to play MP3s (and other formats) from an SD card is considerably easier today than it was years ago.
Part of what makes this all work is I2S (Inter-IC Sound), a format for communicating PCM audio data between devices. Besides the ESP32, at the heart of it all is an SD card reader breakout board and the MAX98357A, which can be thought of as a combination of I2S decoder and Class D amplifier. The ESP32 plays audio files. from the SD card and uses an I2S audio library to send the I2S data stream to the MAX98357A (or two of them for stereo.) From there it is automatically decoded and the audio is pumped through the built-in connected speakers.
It’s amazing how much easier it is to work with audio when you can take advantage of the digital mixing of the audio data and the decoder handles multiple formats with a built-in amplifier. You can see [XTronical]The ESP32 player in action in the embedded video below.
Intrigued by I2S and want to know more? You’re in luck, because we’ve covered everything you would like to know about I2S and how it works.