About MP3 voice module(GD5800)

Issue #544 open
xixicarry created an issue

Hello, John, I want to ask you a question. I use serial communication (TX, RX) to debug an MP3 voice module. Its chip is GD5800. I use the existing ubl library on the platform, but sometimes I can't control it and occasionally use it. Do you have any experience in this regard?

Comments (32)

  1. John Maloney repo owner

    I have not used that particular MP3 player; the library was contributed by a user.

    However, I've run into various glitches with other MP3 player boards. One common problem occurs when multiple commands are sent quickly without much time between them. If you think that is happening, try waiting 1000 msecs between commands.

    You should always wait a few seconds after initializing the MP3 player, especially if you have a lot of tracks installed. I think when it is initialized, the MP3 chip scans the SD card directory structure looking for possible tracks.

    The best way to debug this is to find a sequence that always fails, then try to figure out what is causing the failure. Is the based on timing? Is there a specific command that fails? Or perhaps these is a certain track that makes it fail, which might be because that track is encoded in a way that the MP3 player cannot handle (e.g. variable bit rate encoding might cause problems).

    You could also try the other MP3 player library, which supports several different MP3 chips, including the GD3300B which may be similar to the GD5800 in your MP3 player. (You'll need to try both "Octopus" and "DFRobot"; that will cover MP3 player protocols with and without checksums.)

    Good luck!

  2. xixicarry reporter

    Thanks for the suggestion, I will experiment with it, does MicroBlocks support custom TX and RX? Is there anything I should be aware of?

  3. xixicarry reporter

    I found a phenomenon, for example, connected to the MP3 voice module RX pin IO19, when the serial communication sent a message, I clicked again (read the number of pins 19) blocks, it will be able to trigger the relevant control, very amazing!

  4. xixicarry reporter

    It is now certain that if the digital pin connected to the RX of the MP3 voice module returns true, the control can be triggered normally, but unfortunately, whenever the RX pin of the MP3 voice module is connected, the pin returns false, and you can only imagine what I have described above.

  5. xixicarry reporter

    Unfortunately it can only be triggered to play a sound, all other commands don't work properly

  6. John Maloney repo owner

    It's possible that none of the MicroBlocks MP3 libraries are sending the right commands for your GD5800 MP3 chip. Check the datasheet to see what commands your chip is expecting (and which ones it supports). Do a google search for "GD5800 mp3 datasheet". I didn't find one in English but it looks like there are some in Chinese.

    If the "play" command works, then I think the command format is correct. There seem to be two different MP3 player command conventions -- one of them includes a checksum and the other one does not. But the actual command numbers -- and which commands are supported -- can differ. I've also found that some commands (e.g. "repeat all in folder") don't work expected on some chips. Usually play, pause, and the volume commands do work.

    In other words, you might need to make a new library for the GD5800 but you can start with code from one of the other MP3 libraries.

  7. xixicarry reporter

    Thanks for the guide, I'll rewrite one, but is it correct to return a boolean value to the TX pin for each trigger?

  8. John Maloney repo owner

    The MP3 chip receives commands on its RX pin and sends responses via its TX pin. If you connect the MP3 player's TX pin to the RX pin of the hardware port of your board and open the serial port at 9600 baud, you can read the multiple byte response messages from the MP3 chip. The datasheet will tell you what responses it sends.

    The OpenSmart MP3 library uses the hardware serial port, but only to send commands. The "MP3 Player" library sends commands using "software serial". That allows the library to send MP3 commands via any GPIO pin, not just the serial port TX pin, which is very flexible.

    MicroBlocks does not support receiving data via software serial. Thus, if you want to read responses from the MP3 chip you must use the hardware serial pins. You can find the hardware serial pins for your board here:

    https://wiki.microblocks.fun/en/boards/pinouts

    However, even without using hardware serial, you can get some information back from the MP3 chip. In particular, you can detect the beginning of a response from the MP3 chip because its TX line, which is normally held "high", will drop to "low" at the beginning of the serial message. That trick can sometimes be used to detect when a track has finished playing, assuming your MP3 chip sends a "done playing" response.

  9. John Maloney repo owner

    Thanks for the link to the datasheet. I can read it with Google translate.

    Nice MP3 module! I like that it does not require a microSD card because it has built-in Flash memory.

    According to the datasheet, it sends a four-byte response to each command. You could try reading those responses. It's possible some commands will send some sort of error response which may help debug the commands that are not working as expected.

  10. xixicarry reporter

    In the case of "software serial". It seems that if I send a byte to any GPIO pin and trigger it, it will make a sound, it has nothing to do with the specified byte command, is this a bug?

  11. John Maloney repo owner

    Not sure what you mean by "trigger it". And what sound do you get? Does the MP3 player play a track or just make a buzz or click noise?

    This sounds more like an electronic issue -- for example, it could be the result of noise on the power supply to the MP3 player.

    What microcontroller are you using? You might try running it on batteries (with no USB connection) and triggering the script with a button. That would isolate it electrically from your computer's power supply. Does that change the behavior?

  12. xixicarry reporter

    The first step triggers the software serial blocks, then clicking again (read digital pin 2) triggers the MP3 player to play the track.

  13. John Maloney repo owner

    Thanks for the video -- that's very helpful.

    However, I'm not sure why it is doing that. Is pin2 also connected to something else on your ESP32 board? On some boards it is connected to the user LED.

    Do you get the same behavior other pins or only on pin 2?

    FYI, reading from pin 2 put it into input mode which means it does not pull the pin either high or low. Thus, if there is something connected to the pin such as an LED or pullup resistor then the pin may be pulled up or down which the MP3 chip would interpret as a data bit.

    It might help to set the state of pin 2 to high (the default level of a serial line) and waiting 10 msecs before sending your command.

  14. xixicarry reporter

    Thanks for the quick reply, the same thing happens with other pins on the board, tried your suggestion and I hear a "di" sound!

  15. John Maloney repo owner

    Could that the be the first sound effect on the card? From the description, it may come with some sound effects pre-loaded. You could connect the card via a USB cable to explore what tracks it has on it.

    You might try the command "7E 02 03 EF". That is supposed to play the next song each time is is run.

  16. xixicarry reporter

    This is not what the sound effects sound like, the problem is not solved yet, I will experiment again

  17. John Maloney repo owner

    I'm sorry the MP3 Player is not yet working.

    Are you connected to the board via Bluetooth BLE? If so, you could try connecting using a USB cable. It is possible that the BLE system is messing up the timing of the sofware serial signal.

    You could also test the MP3 Player with the Arduino example program included in the Makefun documentation. That would verify that the hardware itself is working and that the wiring is correct.

  18. xixicarry reporter

    Hi John, tested on Arduino is normal and usable, doesn't the software serial port building block work for this MP3 module?

  19. John Maloney repo owner

    Thanks for doing that test. That confirms that the MP3 Player hardware is working. I notice that the Arduino code uses pins 5 (RX) and 6 (TX). You should test MicroBlocks using the same TX pin you used for the Arduino test to make sure that the pin doesn't matter.

    doesn't the software serial port building block work for this MP3 module?

    It's possible that the Bluetooth BLE system is messing up the timing of the software serial signal. Try using the command "enable or disable BLE" menu to disable BLE, then power-cycle the board and try again.

    Another thing to try is using the hardware serial TX pin, pin 17 and use "serial open 9600" and "serial write" to open the port and send the command bytes.

  20. xixicarry reporter

    Ok, I will experiment further, I have another question, (shape for letter) is for 5x5 LED screen, if I use 8x8 LED screen then it will still display 5x5 size characters, is there any good way to set up with 8x8 LED screen? Thank you for your guidance!

  21. John Maloney repo owner

    The 5x5 display feature is built into MicroBlocks. It is based on the micro:bit, but emulated an many different boards, including ones with TFT graphic displays. That allows MicroBlocks programs that use the LED Display library to be portable across all those boards.

    What is the interface to your 8x8 display? Is it an RGB NeoPixel display? If so, then you could use the NeoPanel library.

  22. John Maloney repo owner

    Also, the "shapeForLetter" uses an internal 5x5 font that only includes the ASCII character range...

  23. xixicarry reporter

    LED Dot matrix driven by MAX7219, I modified it based on NeoPanel library, but the displayed character size can only be 5X5.

  24. John Maloney repo owner

    Yes. To show 8x8 characters you'd need to create an 8x8 font and figure out how to encode that data into the library (for example, as hex strings). Depending on the number of characters, the resulting library might take a lot of space and be slow to download.

  25. xixicarry reporter

    Hi John, after testing, any defined TX RX pins on Arduino can control the MP3 module normally, on MicroBlocks, I followed your suggestion and stopped using the BLE function, but it still can't be controlled normally, is there a problem with the function of the serial blocks?

  26. John Maloney repo owner

    Sorry you are still having problems with this.

    I've used the software serial with MP3 player a lot on other boards but not on the ESP32 (although others have, I think). I don't have your exact MP3 player but I can try a few MP3 players to see if software serial communications is working on the ESP32. However, I won't have time to do that experiment until early next week.

  27. Log in to comment