Problems with reading files on DFPlayer mini pro

I have problems with reading files on a DFPlayer mini Pro with Nano esp32

I use;

Computer: Imac M1 OS Somona 14.2.1

DFPlayer mini Pro

Arduino nano ESP32

Level shifter

5 V power supply

The nano ESP32 is loaded with the program found under examples - DFRobots_DF1201S-play

(encl. 1)

On the DFPlayer mini pro there are three folders under the root with mp3 files (made in

Speechello). All the files play their content when I click on them in the computer.

The set-up is found on enclosed Schema…. (encl 2). All connections between the different parts

are tested with an ohm meter and all the parts have a common ground. The nano ESP32 is

delivering 3.3 V to the level shifter and the power supply is delivering 5 Volt to the shifter and to

the DFPlayer mini pro

The reason why I use a level shifter is that i first tried to DFPlayer mini pro together with an

Arduino Mega and it worked fine. When I then tried it with the nano ESP32 it did not. OK - Mega is

a 5 Volt system so I tried a level shifter - no success.

At startup the the yellow diod is shining on the nano ESP32 and the blue diod on the mini pro. You

can hear from the speaker ”music” but nothing more happens. I can see on the serial monitor the

following message: Init failed, please check the wire connection! Repeatedly.

If I push the button on the mini pro it starts to play the files in uncontrolled order. It selects files

from different folders.

I have also tried a SD card reader (from Adafruit, as seen on the picture (3)) but it did not work).

The program could not see all the files (5/8) on a brand new formatted SD card. This SD card

reader worked perfectly together with the Mega. I have ordered new SD card readers to test.

Please help!

Best regards

Åke Silén

Sweden

encl. :

1 program used

2 Schema Nano ESP32-DFPlayer mini pro

3 picture
Program I used.pdf (42.9 KB)
Schema_Nano_ESP32-DFPlayer_mini_pro.pdf (1.4 MB)

Please, post sketches in open text and schematic images.

This sketch copied from github library

/*!
 *@file play.ino
 *@brief Music Playing Example Program
 *@details  Experimental phenomenon: control MP3 play music, obtain song information
 *@copyright  Copyright (c) 2010 DFRobot Co.Ltd (http://www.dfrobot.com)
 *@license     The MIT license (MIT)
 *@author [fengli](li.feng@dfrobot.com)
 *@maintainer [qsjhyy](yihuan.huang@dfrobot.com)
 *@version  V1.0
 *@date  2023-10-09
 *@url https://github.com/DFRobot/DFRobot_DF1201S
*/
#include <DFRobot_DF1201S.h>

/* ---------------------------------------------------------------------------------------------------------------------
 *    board   |             MCU                | Leonardo/Mega2560/M0 |    UNO    | ESP8266 | ESP32 |  microbit  |   m0  |
 *     VCC    |            3.3V/5V             |        VCC           |    VCC    |   VCC   |  VCC  |     X      |  vcc  |
 *     GND    |              GND               |        GND           |    GND    |   GND   |  GND  |     X      |  gnd  |
 *     RX     |              TX                |     Serial1 TX1      |     3     |   5/D6  |  D2   |     X      |  tx1  |
 *     TX     |              RX                |     Serial1 RX1      |     2     |   4/D7  |  D3   |     X      |  rx1  |
 * ----------------------------------------------------------------------------------------------------------------------*/
#if defined(ARDUINO_AVR_UNO) || defined(ESP8266)
#include "SoftwareSerial.h"
SoftwareSerial DF1201SSerial(2, 3);  //RX  TX
#else
#define DF1201SSerial Serial1
#endif

DFRobot_DF1201S DF1201S;
void setup(void)
{
  Serial.begin(115200);
#if (defined ESP32)
  DF1201SSerial.begin(115200, SERIAL_8N1, /*rx =*/D3, /*tx =*/D2);
#else
  DF1201SSerial.begin(115200);
#endif
  while (!DF1201S.begin(DF1201SSerial)) {
    Serial.println("Init failed, please check the wire connection!");
    delay(1000);
  }
  /*Set volume to 20*/
  DF1201S.setVol(/*VOL = */15);
  Serial.print("VOL:");
  /*Get volume*/
  Serial.println(DF1201S.getVol());
  /*Enter music mode*/
  DF1201S.switchFunction(DF1201S.MUSIC);
  /*Wait for the end of the prompt tone */
  delay(2000);
  /*Set playback mode to "repeat all"*/
  DF1201S.setPlayMode(DF1201S.ALLCYCLE);
  Serial.print("PlayMode:");
  /*Get playback mode*/
  Serial.println(DF1201S.getPlayMode());

  //Set baud rate to 115200(Need to power off and restart, power-down save)
  //DF1201S.setBaudRate(115200);
  //Turn on indicator LED (Power-down save)
  //DF1201S.setLED(true);
  //Turn on the prompt tone (Power-down save) 
  //DF1201S.setPrompt(true);
  //Enable amplifier chip 
  //DF1201S.enableAMP();
  //Disable amplifier chip 
  //DF1201S.disableAMP();
}

