How to use DFPlayer Pro to play MP3
What is a DFPlayer Pro?
The DFPlayer Pro is an upgrade of the DFPlayer Mini MP3 Player for Arduino. It is a small and low-priced MP3 module with an internal storage of 128MB. The module can be used as a stand-alone module with an attached battery, speaker and push buttons or used in combination with an Arduino UNO or any other with RX/TX capabilities. Know More
This tutorial is based on using Arduino UNO.
Wiring
Wiring up the sensor is less complex than the previous version with the labelled pins.

- VIN to 5V (Power)
- GND to GND (Ground)
- RX to D2
- TX to D3
- R+ to Speaker(+) red wire
- R- to Speaker(-) black wire
- Connect L+ & L- if you want stereo audio
File handling
- You can download our example-sounds.zip.
- Connect the module to a computer with a USBC cable.
- Create a folder called
mp3. - Place the mp3 files into that folder.
Library
DFRobot_DF1201S library will be used for this module. We have a tutorial on how to install a library here.
Get Started
#include <DFRobot_DF1201S.h>
#include "SoftwareSerial.h"
SoftwareSerial DF1201SSerial(2, 3); //RX TX
DFRobot_DF1201S player;
void setup(void){
Serial.begin(115200);
DF1201SSerial.begin(115200);
while (!player.begin(DF1201SSerial)) {
Serial.println("Init failed, please check the wire connection!");
delay(1000);
}
player.setVol(0);
player.switchFunction(player.MUSIC);
delay(2000);
/*
SINGLECYCLE = 1, /**<Repeat one song
ALLCYCLE, /**<Repeat all
SINGLE, /**<Play one song only
RANDOM, /**<Random
FOLDER, /**<Repeat all songs in folder
*/
player.setPlayMode(player.SINGLE);
player.setVol(20);
}
void loop(){
if(!player.isPlaying()){ //if player is not playing
player.playSpecFile("/mp3/001.mp3"); //play 001.mp3 in folder "mp3"
String fileName = player.getFileName();
Serial.print("playing: ");
Serial.println(fileName);
}
}

