MP3 Player

Spring 2020

You are not logged in.

If you are a current student, please Log In for full access to the web site.
Note that this link will take you to an external site (https://shimmer.csail.mit.edu) to authenticate, and then you will be redirected back to this page.

1) Overview

I need to verify if these modules are still working...they've gradually changed the chipset and/or a bunch of counterfeits have leaked into the market so there's something off with their timing. I'll look into it and notify anyone interested. I bought a big stash of these from my favorite Shenzhen Supplier so hopefully they work (will test over CPW weekend)

Playing audio files on the ESP32 is possible without any external hardware, though it can be quite taxing on the device and can make multi-tasking difficult since implementation of song playback can be non-blocking. One way to avoid this is to offload this task to a secondary chip/chipset so that you can give it a command, and then get on with your life and go and time that button push or whatever. One really inexpensive chipset/board that can do this is this:

The device has a chip onboard that allows decoding of mp3-type files and a second chip on board that acts as an audio amplifier so you can directly drive a speaker at reasonable volumes.

The library to work with this chip is actually in the primary archive for Arduino (often times ones that work with the ESP32 are not, but in this case it is so Yahtzee for us). Go to Sketch>Include Library>Manage Libraries and then after that, loads search for "DFRobotDFPlayer" and select the most recent version of the library that comes up for installation.

The sketch linked here is a slightly modified version of their default example code that works with our ESP32 when it is hooked up and controlling the board using the following wiring scheme:

DFPlayer Wiring

For reference the pins on the MP3 board are shown below:

DFPlayer Pinout

The last step is to get a microSD Card. I grabbed a SanDisk 16GB Class 10, generically formatted it, and then dragged an MP3 file onto it on my computer. Then popped it out put it into the DFPlayer board (while powered down), turned it all on and a song started playing. If you need an mp3 file, here is "See You Again", a track off of Tyler the Creator's excellent album Flower Boy from last year where I feel he really came into his own, commercially and artistically.

When playing, the script works by receiving serial commands you send to it over the Serial monitor. Read the code and comments to figure it out...then from there you can extract the functionality you'll need for your purposes.