Esp32 DFPlayer mini not connecting

I am currently trying to connect an esp32 to the DFPlayer mini, but i am unable to get a connection to the DFPlayer.
However I am able to play music with the Arduino UNO in the following setup:

This is the base setup i use with the esp. Which isnt working:

I tried a lot of setups with the esp32:

  • Different RX, TX pins (26, 27; 14, 15)
  • Different supply voltages (3V3, 5V)
  • with RX resistor (1k, 10k, 100k) and (1k + 680Ohm, as seen in picture)

The following code returns "Connecting to DFPlayer Mini failed!".
I am 100% sure i connected everything right, as it is working with a specific setup on the arduino.

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

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

// Create the Player object
DFRobotDFPlayerMini player;

void setup() {
  // Init USB serial port for debugging
  Serial.begin(9600);
  // Init serial port for DFPlayer Mini
  softwareSerial.begin(9600);

  // Start communication with DFPlayer Mini
  if (player.begin(softwareSerial)) {
    Serial.println("OK");

    // Set volume to maximum (0 to 30).
    player.volume(30);
    // Play the "0001.mp3" in the "mp3" folder on the SD card
    player.playMp3Folder(1);

  } else {
    Serial.println("Connecting to DFPlayer Mini failed!");
  }
}

void loop() {
}

Nothing works. I even had problems with the arduino. Non of the setups i found online, expect the one from the picture, worked.

Anybody have a clue how i can solve this?

Please post your test sketch that you used on the ESP32

1 Like

You should never post in the Uncategorised section.
It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best out of this forum before you proceed any further.

1 Like

ESP32 topic, UNO wiring diagram.
Oh well.

Try my sketch in post #33 of this thread.

https://forum.arduino.cc/t/df-player-problems/1256694/32

Not working. I dont get an "Connecting to DFPlayer Mini failed!" error anymore.
But even if the player is physically not connected the code is not returning an error.
So i assuem its juts dissabling validation

With the following setup:

My oscilloscope is showing the following Arduino TX pin signal:

Shoudlnt the signal go down to 0V?

SoftwareSerial does not work with ESP32 - if that is what you're using.
If you are using an ESP32 then you should be using its UART (i.e. Serial2).

Thanks a lot.
With Serial2 it looks a lot better.

But its still not working.

This is my current code

// My edit of yours. Compiles & runs here, Thu 9 May 2024 12:17.

//#include "Arduino.h" // Redundant, so I usually omit.
#include "DFRobotDFPlayerMini.h"
//#include <SoftwareSerial.h> // You're no longer using it.

DFRobotDFPlayerMini myDFPlayer;

// void printDetail(uint8_t type, int value);
// I usually find that function and and its lengthy definition
// superfluous. Replace both later if you want.

void setup()
{
  Serial2.begin(9600);
  Serial.begin(115200);
  delay(200); // My preference for print stability
  

  // if (!myDFPlayer.begin(Serial1, /*isACK = */true, /*doReset = */true)) {  //Use serial to communicate with mp3.
  // What was your source of that? I've removed the test entirely for
  // now, assuming your priority is getting it working.

  if (!myDFPlayer.begin(Serial2)) {// Start communication with DFPlayer
  // myDFPlayer.begin(Serial1, true, false); // Start communication with DFPlayer
    Serial.println("ERROR");
  }

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

  delay(1000); // Add this to allow player to fully initialise

  myDFPlayer.volume(15);  //Set volume value. From 0 to 30

  Serial.println("setup ended"); // I like this reassurance
}

void loop()
{
  //  myDFPlayer.play(001); // Ensure that your files have been renamed to 001, 002, etc.
  myDFPlayer.play(1);
  // Note: the 'name' is irrelevant to the module (but not to you,
  // of course). That command plays the first file that was copied
  // or moved to the uSD;  chronologically. Could be called
  // anything.

  delay(5000); // If you actually want to hear anything each time
  // through the loop! To hear entire tracks...another discussion.
}

Solved it now with the following wiring:

ESP PIN 4 = TX -> Player RX
ESP PIN5 = RX -> Player TX

// My edit of yours. Compiles & runs here, Thu 9 May 2024 12:17.

//#include "Arduino.h" // Redundant, so I usually omit.
#include "DFRobotDFPlayerMini.h"
//#include <SoftwareSerial.h> // You're no longer using it.

DFRobotDFPlayerMini myDFPlayer;
#define RXD2 5
#define TXD2 4
// void printDetail(uint8_t type, int value);
// I usually find that function and and its lengthy definition
// superfluous. Replace both later if you want.

void setup()
{
  Serial2.begin(9600, SERIAL_8N1, RXD2, TXD2);
  Serial.begin(115200);
  delay(200); // My preference for print stability
  

  // if (!myDFPlayer.begin(Serial1, /*isACK = */true, /*doReset = */true)) {  //Use serial to communicate with mp3.
  // What was your source of that? I've removed the test entirely for
  // now, assuming your priority is getting it working.

  if (!myDFPlayer.begin(Serial2)) {// Start communication with DFPlayer
  // myDFPlayer.begin(Serial1, true, false); // Start communication with DFPlayer
    Serial.println("ERROR");
  }

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

  delay(1000); // Add this to allow player to fully initialise

  myDFPlayer.volume(15);  //Set volume value. From 0 to 30

  Serial.println("setup ended"); // I like this reassurance
}

void loop()
{
  //  myDFPlayer.play(001); // Ensure that your files have been renamed to 001, 002, etc.
  myDFPlayer.play(1);
  // Note: the 'name' is irrelevant to the module (but not to you,
  // of course). That command plays the first file that was copied
  // or moved to the uSD;  chronologically. Could be called
  // anything.

  delay(5000); // If you actually want to hear anything each time
  // through the loop! To hear entire tracks...another discussion.
}

Used the wiring of this github project.

No idea why it worked with these pins but not with any other pin.

I have the following esp. Maybe it has something to do with it.
ESP32 Chip model = ESP32-D0WDQ6-V3 Rev 3

Maybe someone smarter can explain to me why it only works with the end setup.

You're saying it won't work with other RXD2, TXD2 ?
16, 17 ?

Did you read the thread, which was using a Mega 2560? Or just copy the code without change. My sketch used Serial 1 (pins 18/19) so you’d have to change for your board. If that’s an ESP32 why does your schematic show a UNO?

Also, I’m not clear which version of my sketch you used: the abbreviated one (without the test) or my EDIT? That is your original with my one line correction., so that does include the module test.