likevorti.blogg.se

0X7E FF 06 command 00 00 00 EF
0X7E FF 06 command 00 00 00 EF






Triggering the DFPlayer to play a track is a simple matter of writing 10 bytes to Serial1.

#0X7E FF 06 command 00 00 00 EF code

Turning on a relay on and off is done with one line of code that either sets a specific Photon pin high or low. I use one of them to control my garage door openers as well. I’m guessing “Photon high voltage relay” translates to Particle Relay Shield. I assume that you will need a HV relay for the light as well. You say “speakers” which tells me that you will need to add an amplifier to the mix. The dfPlayer can drive one small speaker in mono mode, or a pair of earbuds in stereo. Will the particle tool for adding the high voltage relay drop right into the code provided for this? And I can only assume that using the same command to initiate two different things will be just fine… THEN I need to insert the code for also controlling a high voltage relay… and I should be able to write a simple piece of the code that uses the same button command, 0x0F, that will close the relay for 10 seconds. I get the MP3 stuff wired up and coded with a command that correlates to where the button is connected. I assume I will need a high voltage relay for this as well… to activate the the light. I had to use a Photon high voltage relay to finish it. The other project I built was a Google Assistant controlled garage door opener. Wiring to the speakers shouldn’t be hard. I want to wire this to an “easy” button that plays a song AND activates a red spinning light for 10 seconds… It is going to be a “SALE” button for the office that gets pushed when someone makes a sale. Ok… I reckon I can handle that… however I want to try and get a little more complex… I will give you context… Speaking of documentation … This document came from the manufacturer, and is the best reference I have found. Volume commands set/get/increase/decrease appear to work fine.Ġx48 returns the number of files on the TFcard … tho the documentation says that command returns the number of files on Udisk. (I believe it references the order in which the tracks were added to the disk.) The track number does not reference the tracks name. The 0x03 command does reference track by a uint16_t track number that spans the MSB and LSB bytes. You must specify both a folder and a track when using 0x0F

0X7E FF 06 command 00 00 00 EF

References tracks within those folders by name (001-255.xxx), where xxx is “mp3” or “wav”. I’ve done a lot of testing with the DFPlayer (FN-M16P) this past week or so, and 0x0F appears to be the best command for playing tracks …Ġx0F plays tracks that are stored in folders Reset the counter and then wait an additional 4 seconds before playing from the beginning again.ĭelay(4000) // Use a long delay to flag that it’s starting over. While(digitalRead(mp3PlayerStatus) = LOW)ĭelay(1000) // Add a little delay between files. Wait for the pin to go high again (MP3 file finished) Give the busy pin some time to go low (MP3 file playing) Serial1.write(buf, idx) // send the command to moduleįor (int i = 0 i < idx i++) // send command as hex string to MCU If (lb >= 0) // if there is a low byte data fieldīuf = (uint8_t)lb // add it to the bufferīuf = idx - 1 // inject command length into bufferįor (int i=1 i > 8) // inject high byte of checksum beforeīuf = chksum & 0xFF // low byte of checksumīuf = 0圎F // place end-of-command byte If (hb >= 0) // if there is a high byte data fieldīuf = (uint8_t)hb // add it to the buffer If (reply) buf = 0x01 // set if reply is needed/wanted Int idx = 3 // position of first command byteīuf = (uint8_t)cmd // inject command byte in buffer Void sendCmd(int cmd, int lb, int hb, bool reply = false)

0X7E FF 06 command 00 00 00 EF

How can the count value be double what it should be, but each MP3 file is played in order? It’s really confusing.Īnyway, could you be a second set of eyes and take a look at it for me? # define MP3_START 1 By the way, if I define MP3_END as 46, all 23 MP3 files play correctly, but that doesn’t make any sense.

0X7E FF 06 command 00 00 00 EF

It doesn’t matter what mp3 files I use or the folder structure, so I’m assuming it’s not the MP3 module and there’s just a bug in my code that I’m not seeing. It seems to work just fine up to “011.mp3”, but then it starts over at “001.mp3” before it get’s the chance to play “012.mp3”. Basically, I have 23 mp3 files on my SD card (001.mp3 through 023.mp3) and I’m looping through each one in order and then starting over.






0X7E FF 06 command 00 00 00 EF