DFPlayer Mini Mp3 Player SOLVED

Hi, I’ve been having a play with the DFPlayer Mini Mp3 Player with varying success. I got it to a point were it would only play a few songs on the micro SD card. Now I have it playing every track on the card.

Use 5V to power the MP3 player. The MP3 player has a ‘Busy’ pin which is high when not playing an MP3 and low when playing. The Busy output is 5V so I used a simple voltage splitter, using 3x 47K resisters (that’s all I had to hand), to drop the voltage to 3.3V. This connects to pin 33 of the ESP32.

ESP32 pin 16(RX) connects to the TX pin of the MP3 player and pin 17(TX) connects to the RX pin of the MP3 player. I used an 8ohm speaker to SPK_1 and SPK_2.

In the Setup, it commands the MP3 player to play track 1. This sends the Busy pin LOW. When the track finishes it goes HIGH. In the LOOP it detects the change in state on pin 33. It then instructs the MP3 player to move on onto the next track sending the Busy pin low again. It actually works quite well.

#include "Arduino.h"
#include "DFRobotDFPlayerMini.h"

#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266))  // Using a soft serial port
#include <SoftwareSerial.h>
SoftwareSerial softSerial(/*rx =*/16, /*tx =*/17);
#define FPSerial softSerial
#else
#define FPSerial Serial1
#endif

//Using Busy pin to move to next song
int BusyPin = 33;
int NextSong = 0;

DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup() {
  pinMode(BusyPin, INPUT);
  NextSong = 1;

#if (defined ESP32)
  FPSerial.begin(9600, SERIAL_8N1, /*rx =*/16, /*tx =*/17);
#else
  FPSerial.begin(9600);
#endif

  Serial.begin(115200);
  Serial.println();
  Serial.println(F("DFRobot DFPlayer Mini Demo"));
  Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

  if (!myDFPlayer.begin(FPSerial, /*isACK = */ true, /*doReset = */ true)) {  //Use serial to communicate with mp3.
    Serial.println(F("Unable to begin:"));
    Serial.println(F("1.Please recheck the connection!"));
    Serial.println(F("2.Please insert the SD card!"));
    while (true) {
      delay(0);  // Code to compatible with ESP8266 watch dog.
    }
  }

  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.volume(10);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);     //Play the first mp3
  delay(500);             //Allow delay to make sure the Busy pin on the MP3 player to go low
}

void loop() {
  NextSong = digitalRead(BusyPin);
  //The busy pin on the MP3 player goes high when song is finished. If high move on to next song
  if (NextSong == 1) {
    Serial.println("Track finished moving to next....");
    myDFPlayer.next();
    delay(500);
  }
}

IMPORTANT: For some reason I couldn’t get it to play anything using 2G or 4G cards even though the cards were formatted to FAT32. I found 2x 8G cards and it works fine with them. I have no idea why the player doesn’t like the 2G and 4G cards. They are formatted in the same way as the 8G cards. Maybe someone can explain why.

Also, please remember that if you use a Mac to add tracks to the card, the Mac will add hidden files that the player will try and play them. I just use a Windows laptop to add the tracks or remove the hidden files off the card.
I hope this helps.

Hi Lexter333,

Thank you so much for the DF Mini Player information!
I’ve been dealing for a while with different codes and connections, without success.

Now my player is working correctly with ESP32 and I can start to play with my own project.

Again, thank you!

Kind Regards,

Mariano.

You are welcome. I was in the same boat for a while.

From the large ESP32 repertoire I have only the 16 pin ESPS32-C3 Supermini board. I select the board 'ESP32C3 Dev Module'. What exactly is the board you are selecting?
I've had no problem with the 4GB, 16GB and 32GB cards I've been using. Currently use only a 5V supply and pins 8/7 for RX/TX and 5 for BUSY. If I can work out how to translate to your pin numbering I could try to reproduce your 4GB mystery.

EDIT: Thu 16 Oct 2025 1702
With only that change of pins your sketch ran fine on my ESP32-C3 Supermini with several 4GB cards.

Is the content identical on the various size mSD cards you're using?
Have you tried formating the reluctant cards and re-populating? Quick Format option first; failing that, Full.

Hi Terry,

I have a number of different ESP32s. The one that I was using is a 30 pin ESP32WROOM - USB-C. As always I select ESP32 Dev Module board in the Arduino IDE. Are you saying that you now have it working on the C3? If so that is good. It proves that the sketch will work on multiple boards. As you know I created a new thread because I could not get it to work on the CYD. If anyone can help then any help would be appreciated. DFPlayer Mini MP3 Player With CYD

Yes, just changed the one line:

#if (defined ESP32)
  **FPSerial.begin(9600, SERIAL_8N1, /*rx =*/8, /*tx =*/7);**
  // FPSerial.begin(9600, SERIAL_8N1, /*rx =*/16, /*tx =*/17)

Did you try the suggestions in my last para?

About the SD cards? Yes. I couldn’t get any of the 8 cards to work (4 & 2G). It must be the MP3 player not being able to handle small cards.

Also, I forgot to mention they have all had quick formatting and full formatting. The MP3 player works with 3.3 - 5V. I used 5V and 3V3 to see if that made a difference but no such luck! I honestly think it’s something on the cards which full and quick formatting does not remove. I know that sounds implausible, but I have no other explanation.
Anyway, it’s working now and I have completed the project. Have a look :slight_smile: https://youtube.com/shorts/SG_TP1PZT2E

I have 1GB microSD in mine.

Where did you get yours from? And what did you format them on? I use my Mac mini and MacBook for everything. I know that Macs add hidden files to the cards but they don’t seem to have an impact on the player with an 8G card.

Curiously though, the 2G and 4G cards will not work in my 3D Printer either, but can be seen and written to with my Mac. The cards are a few years old and I know that Micro USB have limited write cycles, but if they were corrupt in any way they Mac would not be able to write to them. They all have been formatted to FAT32 via a Mac and Windows PC. I have checked for errors using the Windows PC and did First Aid using the Mac…… but they will not be recognised by the MP3 Player or the 3D Printer.

Any suggestions?

Windows. I got these little guys "several years" ago, too.

I don't know if this is any different from what you have or what's on a 'mac' natively as it were. --

I don't know if you have DFRobot units or some imitations / clones. EmilyJane posted, recently, a link to a good write-up on issues with various "players".

Very nice! Your own 3D print?

Is that a USB plug? Data for easy uploading, or just a power supply/charger? With socket for C-type plug or lightning? My cables (for iPhone and iPad) are the latter, and I'm still looking for inexpensive sockets which require a circular drill hole.

Hi Terry, it is a USB-C power socket. I get them from AliExpress. I have 2 different types, I have the ones in the image which are round and oval shaped ones. The round only have power leads on them but the oval ones also have the power and D+ & D-.

I have tonnes of leads and sometimes I pick up a power one instead of a data one which can be infuriating so I bought this to test and separate them.

Hi everyone. On one of my topics, someone mentioned that I should use SD Memory Card Formatter to format my cards and it will fix my 2G and 4G card issues. The cards would not work on the DFPlayer or my 3D printer. I took his advice and downloaded it. All 12 of the Micro SD cards work on both my 3D printer and the DFPlayer. I would like to thank him for your advice and would like to pass this information on to others. Once again thank you!

EDIT

I’ve just noticed it was you runaway_pancake Thank you again, much appreciated.