Nooob DFplayer MP3 issue - SerialWrongStack

Hey guys! New here, I have been getting into making some basic arduino circuits/projects with decent success however this latest is not working.

Basically i am replicating this kind of basic circuit:

I have tried a handfull of tutorials and all seem to stop in the same place:
The serial monitor shows
"Get Wrong Stack"

indicating the case has been triggered:

    case SerialWrongStack:
      Serial.println(F("Get Wrong Stack"));

The issue is, I cant find anywhere what this means and how to rectify it,
Looking through any documentation i cant see what these errors refer to.

I have tried 2 different MP3 chips to no avail. Circuit is as basic as it gets and I am using a 1k resistor (Tried also without it)

Can anyone help?

Code below:

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

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

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

Serial.println();
Serial.println(F("DFRobot DFPlayer Mini Demo"));
Serial.println(F("Initializing DFPlayer ... (May take 3~5 seconds)"));

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

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

void loop()
{
static unsigned long timer = millis();

if (millis() - timer > 3000) {
timer = millis();
//myDFPlayer.next(); //Play next mp3 every 3 second.
}

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;
}

}

Rule #1: Use code tags when posting code.

Now, scrap all the above crap. It looks like you want to do a basic code so let's use DF Mini Player Fast coding. It SHOULD be in your downloadable libraries, the author is PowerBroker. If not its downloadable here:

But try to use the Downloadable Library first. Now, let's get the Example code working first. Its as simple as it gets, so if you can't get it working its almost certainly a wiring issue.


#if !defined(UBRR1H)
#include <SoftwareSerial.h>
SoftwareSerial mySerial(10, 11); // RX, TX
#endif

DFPlayerMini_Fast myMP3;

void setup()
{
  Serial.begin(115200);

#if !defined(UBRR1H)
  mySerial.begin(9600);
  myMP3.begin(mySerial, true);
#else
  Serial1.begin(9600);
  myMP3.begin(Serial1, true);
#endif
  
  Serial.println("Setting volume to max");
  myMP3.volume(30);
  
  Serial.println("Looping track 1");
  myMP3.loop(1);
}

void loop()
{
  //do nothing
}
© 2021 GitHub, Inc.
type or paste code here

Let me know if you get that working, then we can go from there.

Hi! I have the same problem... "SerialWrongStack"
When I loaded the "example" sketch from the DFPlayerMini_Fast library, I got this notation from Serial Monitor:

Setting volume to max
Sent Stack:
7E FF 6 6 0 0 1E FE D7 EF

Looping track 1
Sent Stack:
7E FF 6 8 0 0 1 FE F2 EF

What can I do about this?

I appreciate this is an old thread, but can someone tell me what the first line means please:

#if !defined(UBRR1H)

Its a pre-processor directive to only process the following lines (upto the next #else or #endif), should the symbol UBRR1H not have a definition in the preprocessor.
I suspect this is a #define for a register (given the name), so its testing if the processor being compiled for lacks a particular bit of hardware with a UBRR1H register.

UBRR1H will be defined when there is a hardware Serial1 port on an Arduino. The code is checking to see if it needs to use SoftwareSerial. Notice later in setup there is another check to see whether to initialize mySerial (the SoftwareSerial port) or Serial1 (the hardware port):

#if !defined(UBRR1H)
  mySerial.begin(9600);
  myMP3.begin(mySerial, true);
#else
  Serial1.begin(9600);
  myMP3.begin(Serial1, true);
#endif

Thanks both, and apologies for only today seeing your replies.

As an aside, can I rely on the list that I get of my own posts? (Clicking the Profile icon top right.) Does it perhaps only get updated if there's at least one reply? This post does not seem to be in the list:

DF Robot Mini MP3 Player: the ‘better’ library?

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