I am trying to run a DFRobotDFPlayerMini off an Arduino Uno R3. The code is below. I am using a 32 GB PNY micro card formatted to FAT 32. I tried both a WAV file and an MP3 file. The files are numbered 0001 and 0002 respectively. The MP3 file is set up as follows: Codec: MP3; Sample size: 16 bit; Sample rate: 44.1khz. My intent was that as soon as I uploaded the sketch, track 0002 (the MP3 file) would play. Nothing happens, and no LEDs light on the miniplayer. This might not be a question for this forum, but I did not know where else to go. Thanks.
#include <SoftwareSerial.h> //Allows us to assign different pins for serial use
#include <DFRobotDFPlayerMini.h>
int rxPin = 3;
int txPin = 2; //Sets up the send/receive from the Mp3 player
int track = 0002; //This is the track number on the micro SD card
SoftwareSerial fxSerial(rxPin, txPin); //calls the Mp3 player fxSerial
DFRobotDFPlayerMini fxPlayer;
void setup() {
// put your setup code here, to run once:
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT); // Tells Arduino what the Mp3 pins are doing
fxSerial.begin(9600); //Sets up the serial function for the Mp3 player
fxPlayer.begin(fxSerial); //this tells Arduino that the serial path for the Mp3 player is fxSerial (the name of the MP3 player)
fxPlayer.volume(30);// Volume can be 10 to 30)
}
void loop() {
// put your main code here, to run repeatedly:
fxPlayer.play(track);// Plays track 1
delay(15000); //this plays track 1 for 15 seconds. The speech must be less than 15 seconds long
}
Here is the wiring diagram to my question above about the DFPlayerMini
Thank you! I put in the resistor, and also think I had my rx and tx wires switched. It made a very short buzzing sound, and played the message part way through. Now it only makes a very short buzzing sound. The blue light on the platy does light up. I programmed a 15 second delay (to allow for the message) and now every 15 seconds the player buzzes and the blue light lights, but no message. Any ideas?
I read that I should put a 1k resistor between the DFPlayer Mini's RX pin (pin 2 in the player) and the Arduino. Is that what you meant for me to do, or should I add a resistor to both the rx and tx pins on the player?
No problem.
Do you have any thoughts on this:
It made a very short buzzing sound, and played the message part way through. Now it only makes a very short buzzing sound. The blue light on the player does light up. I programmed a 15 second delay (to allow for the message) and now every 15 seconds the player buzzes and the blue light lights, but no message. Any ideas?
Did you try the other suggestion from @van_der_decken ? This is the easiest way to test the DF player. If that does not work, there is no point testing it with the Uno.
Yes, I did try it. The 9 second message plays for just a few seconds, and cuts out. I wait for at least the 15 seconds of the programmed delay before trying it again
Here's some more information. I removed the Arduino from the circuit, and just powered the DFRobotDFPlayerMini off the 5 volts from the Arduino. If I short either pin 9 or 11 on the player, it sometimes plays the whole 9 second message, but most of the time it plays about a second or 2 and stops. Could this be a defective DFRobotDFPlayerMini ?
Thanks for all your help; I really do appreciate it.
No one can say with any certainty from this side of things. We can't see your hardware, we can't test your hardware. It's up to you to narrow it down. Try another DFPlayer. Try another speaker. Does reseating the DFPlayer change anything? Is your power supply capable to supplying enough current to power the DFPlayer? All of these questions and more are the kinds of things you need to be checking and finding the answers to.
Methodical testing as recommended up thread should isolate the problem. At least for now, we can ignore the Arduino.
I assume the two files play correctly for their full duration in any other media player?
If none of the above fix it, I would do a quick format on the microSD card, replace the files and try again.
EDIT: And when doing the independent DFR test don't forget that both IO1 (pin 9) and IO2 (pin 11) have dual functions. A long LOW on 9 (over about 750ms) lowers the volume, and on 11 it increases it. Perhaps while using 9 you are sometimes inadvertently reducing the volume to silence?
Get that checked and if necessary we can get back to looking at the Arduino, armed with your latest sketch and schematic.
Meanwhile I note in the schematic you have still not shown the 1k resistor between the UNO's TX and DFR's RX. Is your sketch also now outdated?
BTW, I'd personally never use pins 2 & 3, as interrupts are an occassional issue. Try 10 & 11 instead.
The micro SD card plays fine in my desktop computer. I put it back in the DFRobot DFPlayer Mini, and it only played the first 3 seconds of the 9 second message. This was when I shorted the player’s pins 9 and 10 (IO_1 and GND). I then grounded pin IO_1 to the breadboard ground (not the player’s pin 10), and the full message played every time I tried it. Full of optimism, I hooked the Arduino up again (updated schematic attached). Now. it only played the first 3 seconds. I disconnected the Arduino and grounded the player’s pin IO-1 to the breadboard ground, and it plays the full the message. I am using the 5 volts from the Arduino to power the player.
As for the comment on not using Arduino pins 2 and 3 , I am running out of PWM pins for the whole project, and several tutorials used pins 2 and 3, so that’s why I tried them.
Thanks everybody! It appears to work now. I followed the suggestions above, as well as some on Google. What did the trick was a dedicated power supply for the DFRobotDFPlayerMini. I used that to power the DFRobotDFPlayerMini, instead of using the Arduino. I also connected the grounds from the power supply and the Arduino. I am surprised that the DFRobotDFPlayerMini alone could power the speaker, but when I used the Arduino, there apparently wasn't enough power? In any event, I can now move on to the next step on my ambitious (for me, anyway) project of getting the DFRobotDFPlayerMini to play messages based on which button of an IR remote is pushed.
Hopefully, this may help others who have a similar problem.