DFPlayer Mini MP3 with BS2.
Michelt35
Posts: 4
in BASIC Stamp
Needs some help. I have hard time to access the DFPlayer with BS2 using the serial port. I re-check my software few times and unable to control it with the SEROUT instruction. Someone SVP?
Michel.
Michel.
Comments
http://www.picaxe.com/docs/spe033.pdf
Thank you. I have a resistor on the serial link. Still have a communication problem. Still looking for a solution.
Thank you. I will try with the restart MP3 thing. My software did not include this step.
Your DF mini has more input pins than the YX5300 I used, providing direct access to play, track select and volume functions. Trying those to verify that the player is functional would be prudent, only then move on to using the serial commands.
Note that the uSD card must have specific folder names (only 01,02,03...) and the files within those folders must be named 001xxxx.MP3, 002yyyy.MP3, 003zzzz.MP3...) per the attached illustration. Nothing else works.
Edit: my YX5300 can use files named 001-1stMarker.MP3 but perhaps yours can't. Per the illustration, stick with 001.MP3 002.MP3 etc to be safe.
One of my early mistakes with the YX5300 module was trying to play WMA files. They never work, only MP3 files. I shan't forget.
The datasheet for your module looks similar to the CY-T16 module that I helped someone get working a few years ago.
How do you have the module hooked up to your BS2 and what is the code that you are using?
Command Name Command String (HEX) Command Description
[Next Song] 7E FF 06 01 00 00 00 EF Play next song
[Previous Song] 7E FF 06 02 00 00 00 EF Play previous song
[Play with index] 7E FF 06 03 00 00 01 EF Play the first song
7E FF 06 03 00 00 02 EF Play the second song
[Volume up] 7E FF 06 04 00 00 00 EF Volume increased one
[Volume down] 7E FF 06 05 00 00 00 EF Volume decrease one
[Set volume] 7E FF 06 06 00 00 1E EF Set the volume to 30 (0x1E is 30)
[SET_EQUALIZER] 7E FF 06 07 00 00 1E EF 0=Normal, 1=Pop, 2=Rock, 3=Jazz, 4=Classic 5=Base
[Single cycle play] 7E FF 06 08 00 00 01 EF Single cycle play the first song
[Select device] 7E FF 06 09 00 00 02 EF Select storage device to TF card
[Sleep mode] 7E FF 06 0A 00 00 00 EF Chip enters sleep mode
[Wake up] 7E FF 06 0B 00 00 00 EF Chip wakes up
[Reset] 7E FF 06 0C 00 00 00 EF Chip reset
[Play] 7E FF 06 0D 00 00 00 EF Resume playback
[Pause] 7E FF 06 0E 00 00 00 EF Playback is paused
[Play with folder 7E FF 06 0F 00 01 01 EF Play the song with the directory:/01/001xxx.mp3
and file name] 7E FF 06 0F 00 01 02 EF Play the song with the directory:/01/002xxx.mp3
[Stop play] 7E FF 06 16 00 00 00 EF Stop playback
[Cycle play with 7E FF 06 17 00 01 02 EF 01 folder cycle play
folder name]
[Set single 7E FF 06 19 00 00 00 EF Start up single cycle play
cycle play] 7E FF 06 19 00 00 01 EF Close single cycle play
[PLAY With Volume] 7E FF 06 22 00 01 0E EF Play track at the specified volume. Data hi byte is the track index,
low byte is the volume level [0..30
[SHUFFLE_FOLDER ] 7E FF 06 28 00 01 00 EF Playback shuffle mode for folder specified. Data high byte is the
folder index
[QUERY_STATUS] 7E FF 06 42 00 00 00 EF Query Device Status
[QUERY_VOLUME] 7E FF 06 43 00 00 00 EF Query Volume level.
[QUERY_EQUALIZER] 7E FF 06 44 00 00 00 EF Query current equalizer
[QUERY_TOT_FILES] 7E FF 06 48 00 00 00 EF Query total files in all folders
[QUERY_PLAYING] 7E FF 06 4C 00 00 00 EF Query which track is playing
[QUERY_FLDR_FILES] 7E FF 06 4E 00 00 00 EF Query total files in folder. Data is the folder index number
QUERY_TOT_FLDR 7E FF 06 4F 00 00 00 EF Query number of folders
[TF Inserted] 7E FF 06 3A 00 00 00 EF SD Card inserted No
[TF Removed] 7E FF 06 3B 00 00 00 EF SD Card Removed No
[File end] 7E FF 06 3D 00 00 01 EF File has ended playing. Data is file number No
[Init Complete] 7E FF 06 3F 00 00 00 EF Chip initialization Complete No
[Err_File] 7E FF 06 40 00 00 00 EF File error – Generally file not found -Data is returned ??? No
[Ack ok] 7E FF 06 41 00 00 00 EF Message Acknowledged OK Yes
[Current Status] 7E FF 06 42 00 00 01 EF Status in low byte 0=stopped, 1=playing 2=paused Yes
[Volume level] 7E FF 06 43 00 00 0F EF Current Volume level ( 0 … 30) Yes
[Equalizer status] 7E FF 06 44 00 00 01 EF Current Equalizer setting 0=Normal 1=Pop 2=Rock 3=Jazz 4=Classic 5=Base Yes
Total Files 7E FF 06 48 00 00 02 EF Total File count – data is number of files Yes
[File Playing] 7E FF 06 4C 00 00 01 EF File number of file currently playing Yes
[Folder Files] 7E FF 06 4E 00 00 06 EF Number of files in the requested folder Yes
[Total folders] 7E FF 06 4F 00 00 03 EF Total number of folders Yes
' 14 MP3 Player Receive
' 15 MP3 player Transmit
Done VAR Bit
Command_Bytes VAR Byte(8)
.
.
.
Command_Bytes(0) = $7E
Command_Bytes(1) = $FF
Command_Bytes(2) = $06
Command_Bytes(3) = $0F
Command_Bytes(4) = $00
Command_Bytes(5) = $02
Command_Bytes(6) = $01
Command_Bytes(7) = $EF
GOSUB Send_Command
GOSUB Get_Response
.
.
.
END
'_____________________________________________________________________
Send_Command:
PAUSE 20
SEROUT 15, 84, [STR Command_Bytes\8]
PAUSE 25
RETURN
'_______________________________________________________________________________
Get_Response:
SERIN 14, 84, 1000, No_Data, [STR Command_Bytes\8]
Done = 1
RETURN
No_Data:
Done = 0
RETURN