Arduino Nano 328p to DFPlayer Mini

Hello everybody,

I tried creating an arduino Nano ATmega328p project where I can play MP3 files on a speaker attached to a DFPlayer Mini.

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

const int soundSerialRx = 10; // RX des DFPlayer Mini
const int soundSerialTx = 11; // TX des DFPlayer Mini
const int ledPin1 = 2; // LED 1
const int ledPin2 = 3; // LED 2
const int buttonPin = 4; // Taster

SoftwareSerial soundSerial(soundSerialRx, soundSerialTx);
DFRobotDFPlayerMini soundPlayer;

unsigned long startTime = 0; 
bool isPlaying = false; 

void setup() {
  pinMode(ledPin1, OUTPUT);
  pinMode(ledPin2, OUTPUT);
  pinMode(buttonPin, INPUT_PULLUP);

  soundSerial.begin(9600);
  soundPlayer.begin(soundSerial);

  soundPlayer.volume(30);
}

void loop() {
  if (digitalRead(buttonPin) == LOW && !isPlaying) { 
    soundPlayer.playMp3Folder(1);

    for (int i = 0; i < 20; i++) { 
      digitalWrite(ledPin1, HIGH);
      digitalWrite(ledPin2, LOW);
      delay(50); 
      digitalWrite(ledPin1, LOW);
      digitalWrite(ledPin2, HIGH);
      delay(50); 
    }

    startTime = millis(); 
    isPlaying = true; 
  }


  if (isPlaying && (millis() - startTime >= 5000)) {
    digitalWrite(ledPin1, LOW);
    digitalWrite(ledPin2, LOW);
    isPlaying = false;
  }

  if (digitalRead(buttonPin) == HIGH && isPlaying) {
    isPlaying = false;
  }
}

I attached the Pin11 of Arduino to TX and Pin10 to RX.
The folder on my SD-Card (16gb, formatted in fat32) is called "mp3" and the file inside 0001.mp3
The arduino gets power, but in the serial Monitor i only get the errors:

18:57:33.367 -> DFRobot DFPlayer Mini Demo
18:57:33.367 -> Initializing DFPlayer ... (May take 3~5 seconds)
18:57:33.367 -> ~⸮ Unable to begin:
18:57:35.595 -> 1.Please recheck the connection!
18:57:35.595 -> 2.Please insert the SD card!

The attached speaker is a "Mini speaker 40mm 8 Ohm 0.5W"

The LEDs are functioning as expected, but can be ignored for the sake of this question.

Why do i not get audio output?

First replace the smoke alarm battery, it is useless for this purpose. Either use a wall wart (5V) or your computer USB cable.

Doesn't work with the computers USB cable either. The Battery is a 5V battery.

So power is ok. Add serial.println statements before and after areas of code that you think are both working and not working. Then depending on the outputs move the prints closer to the point of failure. Repeat that until the problem is solved.

I'm honestly not sure if it's about code but instead maybe about the connection between the arduino and the player not working according to the error log.

Show all the error log in code tags

I just noticed, in your OP the error messages are NOT in your code, but in the library code. Open the library code and find where the messages are created, maybe some extra debug will help or a comment may help. It appears to fail on the 'begin' method.

These are the errors I am getting

Will try to look into that, thank you. Do you think with my power supply and the wiring everything is okay as is?

As long as your power supply is providing 5V and can deliver a couple amps like your computer USB or a 5V wall wart then yes.
I can't see your wiring, maybe read the pinned post re how to do that.

1 Like

I forgot to mention, try to eliminate the breadboard, they are notoriously bad connectors.

1 Like

TX of the Arduino should go to RX of the player, via a 1k resistor to drop the voltage. And it looks as if you have them reversed?