Language: EN


Play MP3 on Arduino with DFPlayer Mini

What is a DFPlayer Mini player?

The DFPlayer Mini is a low-cost, small audio player that can be connected to a processor like Arduino to play audio in MP3 format.

Arduino does not have the power to play a compressed file like an MP3. No matter how hard you try, or even if you use a more powerful processor, it is not the function of a robot to perform these tasks. It is much better to delegate to a specific subprocessor.

There are different options to play MP3 files from Arduino, such as various shields and more or less expensive boards. Among the different options available, the DFPlayer Mini modules have become very popular due to their low price and great features.

In fact, the DFPlayer Mini is a complete audio player, capable of playing MP3, WMA, and WAV file formats.

It has a micro SD reader compatible with FAT16 and FAT32, with a maximum capacity of 32GB. It supports up to 100 folders and can access up to 255 songs.

The DFPlayer Mini provides sampling rates of 8, 11.025 12 16 22.05 24 32 44.1 and 48 kHz, and output with 24-bit DAC. It has 30 levels of adjustable volume, a 6-level equalizer, and a signal-to-noise ratio (SNR) of 85dB.

The DFPlayer Mini receives commands from Arduino via the serial port. It has functions to play, stop, pause, advance, and rewind between songs. The output is made directly to the speaker, through the corresponding pins.


The MP3 player DFPlayer Mini is a very cheap device, we can find it for 1.20€ searching in international sellers on eBay or AliExpress.


Connection diagram

The connection with the DFPlayer Mini MP3 player is very simple since the communication with the module is done through the serial port.


Simply by powering the MP3 player with an external 5V power source, connecting the Gnd to Arduino. On the other hand, we connect the RX and TX pins of the serial port to Arduino. Finally, we connect the speaker to the DFPlayer Mini to the Spk_1 and Spk_2 pins.

The connection, seen from Arduino, would be as follows


Code examples

To handle the DFPlayer Mini, we will need the DFPlayer_Mini_Mp3 library available at this link.

The library provides code examples, which it is advisable to review. The following examples are modifications based on those available in the library.

#include <SoftwareSerial.h>
#include <DFPlayer_Mini_Mp3.h>

SoftwareSerial DFPlayerSerial(10, 11); // RX, TX

mp3_play();    //start play
mp3_play(5);  //play "mp3/0005.mp3"

mp3_set_volume(uint16_t volume);  //0~30
mp3_set_EQ();  //0~5
void mp3_single_loop(boolean state);  //set single loop
void mp3_random_play();

void setup()

void loop()

Download the code

All the code from this post is available for download on Github. github-full