The DFplayer mini is essentially a small mp3-player which can be controlled by an Arduino. With the provided library you can easily control the module by calling functions, which makes the DFplayer mini easy to implement in projects using Arduino.

What you will need

  • DFPlayer mini MP3 module
  • MicroSD card + adapter
  • Arduino
  • 2 x 1kΩ resistors
  • 2 x pushbuttons
  • 10kΩ potentiometer
  • Mini Jack cable
  • Mini jack female adaptor
  • Breadboard + jumper wires

 

 

Trying it out with example code A

The first example aims to get the module up and running, with your selected audiofiles. The code works by calling the play function and cycling through all files with a 10 second interval.

  1. Start by downloading and installing the Arduino library provided by dfrobot (see link above).
  2. Connect Arduino, speaker and DFplayermini as seen on the diagram below. Remember to turn on the speaker.
  3. Access your MicroSD card, rename it to ‘mp3’ and add .mp3-files as needed. Filenames must start with 0001, 0002 etc. such as “0001YourFileNameHere.mp3”
  4. Download AIRLab example code A from above, and upload the code to your Arduino

Your mp3 files should now cycle and play 10 seconds each!

Setting up a simple music player with example code B

For this next example we will set up a simple music player that adds two buttons to skip forwards or backwards between music files, as well as a potentiometer for volume control. The code will play the first audiofile. The buttons and potentiometer are coded using debounce.

  1. Start by adding components as seen on the diagram below
  2. Download AIRLab example code B from above, and upload the code to your Arduino
  3. Run the code and open the serial monitor.
  4. Test the buttons and volume control to make sure everything is working – the serial monitor should print statements based on interaction with the buttons and volume control!

NB: A know issue with the DFPlayer Mini is currently the appearance of a ghost-track (a seemingly empty music-file) between each added Mp3 file. This means that two clicks are needed to play the next or previous track when cycling through your tracks with buttons. A quick workaround is to simply duplicate the function call for previous/next track if you experience this. 

NB: If the volume immediately drops to zero, you may need to reverse the polarity of the potmeter