Help with SPE035 MP3 player.

The bear

Senior Member
Hello Everyone,
I'm using a SEP035 MP3 from Rev Ed,.
It plays fine as a stand alone unit.
I've failed to get it working properly, when coupled to a 14M2, using the code from the SPE035 manual.
It just plays music from track one continuously, this is probably how its coded.
My object is to get it to play random tracks continuosly, when switched on.
I have experimented with different command codes.
Searched the forum, not found the answer.
Also will the 14M2 switch it on and off?
http://www.picaxe.com/docs/spe035.pdf
The micro SD card contains 25 tracks from a music CD.
I have experimented with different command codes.(SPE035)
Searched the forum, not found the answer.
As you have gathered, my knowledge is limited.
The SPE035 manual shows a connection to pinC.2 from Busy, but no code.
I don't understand what command $12 does (cmd = $12 : arg = 0025)
Any guidance would be appreciatedhttp://www.picaxe.com/docs/spe035.pdf
Code:
;MP3 from data sheet
#picaxe 14M2
#No_data
#Com 3

Symbol tx  = B.4 
Symbol rx = C.3 
Symbol busy_pin  = pinC.2 
 
Symbol baud_freq = M8 Symbol baud      = T9600_8 
 
Symbol cmd  = b0 
 
Symbol arg = w1 ; b3:b2 Symbol arg.lsb   = b2 Symbol arg.msb   = b3 
Symbol arg.lsb = b2
Symbol arg.msb = b3

Sertxd("From data sheet",Cr,Lf)

High tx ; set TX pin high for idle high serial 
 
Pause 2000 Sertxd("Starting", Cr, Lf ) 
 
Sertxd("Select microSD Card", Cr, Lf ) cmd = $09 : arg = $0002 : Gosub Send Pause 4000 

 Pause 1000
 cmd = 0x06 : arg = 10 : Gosub Send	;Volume?
 Pause 1000
 cmd = 0x08 : arg = 3 : Gosub Send	;Random
Sertxd("Play MP3 folder song 0001.mp3", Cr, Lf ) cmd = $12 : arg = 0025 : Gosub Send Pause 1000 
Do
Pause 5000
Loop
 
Stop 
 
Send:   Setfreq baud_freq 
Pause 10  
Serout tx, baud, ( $7E, $FF, $06, cmd, $00, arg.msb, arg.lsb, $EF ) 
Setfreq Mdefault  
Return
linkhttp://www.picaxe.com/docs/spe035.pdf
 

Technical

Technical Support
Staff member
cmd = 0x08 : arg = 3 : Gosub Send
Repeatedly play the 3rd song.

cmd = $12 : arg = 0025 : Gosub Send
Play song number 25 (ie file called 0025.mp3).

So you have a mixture of play commands - probably not what you were trying to do? Have a look at page 19 of the SPE035 pdf for the various commands.
 

hippy

Technical Support
Staff member
The good news is that if it's playing one track under program control everything is wired up as it should be and it's likely only a matter of program code.

The busy pin from the module is high when a track is playing, low when not. Looping until the busy pin goes low indicates a track being played has ended.

The $12 command is the 'play track command, 'arg' specifies which filename to play.

It is worth looking at the AXE171 code supplied with PE6 (File->Open Samples->BASIC) and particularly the "Play Sequential.bas" example. That should play tracks 0001 through 0009 one after each other.

It would also be worth getting all those examples to work, modifying them to work for tracks you have, to see if they work as expected before moving on to other commands.

I don't have an SPE035 setup to test but the actual problem you have may be with -

cmd = 0x08 : arg = 3 : Gosub Send ;Random

Command $08 with arg=3 will repeatedly play the 3rd track found on the SD card, which isn't necessarily 0003.mp3 or whatever the third entry may appear to be when the SD Card directory is shown in Windows Explorer.

I cannot recall what sending a $12 command with arg=0025 will do while a track is still being played. I would have thought it would stop the current and start playing track 0025. Perhaps that is sent too quickly after the $08 command to be recognised. It is probably best to to put a PAUSE 1000 between each command sent at least to start with.
 

The bear

Senior Member
Thank you Technical & hippy,
It is worth looking at the AXE171 code supplied with PE6 (File->Open Samples->BASIC) and particularly the "Play Sequential.bas" example. That should play tracks 0001 through 0009 one after each other.
It would also be worth getting all those examples to work, modifying them to work for tracks you have, to see if they work as expected before moving on to other commands.
Will Study that, thanks.

Regards, bear..
 

Hans Michlmayr

New Member
You may have to use $03 instead of $12 as the command , this worked for me . Had the same problem , always played the first track only . The major supplier of the DFPlayer module (Flyrontech.com) clearly show this in their module user manual .
 

hippy

Technical Support
Staff member
You may have to use $03 instead of $12 as the command , this worked for me . Had the same problem , always played the first track only . The major supplier of the DFPlayer module (Flyrontech.com) clearly show this in their module user manual .
Do you have a link to that datasheet ?

It is possible that different suppliers are using different modules with different firmware within them. The example code we provide is that which we tested the modules we were selling at the time with and that was found to be working by ourselves.
 

The bear

Senior Member
Thanks hippy,
It looks like "Shuffle/Random" mode, its going to play track one, then go into shuffle/random, I can live with that.

I haven't tried the $03 command yet, as mentioned in post #6. thanks Hans.

Regards, bear..
 

Hans Michlmayr

New Member
You're probably right . Most will place the files directly into the uSD card memory / root directory . In which case it seems you have 0.....2999 files allowed , accessible via the $03 command. This is probably different for using separate directories/folders , then the $12 command will address individual tracks.
regards,
Hans
 

Technical

Technical Support
Staff member
The problem with the $03 command is it plays the files in the filing system FAT order - for instance $03, $0003 will play the third tune that was historically copied onto the card, ignoring the actual filename. This is NOT the same as playing the filename e.g. the '0003.mp3' file with command $12, $0003

This confuses many people when trying to select a particular tune, so we suggest always using the files in a /MP3 subfolder so you can use actual filename command $12 instead of $03, so you are not dependent on the FAT file position (which is quite random, it depends on whichever FAT order the files happened to have been copied onto the SD card). Page 19 of the SPE035 datasheet shows both commands.
 
Last edited:
Top