DFPlayer Mini on ESP32 30 pin devkit

Hi,

I have the ESP32 dev module with 30 pin and ESP-Wroom-32 identical to the one here:

I am trying to use DFPlayer on this board.
Here in the example code:

There is SoftwareSerial library but that is for Arduino Uno and 8266 variants.
In case of Esp32 it defines

#define FPSerial Serial1

but when I try to compile, I get this error:

'Serial1' does not name a type
 #define FPSerial Serial1

what am I missing ?

Note: I might be selecting a wrong board type, because I can't find the exact name of this board. Any ideas ?

Please do not post in "Uncategorized"; see the sticky topics in Uncategorized - Arduino Forum.

I moved your topic to an appropriate forum category.

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.
Thanks in advance for your cooperation.

Use "ESP32 Dev Module" for that one, it will work.

this might help solve your Serial1 issue

or

thanks for your response.
If I select "esp32 dev module" , after I upload a code (even an empty code) , it goes into boot loop.
When I select "nodemcu-32s" , it does not go into boot loop and functions fine.
if the correct board is what you wrote, then what's wrong with my setup ?

when I use serial2 as you wrote, it compiles well. but I don't get any sound.


  DFRobotDFPlayerMini myDFPlayer;
  Serial2.begin(9600, SERIAL_8N1, /*rx =*/16, /*tx =*/17);
  if (!myDFPlayer.begin(Serial2, true, true)) {  
    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); 
    }
  }
  Serial.println(F("DFPlayer Mini online."));
  myDFPlayer.volume(20);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3

OK - then use the S version if it works for you.

How did you wire and power your DFPlayer ?

I used the attached diagram.
TX (gpio 17) is connected with a 1K resistor to the player.
RX (gpio 16) is directly connected to the player.
Powered directly with 5V (VCC+GND)
And the speaker is connected as in the image.
I have a Fat32 formatted SD card on it. And it has 7 short mp3 files.

Does the format or name of the mp3 file matter ?

When I remove player's power , TX or RX, I get an error. So I assume the connections are OK.

Is there a way to test the speaker ? (dfplayer command ?) When I plug power, I hear a tock sound from the speaker.


it seems like "play(1)" command does not work and the code is stuck there.


if (!myDFPlayer.begin(Serial2, true, true)) {  
    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(20); 
  Serial.println(F("DFPlayer Mini log 1."));
  myDFPlayer.play(1);  //Play the first mp3
    Serial.println(F("DFPlayer Mini log 2."));
  delay(1000);
  Serial.println(F("DFPlayer Mini log 3."));

because with this code all I get is:
13:01:17.462 -> DFPlayer Mini online.
13:01:17.961 -> DFPlayer Mini log 1.

It can't reach "log 2"
what might be the issue ?

the schema is with a MEGA, a 5V device. You are using an ESP32 which is a 3.3V device.

Are you sure your DF Mini works fine at 3.3V ?

have you tried without the RFID module?

DF mini working voltage range is 3-5V
But I am powering it directly with 5V.
And without the RFID result is same.

when I remove the esp32 module and give a direct command to the player (connect ground to IO1) , its led goes ON and sound comes from speaker.
So the speaker is working. Module is working.
But when the library is used, "play(1)" command does not work

can you post the full code? (or test code)

may be try with that library GitHub - PowerBroker2/DFPlayerMini_Fast: Fast and easy to understand Arduino library to use the DFPlayer Mini MP3 module from DFRobot.com. This is a huge improvement (both in terms of execution speed and simplicity) to the standard library provided by DFRobot.com.

well, I just put a delay(1000) command before the serial.begin() now and it works !!!

weird :man_shrugging:

Long shot: I eventually diagnosed some problems with the DFR player to a bug in the latest library version. Going back from 106 to 105 fixed it. Suggest you try same to eliminate that possibilty.

https://forum.arduino.cc/t/dfr-mini-player-library-bugs/1218680/6

thanks but my issue is already resolved by adding a delay to the startup before sending any sound command.