DFplayer Mini is not on and is not working properly

Hello. This is my first time working with this DFPlayer and I dont really know what I do.
I've connected all the pins and the player is initialized/found but i cant really controll it
The LED on the player is not even on.

This is the code I used:

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

SoftwareSerial mySoftwareSerial(10, 11); // RX, TX
DFRobotDFPlayerMini myDFPlayer;

void setup() {
  Serial.begin(9600);
  mySoftwareSerial.begin(9600);

  Serial.println("Initializing DFPlayer...");

  if (!myDFPlayer.begin(mySoftwareSerial)) {
    Serial.println("ERROR: Could not detect DFPlayer.");
    while (true);  // Stop execution
  }

  Serial.println("DFPlayer initialized successfully.");

  myDFPlayer.volume(20);  // Set volume
  delay(500);  // Wait a bit for volume to apply

  int vol = myDFPlayer.readVolume();
  Serial.print("Volume set to: ");
  Serial.println(vol);

  myDFPlayer.play(1);  // Play track 0001.mp3
  Serial.println("Playing track 1...");
  delay(3000);  // Give some time to start playing
}

void loop() {
  int state = myDFPlayer.readState();

  if (state == 0) {
    Serial.println("Stopped.");
  } else if (state == 1) {
    Serial.println("Playing...");
  } else if (state == 2) {
    Serial.println("Paused.");
  } else {
    Serial.print("Unknown state: ");
    Serial.println(state);
  }

  delay(1000);  // Check status every second
}

I need to mention that all the files are mp3 and are named accordingly (001.mp3,002.mp3,etc)

Also something weird happens: When I try to use .play(1) it doesn't work but with playFolder(1,1) it just stops after a bit

Test the player like this:

Connect a wire to the AD0 pin. Touch the other end of the wire to ground. This should trigger the player to play one of the files and the blue LED should light.


GREAT
IT WORKS
THANK YOU

Ok. At least we know the DF player is not faulty.

What do you see on serial monitor?

Your sketch runs OK here on a Uno. (What's your device?)

Here's the initial output.

14:51:14.672 -> Initializing DFPlayer...
14:51:16.067 -> DFPlayer initialized successfully.
14:51:16.580 -> Playing track 1...
14:51:16.580 -> Playing track 1...
14:51:19.647 -> Unknown state: 513
14:51:20.669 -> Unknown state: 513
14:51:21.694 -> Unknown state: 513
14:51:22.719 -> Unknown state: 513
14:51:23.740 -> Unknown state: 513
14:51:24.764 -> Unknown state: 513
14:51:25.787 -> Unknown state: 513
14:51:26.811 -> Unknown state: 513
14:51:27.833 -> Unknown state: 513
14:51:28.856 -> Unknown state: -1
14:51:29.875 -> Unknown state: 512
14:51:30.896 -> Unknown state: 512
14:51:31.921 -> Unknown state: 512
14:51:32.898 -> Unknown state: 512
etc

I don't understand the purpose of your sketch. For instance, what's all that state reporting in your loop()?

I assume your MP3 file(s) are in the SD root, named 0001.mp3, 0002.mp3, etc and that there no other files, including hidden. If unsure, format the card and try again.

Without a schematic we can't check your wiring.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.