void loop()
{
  Serial.println("Start playing");
  /*Start playing*/
  DF1201S.start();
  delay(3000);
  Serial.println("Pause");
  /*Pause*/
  DF1201S.pause();
  delay(3000);
  Serial.println("Next");
  /*Play the next song*/
  DF1201S.next();
  delay(3000);
  Serial.println("Previous");
  /*Play the previous song*/
  DF1201S.last();
  delay(3000);
  Serial.println("Start playing");
  //Fast forward 10S
  DF1201S.fastForward(/*FF = */10);
  //Fast Rewind 10S
  //DF1201S.fastReverse(/*FR = */10);
  //Start the song from the 10th second 
  //DF1201S.setPlayTime(/*Play Time = */10);

  Serial.print("File number:");
  //Get file number
  Serial.println(DF1201S.getCurFileNumber());

  Serial.print("The number of files available to play:");
  //The number of files available to play
  Serial.println(DF1201S.getTotalFile());

  Serial.print("The time length the current song has played:");
  //Get the time length the current song has played 
  Serial.println(DF1201S.getCurTime());

  Serial.print("The total length of the currently-playing song: ");
  //Get the total length of the currently-playing song 
  Serial.println(DF1201S.getTotalTime());
  Serial.print("The name of the currently-playing file: ");
  //Get the name of the playing file 
  Serial.println(DF1201S.getFileName());
  delay(3000);
  //Play the file No.1, the numbers are arranged according to the sequence of the files copied into the U-disk 
  DF1201S.playFileNum(/*File Number = */1);
  //Play the test.mp3 file in test folder 
  //DF1201S.playSpecFile("/test/test.mp3");

  while (1) {
    // if(DF1201S.isPlaying()){
    //   Serial.println("is play");
    // }else{
    //   Serial.println("is stop");
    // }
  }
  /*Delete the currently-playing file */
  //DF1201S.delCurFile();
}

Is the red board the level shifter? Transistors look suspiciously oriented the same way... Are you sure that is bidirectional / is correctly oriented so TX and RX are following proper directions?

Yes. It is bought as bidirectional. If I remember correctly it is based on Fairchild BSS138

ESP32 TX to mini pro RX
ESP32 RX to mini pro TX
Checked with ohm meter before start

SoftwareSerial doesn't work with a "ESP32".
I believe it works no better with a "Nano ESP32".

The following is for the 'other' DFPlayer (the one without the USB_C), but the hardware serial implementation still carries --

HI
I have tried the program (Your?) earlier. Now when I read, perhaps more in detail, I found the following lines:
const byte RXD2 = 6; // Connects to module's RX
const byte TXD2 = 7; // Connects to module's TX
Is this correct? RXD2 connect to module´s RX not RX to TX?

I should change that. The DWG Arduino TX (D7) to the module's RX and Arduino RX (D6) to the module's TX.
In post no.12 I had deleted that - placing the DWG for clarity.

That's not in my post/s.

No change necessary.

RX goes to TX, TX goes to RX

Hi Runaway_pancake
I have tried your program suggestion and rewired to a DFplayer mini and the ESP32 to p6, p7. It works but the play function only plays the files according to the time they were made(?). I have tried to change the code to playFolder (2, 1); or playMp3Folder(2, 1); but it does not seem to work that way. (4 digits in the file number does not help. What is missing in the code ?

// ESP32dfmini01
//
#include "HardwareSerial.h"
#include "DFRobotDFPlayerMini.h"

const byte RXD2 = 6; // Connects to module's RX
const byte TXD2 = 7; // Connects to module's TX

HardwareSerial dfSD(1); // Use UART channel 1
DFRobotDFPlayerMini player;

void setup()
{
Serial.begin(19200);
dfSD.begin(9600, SERIAL_8N1, RXD2, TXD2); // 16,17
delay(5000);

if (player.begin(dfSD))
{
Serial.println("OK");

// Set volume to maximum (0 to 30).
player.volume(25); //30 is very loud

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

void loop()
{
Serial.println("Playing #1");
player.playFolder(2, 10);
Serial.println("play start");
delay(5000);
Serial.println("played");
delay(1000);

Serial.println("Playing #2");
player.playFolder(2, 11);
Serial.println("play start");
delay(10000);
Serial.println("played");
delay(1000);

Serial.println("Playing #3");
player.play(3);
Serial.println("play start");
delay(10000);
Serial.println("played");
delay(1000);

Serial.println("Playing #4");
player.play(4);
Serial.println("play start");
delay(10000);
Serial.println("played\r\n\r\n");
delay(1000);
}

OK - I have modified the program and the file numbers and now I think it is working.

Thank you this far. I may come back with more questions

Best regards; Åke

Sounds like a file organisation issue. To test this:

  1. Full format the micro SD card (long duration)
  2. Create a single folder in the root
  3. Copy several file to it, one by one: \01\001.mp3, \01\002.mp3, etc

Does your sketch now play those correctly?

EDIT: Looks like you fixed it while I was composing.
:slightly_smiling_face: