Shop OBEX P1 Docs P2 Docs Learn Events
DFPlayer Mini MP3 with BS2. — Parallax Forums

DFPlayer Mini MP3 with BS2.

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.

Comments

  • Welcome to the forums! Could you provide a link to the DFPlayer, as it not a Parallax product that we are familiar with.
  • Here is the link for DFPlayer Mini MP3.

    http://www.picaxe.com/docs/spe033.pdf
  • RaymanRayman Posts: 13,805
    Looks like you need a resistor on the serial link...
  • ercoerco Posts: 20,244
    I haven't used this specific MP3 player module, but I have used the YX5300, which is likely similar. I wrote about it here and included some info about using it with several processors, including our beloved BS2. The first time you use these can be confusing. You must remember that the MP3 module has its own onboard processor and may be off doing its own thing and apparently not responding to your commands. When in doubt, restart the MP3 module (cycle the power) and give it a second or two to initialize. Also, add a brief pause between serial commands to let the module catch up. Once you get all the timing and commands working, keep a copy of that program handy and use it as a template for future projects.
  • ercoerco Posts: 20,244
    You can find some BS2 demo code for that Catalex YX5300 in the description of my video at
  • Rayman wrote: »
    Looks like you need a resistor on the serial link...

    Thank you. I have a resistor on the serial link. Still have a communication problem. Still looking for a solution.
  • erco wrote: »
    I haven't used this specific MP3 player module, but I have used the YX5300, which is likely similar. I wrote about it here and included some info about using it with several processors, including our beloved BS2. The first time you use these can be confusing. You must remember that the MP3 module has its own onboard processor and may be off doing its own thing and apparently not responding to your commands. When in doubt, restart the MP3 module (cycle the power) and give it a second or two to initialize. Also, add a brief pause between serial commands to let the module catch up. Once you get all the timing and commands working, keep a copy of that program handy and use it as a template for future projects.

    Thank you. I will try with the restart MP3 thing. My software did not include this step.
  • ercoerco Posts: 20,244
    edited 2019-09-23 00:13
    @Michelt35: You probably know this already since the link you provided is from Picaxe. There are several troubleshooting threads in that forum, such as https://picaxeforum.co.uk/threads/dfplayer-mini.30364/ and one moderator comment points to their product page at http://www.picaxe.com/Hardware/Add-on-Modules/Budget-Serial-MP3-Player-Kit with two datasheets there. Worth reviewing both IMO.

    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.
    600 x 375 - 28K
  • Michelt35,

    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?
  • MarkCrCoMarkCrCo Posts: 89
    edited 2019-10-11 01:49
    Here is a list of all the command codes for the YX5300 that I could find the forth byte is the command and the sixth and seventh bytes are any data needed by the command:
    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
  • Response Name Response String (HEX) Response Description Query required
    [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
  • Code snipet that might be helpful. The code only looks for a response for 1 second. if you do a lot before checking for a response again you may miss the response.

    ' 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
Sign In or Register to comment.