DFPlayer MP3 did not play sound

I have problems about playing sound by DFPlayer MP3 using TF card.
These are the photos of the TF card's folder, the connection I have made and the code.


#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>

#define RX 11
#define TX 10

DFRobotDFPlayerMini mp3;
SoftwareSerial *MP3;

void setup() {
  Serial.begin(9600);
  MP3 = new SoftwareSerial(RX, TX);
  MP3 -> begin(9600);
  Serial.println("Initializing");

  if(!mp3.begin(*MP3, true, false)){
    Serial.println("Initializing falure");
    while(true);
  }
  Serial.println("Initializing success");
  mp3.volume(10);
  mp3.play(1);
}

void loop() {

}

After uploading, the Serial Monitor displayed 'Initializing Success' which I assume that the DFPlayer had been connected correctly. However, the LED on the DFPlayer did not light up as same as tutorials, the Speaker did not play either.
Please someone figures out my problems and thank you for your help.

what format for the mp3 ? for the SD card (the long file name might be an issue) ?

usually files are called 001.mp3 002.mp3 etc

why do you instantiate SoftwareSerial dynamically ?

If the mp3 is in the root, as it appears there, then it needs a 4 digit 'name' (0001.mp3)

I have changed the file name as you said but it did not work either. I wonder do I have problems about DFPlayer or the code.

#include "SoftwareSerial.h"
#include "DFRobotDFPlayerMini.h"

// Use pins 2 and 3 to communicate with DFPlayer Mini
static const uint8_t PIN_MP3_TX = 11; // Connects to module's RX 
static const uint8_t PIN_MP3_RX = 10; // Connects to module's TX 

SoftwareSerial softwareSerial(PIN_MP3_RX, PIN_MP3_TX);

// Create the Player object
DFRobotDFPlayerMini player;

void setup() 
{
  Serial.begin(19200);
  delay(500);
  Serial.print("hwserial ok");
  delay(500);
  softwareSerial.begin(9600);
  delay(3000);
  if (player.begin(softwareSerial)) 
  {
    Serial.println("OK");
    player.volume(20); //30 is very loud
  } 
  else 
  {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }

  player.play(1);
}

void loop() 
{
}
1 Like

I have changed the file name but it stil did not work.
Oh, I accidentally copied the old code. This is my current code I have learnt from this video.

#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>

#define rx 11
#define tx 10

SoftwareSerial mp3Serial(rx,tx);
DFRobotDFPlayerMini mp3Player;
void setup() {
  // put your setup code here, to run once:
  pinMode(rx, INPUT);
  pinMode(tx, OUTPUT);

  mp3Serial.begin(9600);
  Serial.begin(9600);
  mp3Player.begin(mp3Serial);

  mp3Player.volume(15);
  mp3Player.play(1);
}

void loop() {
  // put your main code here, to run repeatedly:

}

But it still did not work.

Curious.
Perhaps you could rig it up after the 'io mode' config - to see if it works at all.

DFPlayer Mini Mp3 Player - DFRobot Wiki

(I know that the sketch I posted works.)

What do you mean using pins 2 and 3 of arduino to connect with DFPlayer? Which pins of DFPlayer should I connect with? I thought that the RX, TX connections are enough.

Use I/O Mode in the link in post #7.

1 Like

A vestigial comment.

On your microSD --
make a folder, name it 01
place your MP3 in that folder and name it 001.mp3

In my sketch, use --
player.playFolder(1,1);
( in place of player.play(1); )

I wonder if your unit is a 'clone'. Where did you get it?

About the module, I bought it from the most reliable electonic store in my area. Also the store has many 5 stars feedbacks on the module, so I believe the module can not be fake.
About the speaker, I bought it online and I lost its receipt somewhere. It is a 1.5 Inch full range speaker. Also, when I replace the nano with an uno and reupload the sketch, I heard small buzzing sound from the speaker repeatedly, the DFPlayer got hotter.

You get receipts with online purchases? I just look in my history.

Wrong wiring.

There's widespread confusion about the DFR module's file format requirement. Your MP3s in the root can be named however you like. They do not need prefix numbers. The instruction

myDFPlayer.play(N);

will play the Nth track on the card. Where N is the Nth track that was copied or moved to the card.

I think the issue has arisen because of poor documentation, largely due to translation flaws. Of course, most users will therefore need numbering, as I do, to manage the implications.

Didn't understand your first code (not a C/C++ programmer). :slightly_smiling_face:
Will study your latest sketch this morning.. Meanwhile, I'm sure you don't need pinMode for the Rx/Tx pins?

1 Like

Yes. I guess the doc suggesting the numbering was a "trick" because most OS copy files to the SD in the file name order when you do a bulk copy, so that was ensuring file 001.mp3 was copied over before file 002.mp3 etc...

1 Like

The key error in your code was that you had Tx/Rx reversed. Otherwise I've kept the sketch below close to yours (although I would personally make some other changes). It works as expected on a Uno.

#include <SoftwareSerial.h>
#include <DFRobotDFPlayerMini.h>

#define rx 10
// #define rx 11
#define tx 11
// #define tx 10

SoftwareSerial mp3Serial(rx, tx);
DFRobotDFPlayerMini mp3Player;
void setup()
{
  // put your setup code here, to run once:
 // pinMode(rx, INPUT);
  // pinMode(tx, OUTPUT);

  mp3Serial.begin(9600);
  Serial.begin(115200); // my preference
  mp3Player.begin(mp3Serial);

  mp3Player.volume(15);
  mp3Player.play(2); // Play the second track that was copied to the mSD.
}

void loop()
{
}
1 Like

Auf wiedersehen.

1 Like

Thank you for your effort.

THANK YOU SO MUCH FOR YOUR GREAT HELP!!!!! I AM SO EXCITED RIGHT NOW
It took me nearly 3 DAYS finding errors and turned out that it was REVERSED WIRING!!!
You are right, naming files does not matter at all. I have tried changing the file name with your great code and it played sound normally.