ArduinoTroubleshooting

Arduino Mega and DFRobot mini MP3 player

userHead Sarina.Till 2023-07-13 23:01:13 370 Views4 Replies

Hi, 

 

I hope someone can help me, I am trying to work with a mini MP3 player and the Arduino Mega board. 

 

I am using the following sketch:

 

```#include "DFRobotDFPlayerMini.h"

DFRobotDFPlayerMini myDFPlayer;

void setup() 
{
 Serial.begin(9600);
 Serial1.begin(9600);
 delay(2500);
 myDFPlayer.begin(Serial1, true);

 Serial.println(myDFPlayer.begin(Serial1));
 if(!myDFPlayer.begin(Serial1))
 {
  Serial.println("Problem");
  while (true);
 }

 if(myDFPlayer.begin(Serial1))
 {
   Serial.println("Good");
    
 }
}

void loop ()
{

  myDFPlayer.volume(30);
  myDFPlayer.play(1);
  delay(5000);
 
}

```

 

And I have connected the MP3 player to the Arduino as follows:

 

Adruino             MiniMp3 player 

Rx (18)-------------------→ Tx

Tx(19)----------------------- Rx 

GND----------------------------GND

5V-------------------------------VCC

 

Speaker             MiniMp3 player

SPK1--------------------SPK1

SPK1----------------------SPK1

 

I am using the following speaker: https://www.diyelectronics.co.za/store/audio/1502-small-speaker-4-3w-2-inch.html?search_query=speaker+arduino+&results=18

 

No sound plays through the speaker at all.  This is what I see and hear

 

https://drive.google.com/file/d/1c0aRlhMpArySE-s0N4fzwUY4Asz7xpne/view?usp=sharing

 

https://drive.google.com/file/d/1_o6X5bR-Y3Y_ABRb8Oq8h6SuAzqCoyIa/view?usp=sharing

 

The SD card has a file named 0001.mp3 on the root of a FAT32 32GB MicroSD card. 

 

I have the 1K resistor set up between the Rx pin and the Arduino. 

 

I have been stuck for days, any help would be greatly appreciated. 

 

 

 

2023-07-14 23:23:55

Update ,  it is working !!! I had to replace the SDCard and use the code provided on the wiki . 

THANK YOU Jenna !!!!

userHeadPic Sarina.Till
2023-07-14 22:49:32

```#include "Arduino.h"#include "DFRobotDFPlayerMini.h"

#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266))   // Using a soft serial port#include <SoftwareSerial.h>SoftwareSerial softSerial(/*rx =*/19, /*tx =*/18);#define FPSerial softSerial#else#define FPSerial Serial1#endif

DFRobotDFPlayerMini myDFPlayer;void printDetail(uint8_t type, int value);

void setup(){#if (defined ESP32) FPSerial.begin(9600, SERIAL_8N1, /*rx =*/19, /*tx =*/18);#else FPSerial.begin(9600);#endif

 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(FPSerial, /*isACK = */true, /*doReset = */true)) {  //Use serial 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){     delay(0); // Code to compatible with ESP8266 watch dog.   } } 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(){  myDFPlayer.play(1);}```

userHeadPic Sarina.Till
2023-07-13 23:56:58

Hi!

 

1.Perhaps you can try the example in the wiki. This code is tested on Arduino Uno, Leonardo, Mega boards. It might be worth a shot!

 

DFPlayer Mini Mp3 Player - DFRobot Wiki

 

2.pls check the location of the MP3 file.

MP3-2.png
MP3-1.png
userHeadPic jenna
Sarina.Till wrote:

Hi Again, 

 

Thank you so much for your reply

 

I have updated the code :

 

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

#if (defined(ARDUINO_AVR_UNO) || defined(ESP8266))   // Using a soft serial port#include <SoftwareSerial.h>SoftwareSerial softSerial(/*rx =*/19, /*tx =*/18);#define FPSerial softSerial#else#define FPSerial Serial1#endif

DFRobotDFPlayerMini myDFPlayer;void printDetail(uint8_t type, int value);

void setup(){#if (defined ESP32) FPSerial.begin(9600, SERIAL_8N1, /*rx =*/19, /*tx =*/18);#else FPSerial.begin(9600);#endif

 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(FPSerial, /*isACK = */true, /*doReset = */true)) {  //Use serial 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){     delay(0); // Code to compatible with ESP8266 watch dog.   } } Serial.println(F("DFPlayer Mini online."));

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

void loop(){} 

I get the the following output:

 

16:46:32.037 -> 16:46:32.037 -> DFRobot DFPlayer Mini Demo16:46:32.037 -> Initializing DFPlayer ... (May take 3~5 seconds)16:46:33.069 -> DFPlayer Mini online. 

 

But nothing plays through the speaker. I have updated the folder structure on the SD card to match yours. I am using the following speaker - could that be the problem ?

 

https://www.diyelectronics.co.za/store/audio/1502-small-speaker-4-3w-2-inch.html?search_query=speaker+arduino&results=18

2023-07-14 22:48:49
1 Replies