DFPlayer Mini not working with Arduino Nano

Hi there,

I'm new here and I've recently started playing around with Arduino in order to add lights and sound to my model kits.

So far I'm pleasantly surprised how easy it was to setup a working DFPlayer on an Arduino Uno.

But, when I tried the exact same setup linked to an Arduino Nano, I can't get the DFPlayer to play anything.

In both cases I'm using the exact circuit from the DFRobot wiki, where the Arduino is powered by a USB cable:

Here's my code:

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

int serial1 = 10;
int serial2 = 11;

SoftwareSerial mySoftwareSerial(serial1, serial2); // RX, TX
DFRobotDFPlayerMini myDFPlayer;
void printDetail(uint8_t type, int value);

void setup()
{
  pinMode(serial1, INPUT);
  pinMode(serial2, OUTPUT);

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

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

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

  myDFPlayer.volume(10);  //Set volume value. From 0 to 30
  myDFPlayer.play(1);  //Play the first mp3
}

void loop()
{
  if (myDFPlayer.available()) {
    printDetail(myDFPlayer.readType(), myDFPlayer.read()); //Print the detail message from DFPlayer to handle different errors and states.
  }
}

void printDetail(uint8_t type, int value) {
  switch (type) {
    case TimeOut:
      Serial.println(F("Time Out!"));
      break;
    case WrongStack:
      Serial.println(F("Stack Wrong!"));
      break;
    case DFPlayerCardInserted:
      Serial.println(F("Card Inserted!"));
      break;
    case DFPlayerCardRemoved:
      Serial.println(F("Card Removed!"));
      break;
    case DFPlayerCardOnline:
      Serial.println(F("Card Online!"));
      break;
    case DFPlayerPlayFinished:
      Serial.print(F("Number:"));
      Serial.print(value);
      Serial.println(F(" Play Finished!"));
      break;
    case DFPlayerError:
      Serial.print(F("DFPlayerError:"));
      switch (value) {
        case Busy:
          Serial.println(F("Card not found"));
          break;
        case Sleeping:
          Serial.println(F("Sleeping"));
          break;
        case SerialWrongStack:
          Serial.println(F("Get Wrong Stack"));
          break;
        case CheckSumNotMatch:
          Serial.println(F("Check Sum Not Match"));
          break;
        case FileIndexOut:
          Serial.println(F("File Index Out of Bound"));
          break;
        case FileMismatch:
          Serial.println(F("Cannot Find File"));
          break;
        case Advertise:
          Serial.println(F("In Advertise"));
          break;
        default:
          break;
      }
      break;
    default:
      break;
  }
}

The serial monitor outputs the following:

Initializing DFPlayer ...
Unable to begin:
1.Please recheck the connection!
2.Please insert the SD card!
Time Out!
DFPlayerError:Card not found
Time Out!

Which is very weird since the SD card is present. When at this point I remove the SD card and insert it again, the serial monitor shows these messages (as expected):

Card Removed!
Card Inserted!

So it looks to me like the DFPlayer works at least in some part. Since this exact same setup and code work flawlessly on my Uno, I wonder if anyone can tell me what is wrong here?

Make sure it is pressed tightly in. To get it out, press in again and it pops out.

beapilot:
Make sure it is pressed tightly in. To get it out, press in again and it pops out.

The card is inserted correctly. Without touching the card but switching to the Uno (using the same DFPlayer module) it all works flawlessly.

OK so I'm embarrassed to report that the issue was related to one of the wires of the resistor not being connected correctly between pin 11 and the Dfplayer .. :o All works great now!

Is the Nano a +5v one? Or a +3.3v one?

Have you tried powering from the VIN pin instead? (when powered from a stable 5v source?)

Wonder if its not getting enough current?

OMG thank you for posting this.

...
I've been trying to get this to work for 2 days now, and i had the exact same problem, cut resistor too short

I had a similar problem with Arduino nano and DFplayer: Playing mp3s via software worked with Arduino uno, but not with Arduino nano. With the example code (and all other sketches) speaker produced noise and popping noises and software serial reported com problems.

As I stumbled over this thread while searching for an answer, I'll document the result here as well for future reference.

The problem with dfplayer mini and arduino nano in my case was caused by three things:

  • wrong wiring of rx / tx ports
    Reading the comments in the example sketch of the DFPlayer library, I assumed that the digital RX/TX on the arduino nano goes to the same corresponding RX/TX on the DFPlayer. This is not so! Valuable lesson about serial connection, digital RX (pin 10 in my sketch on the arduino) should be connected to TX on DFPlayer, and digital TX (pin 11 in my sketch on the arduino) should be connected to RX on the Dfplayer.

  • dot files on the sd card, caused by mac os x
    Mac computers litter the sd card with lots of unneccessary dot files, that can cause problems with dfplayer (also with catalex mp3 serial player, for the record). What helped was following the tips from RepRage – DFPlayerMini cheat sheet . If you don't want to remove it via terminal every time, there is also software like "clean my drive" for this mac-software-generated problem.

  • odd behavior of my cheap ch340 arduino nanos
    A bad karma situation: My cheap asian arduinos caused long debugging pain. I had to power my Cheap Arduino Nano (CAN) and the DFPlayer through an external power supply -for some reason the whole setup would not work when powered through my trash-CAN. Before uploading code, I unplugged the external power supply, after uploading I unplugged usb and plugged in the external power supply. For some reason, serial port communication would be fine when first powering the whole setup through the external power supply, connection the CAN via USB only afterwards.

Final setup:

Fun and games. But now it works.

Hello,
Just for your info, I just solved a problem with the dfplayer start. The SD wont start because there was a bad weld in the dfplayer module... The pin rx or tx not shure it was touching the sd mount (so GND), I scratched it and solved.

1 Like

I have tried the above connection. But after connecting with Arduino only ghezz ghezz sound is coming from the speaker and immediately the LED of the DF player is gone.

A resistor (about 1k Ohm) is needed in the TX line.

Hi,

I have the following problem when I compile my code:

In function mySoftwareSerial': (.text+0x0): multiple definition of mySoftwareSerial'

In function mySoftwareSerial': (.text+0x0): multiple definition of myDFPlayer'

I use the libraries AVR Sleep to sleep the Arduino and FastLED for a strip LED. I have read that it may be due to a conflict between libraries that want to use the same interruptions or timers of the arduino, how could I solve this?

Thank you.

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