Weird behavior from DFPlayer Mini

Hi All,
I've recently started working on a project I saw online for a Helldivers Stratagem orb with lights and sound. I've managed to get it working but with a small snag. When I power up the arduino nano via usb the DFPlayer isn't playing sounds (through the speaker obviously).

I thought this might be a wiring issue or an issue with format of the SD card but after investigating further I've determined that doesn't seem to be the issue in this case. After powering up, if I remove the SD card and re-insert it, the light on the DFPlayer flashes, the speaker makes a pop sound, and then the files on the SD card work as intended and sound is played whenever the button is triggered.

However, after powering it off, and then powering on again, I once again have to remove and reinsert the SD card before it starts playing sound again.

I'm stumped by this and would really appreciate if anyone has any suggestions. I've tried 2 different SD cards with the same result. Is it possible I just got a bad DFPlayer? Could it be the SD card? Or could it be something software side.

Using an Arduino Nano clone, with DFPlayer Mini MP3-TF-6p V3.0. Currently powered by usb and there is a 1k Ohm resistor on the RX pin of the Player from pin 11 on the arduino nano.

Code can be found on PlentifulProps youtube/github.

Out curiosity, how are the files structured? Are they just dumped in the root directory or are they in a folder called MP3?

So, I believe this was a problem initially as I had originally dumped the mp3 file straight into the root and named it 0001.mp3. After some research online it appeared that the correct structure was inside a folder called MP3. This resolved the issue with it not playing at all.

However, that was when I discovered the issue of having to remove and reinsert the SD card after powering the circuit on.

I have mine in the root and while every other track is an audio track (because the other "tracks" are information), I haven't had any other issues. I just increment by 2.

I'll try your same structure and see if I can replicate it.

Code should be presented here!

How to get the best out of this forum - Development Tools / IDE 1.x - Arduino Forum

I was unsure of whether I should be sharing it as it's not my code

If the problem is with the code, how can you expect help if you don't post it?

1 Like

How about this, what library are you using?
I recommend using “DFPlayerMini_Fast”

Parallel to your "filename" issue, have you tried I/O Mode? That requires VCC, GND, SPK_1, SPK_2 and grounding IO_1 or IO_2 to play NEXT/PREV file. This might help you validate the files.

I posted 2 videos and provided my audio files. Yes they are from Twisted Metal 1.

No thank You.

Here is the code from the project by Plentiful Props (Freely Distributed, I did not make this)

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

#define BUTTON_PIN 2
#define NEOPIXEL_PIN 3
#define NUM_PIXELS 12

#define DFPLAYER_RX 10
#define DFPLAYER_TX 11

#define DEBOUNCE_DELAY 50
#define LONG_PRESS_TIME 2000

Adafruit_NeoPixel pixels(NUM_PIXELS, NEOPIXEL_PIN, NEO_GRB + NEO_KHZ800);
SoftwareSerial mySoftwareSerial(DFPLAYER_RX, DFPLAYER_TX);
DFRobotDFPlayerMini dfPlayer;

bool neopixelsOn = false;
bool colorIsRed = true;
bool buttonState = false;
bool lastButtonState = false;
unsigned long buttonPressTime = 0;
unsigned long lastDebounceTime = 0;

void setup() {
    Serial.begin(115200);
    mySoftwareSerial.begin(9600);
    
    pinMode(BUTTON_PIN, INPUT_PULLUP);
    
    pixels.begin();
    pixels.clear();
    pixels.show();
    
    if (!dfPlayer.begin(mySoftwareSerial)) {
        Serial.println("DFPlayer Mini not detected!");
    } else {
        Serial.println("DFPlayer Mini ready.");
        dfPlayer.volume(30);
    }

    Serial.println("Setup complete. Waiting for button press...");
}

void loop() {
    int reading = digitalRead(BUTTON_PIN);
    unsigned long currentTime = millis();

    if (reading != lastButtonState) {
        lastDebounceTime = currentTime;
    }

    if ((currentTime - lastDebounceTime) > DEBOUNCE_DELAY) {
        if (reading == LOW && !buttonState) {
            buttonState = true;
            buttonPressTime = currentTime;
        } 
        else if (reading == HIGH && buttonState) {
            buttonState = false;

            if ((currentTime - buttonPressTime) >= LONG_PRESS_TIME) {
                colorIsRed = !colorIsRed;
                Serial.print("Long press detected. New color: ");
                Serial.println(colorIsRed ? "Red" : "Blue");
            } 
            else {
                neopixelsOn = !neopixelsOn;
                Serial.print("Short press detected. NeoPixels now ");
                Serial.println(neopixelsOn ? "ON" : "OFF");

                if (neopixelsOn) {
                    setNeoPixelColor(colorIsRed ? 255 : 0, 0, colorIsRed ? 0 : 255);
                    
                    if (dfPlayer.available()) { // Prevent blocking
                        dfPlayer.play(1);
                        delay(100);
                        Serial.println("Playing sound effect #1.");
                    } else {
                        Serial.println("DFPlayer not ready, skipping sound.");
                    }
                } 
                else {
                    pixels.clear();
                    pixels.show();
                }
            }
        }
    }

    lastButtonState = reading;
}

void setNeoPixelColor(int red, int green, int blue) {
    for (int i = 0; i < NUM_PIXELS; i++) {
        pixels.setPixelColor(i, pixels.Color(red, green, blue)); // Adjust for WS2811 GRB
    }
    pixels.show();
}

Using the DFRobotDFPlayerMini library as this is what the author of the code has created it with.

Thanks, Will give this a go with a breadboard and a spare player when I get a chance.

Do you know what are in those two video?

That library never seemed to work for me. The module would only work some of the time, probably similar to what you are seeing on your end, though I don't recall needing to remove and reinsert the card to get it to work.

Firstly, I don't see how that code can reliably play tracks. Please provide a link to the original source of the project you are using. How will the bool _isAvailable ever become true as the code stands?

Secondly, let's clear up the card format issue. Misinformation seems widespread. The player module cares nothing for the format of MP3 files in the root. You could have the files named anything (within the OS specification). All that matters (to the module) is the order in which you copied the files to the card. Of course, it does matter to you, to manage the structure!

Thirdly, try fixing the 'popping' sound by changing

if (!dfPlayer.begin(mySoftwareSerial))

to

if (!dfPlayer.begin(mySoftwareSerial), true, false)

Finally, can you describe exactly what you want your nano to do.
I don't have a neopixel strip at hand but could substitute say a simple blinking led to focus on the player issue.

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