You are here

JAL Library for the DFPlayer Mini module

This JAL Library supports all features of the DFPlayer Mini, an audio playback device. The DFPlayer Mini is controlled via the serial interface using a fixed baudrate of 9600 baud. It can operate on 5 Volt but it is recommended to use 1k resistors in the serial communication lines between the PIC and the DFPlayer Mini.

The DFPlayer Mini plays audio files in mp3 or wav format, stored on e.g. a micro sd card that can be inserted into the device. A loudspeaker can be connected directly to the DFPlayer Mini of which the volume can be controlled via the API provided by the library.
A draft version of the library was already distributed and used in this project by an enthusiastic JAL user: https://youtu.be/washUeNLm_8

The library is set up in a way that the main program determines which serial interface is being used for controlling the DFPlayer Mini. Three sample files are available, a simple version (16f1823_dfplayer.jal) that plays the first track, waits for 10 seconds and then plays the next track. The other sample program (16f19176_dfplayer.jal) uses a menu structure with which all features of the library can be controlled. The third sample 12f617_dfplayer.jal shows the same functionality as the 16f1823 version but this version is meant to show that it can work on a smaller PIC that has no on-board USART so it uses the software serial interface to control the DFPlayer Mini.

It took me some time to understand the folder structure and file structure that is being used. This structure is documented in the dfplayer.jal library and is defined as follows:
• Folders used must be named 01 to 99, ADVERT or MP3
• Audio files are numbered 001 to 255 or 0001 to 3000 with extension .mp3 or .wav
• Folders 01 to 15 can contain audio files named 001 to 255 and 0001 to 3000, these are the so called special 3000 track folders.
• Folders 16 to 99 can contain audio files with names 001 to 255
• Folder ADVERT can contain advertisement audio files named 0001 to 3000
• Folder MP3 can contain mp3 only audio files named 0001 to 3000

So audio files (tracks) are always numbers and they have to be exactly 3 or 4 digits with the extension .mp3 or .wav. Note that some API functions only work on files with 3 digits and some other on audio files with 4 digits. It is possible to combine these different files in folders 01 to 15, so you could have audio files in these folders like 001.wav, 1234.mp3.

To play track 011.wav from folder 02 you the procedure call is dfplayer_play_folder(2,11) but if you want to play track 1234.wav from the same folder with number 02 the procedure call is dfplayer_play_3000_folder(2, 1234). When calling procedure dfplayer_play_advertisement(2000), the DFPlayer will interrupt the playback of the current track, plays the advertisement track 2000 (.wav or .mp3) from the ADVERT folder and will resume play after the advertisement track has completed.

The module has some other special features like a repeat track, repeat folder and an equalizer. It also has a sleep function that can be called via the API of the library but the only way to wakeup the DFPlayer after sleep is by switching the power off and on again.

The tests of the library where done with the folders and files stored on a micro sd card but the module and the library also support other storage devices.