Go Down

Topic: DFPlayer does not work with Arduino (Read 338 times) previous topic - next topic

cgmolina

Hello,

I'm using DFPlayer mini with arduino UNO. It work very well ALONE, but I can't made it work with ARDUINO.

If I power it alone, I can play a song, change the song, change sound level, etc
But when I tried to used with the Arduino, I get this message:

Initializing DFPlayer ...
Unable to begin:
1.Please recheck the connection!
2.Please insert the SD card!


I already checked the wiring and replaced the proto-board. I have it connected as the picture I attached.

any suggestion?

thanks in advance

cgmolina

I'm using an external 5V power source for the DFPlayer

Grumpy_Mike

I'm using an external 5V power source for the DFPlayer
Have you connected the ground of this to the ground of the Arduino?

cgmolina

yes, grounds are connected.

The strange thing is that the DFplayer works OK alone
I use pin 10, 11 for RX, TX


Grumpy_Mike

#4
Jan 11, 2020, 09:05 pm Last Edit: Jan 11, 2020, 09:06 pm by Grumpy_Mike
I think you need to post your code. Please read this:-
How to use this forum to tell you how to post code here.

Quote
The strange thing is that the DFplayer works OK alone
Why should it be strange? You have made some mistake and we are trying to track it down with your help.

cgmolina

Thanks for your answer
here is the code:

Code: [Select]

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

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

int buttonNext = 2;
int buttonPause = 3;
int buttonPrevious = 4;

boolean isPlaying = false;

void setup() {
    pinMode(buttonPause, INPUT);
    digitalWrite(buttonPause, HIGH);
    pinMode(buttonNext, INPUT);
    digitalWrite(buttonNext, HIGH);
    pinMode(buttonPrevious, INPUT);
    digitalWrite(buttonPrevious, HIGH);

    mySoftwareSerial.begin(9600);
    Serial.begin(9600);

    delay(1000);

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

    if (!myDFPlayer.begin(mySoftwareSerial)) {
        Serial.println("Unable to begin:");
        Serial.println("1.Please recheck the connection!");
        Serial.println("2.Please insert the SD card!");
        while (true);
    }
    Serial.println(F("DFPlayer Mini online."));

    myDFPlayer.setTimeOut(500);

    //----Set volume----
    myDFPlayer.volume(10); //Set volume value (0~30).
    //myDFPlayer.volumeUp(); //Volume Up
    //myDFPlayer.volumeDown(); //Volume Down

    //----Set different EQ----
    myDFPlayer.EQ(DFPLAYER_EQ_NORMAL);
    //  myDFPlayer.EQ(DFPLAYER_EQ_POP);
    //  myDFPlayer.EQ(DFPLAYER_EQ_ROCK);
    //  myDFPlayer.EQ(DFPLAYER_EQ_JAZZ);
    //  myDFPlayer.EQ(DFPLAYER_EQ_CLASSIC);
    //  myDFPlayer.EQ(DFPLAYER_EQ_BASS);

    myDFPlayer.outputDevice(DFPLAYER_DEVICE_SD);

    myDFPlayer.play(1); //Play the first song
    isPlaying = true;
    Serial.println("Playing..");
}

void loop() {
    if (digitalRead(buttonPause) == LOW) {
        if (isPlaying) {
            myDFPlayer.pause();
            isPlaying = false;
            Serial.println("Paused..");
        } else {
            isPlaying = true;
            myDFPlayer.start();
            Serial.println("Playing..");
        }
        delay(500);
    }
    if (digitalRead(buttonNext) == LOW) {
        if (isPlaying) {
            myDFPlayer.next();
            Serial.println("Next Song..");
        }
        delay(500);
    }

    if (digitalRead(buttonPrevious) == LOW) {
        if (isPlaying) {
            myDFPlayer.previous();
            Serial.println("Previous Song..");
        }
        delay(500);
    }
}



Grumpy_Mike

#6
Jan 13, 2020, 12:14 am Last Edit: Jan 13, 2020, 12:20 am by Grumpy_Mike
Your diagram shows the buttons are connected between input and ground which is fine. But your code shows that these have been defined as only INPUT. What you need is to enable the internal pull up resistors on these button inputs by using in the pinMode call INPUT_PULLUP. With floating inputs I suspect that the button inputs are sometimes zero and are over riding the serial control of the player.

Just use:-
Code: [Select]
void setup() {
    pinMode(buttonPause, INPUT_PULLUP);
    pinMode(buttonNext, INPUT_PULLUP);
    pinMode(buttonPrevious, INPUT_PULLUP);


The bit here
Code: [Select]
if (!myDFPlayer.begin(mySoftwareSerial)) {
Is failing. That is the Arduino has sent a message to the player and is not getting the right or any response. This could be due to the connections on the solderless bread board not making proper contact, or not being like the diagram. If the problem persists can you post a good clear picture of your circuit.

cgmolina

#7
Jan 13, 2020, 12:41 am Last Edit: Jan 13, 2020, 12:43 am by cgmolina
Thanks !!
still not working
Code: [Select]


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

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

int buttonNext = 2;
int buttonPause = 3;
int buttonPrevious = 4;

boolean isPlaying = false;

void setup() {
   // pinMode(buttonPause, INPUT);
   // digitalWrite(buttonPause, HIGH);
   // pinMode(buttonNext, INPUT);
   // digitalWrite(buttonNext, HIGH);
   // pinMode(buttonPrevious, INPUT);
   // digitalWrite(buttonPrevious, HIGH);

    pinMode(buttonPause, INPUT_PULLUP);
    pinMode(buttonNext, INPUT_PULLUP);
    pinMode(buttonPrevious, INPUT_PULLUP);

    mySoftwareSerial.begin(9600);
    Serial.begin(9600);




I changed the code as you told me

I attached the connections, are really easy

thanks in advance

cgmolina

pict of the protoboard

Grumpy_Mike

Thanks for the picture but I am all out of ideas, sorry.

xl97

Random thoughts on it:

* Are RX/TX correct?  try swapping them?
* Try changing the baud rate for the Serial.begin(); instantiation

* Is your DFPlayer module a legit YX5200 chip set version?  or a Chinese -clone- using a bogus chip?





Go Up