DFPlayer MP3 Module - Serial Comms Causing Playback Clicks

Hello good people,

I am making a sounder circuit for a friend using a DFPlayer Mini MP3 Module.

It's a simple design.

A Nano, a DFPlayer Mini and some momentary push buttons which I have mocked up on Breadboard. I am also using the DFPlayer Arduino Library btw.

The circuit works and I am just mocking up the first button which has a simple action:

Push button momentarily and MP3 will play uninterrupted til the end of the track.

But I'm getting issues with clicking whenever the Nano communicates with the DFPlayer over Serial to check that the MP3 is still playing.

This is the code I found to play an MP3 until the end of the track

//----DFPlayer State Checking Function
void dfPlayerStateCheck(){
  int playerState = 0;
  delay(100); //Delay after call to play mp3 function in main program loop
  while(playerState != 512) {
    delay(2000); // prevents clicks and static during playback - increase if necessary.
    playerState = myDFPlayer.readState();
  } //--END WHILE LOOP 
}

If I remove that function and just use a play() function call followed by a delay, the song plays for the duration of the delay without clicks so it's definitely the serial calls to check the player state causing it.

  • I have ruled out insufficient power supply problems by running the project off one shared 7805 Regulator and then powering the Nano and DFPlayer with their own separate 7805 regulators. No change.
  • I have also played around with the delay value to prevent clicks but they are still there whenever the Nano talks to the DFPlayer over serial while audio is playing.
  • I have 1K resistors in the Serial TX/RX lines and I've tried with, without, one with, one without and various combinations but nothing helps.
  • I have also played around with the "prevents clicks" delay in that function but it doesn't help. Increasing the value lessens the frequency of the clicks but they're still there. And decreasing the value obviously makes it worse with more clicks per second.

Does anyone have any other ideas please??

Thank you!

I had a similar issue as you describe when I would try to poll the DFPlayer to see if it was playing. My intention was that when it was time to play the track I would only start playback if the DFPlayer said it wasn't playing.

The problem with that as I found out was that from the time you tell the player to start playing it takes a period of time before the player says that it is playing (either over serial or via the busy pin). This allows the arduino to make a number of loops in the meantime and repeatedly tell the player to play again. This basically jacks the audio up as well as making it take a number of seconds to start playing (because it is trying over and over to start playing I think).

Anyway, I finally got around this by not asking the player for its status. Instead I created a global variable in my sketch where I manually kept track of if I had started playback yet or not. Once I did this, it play audio perfectly and the audio starts instantly as well.