by Martin Scott Nicklous | Github Project Page
Released under the MIT License
Overview
This library allows you to control a DY-SV17F MP3 module in UART mode using only the module Rx and busy lines.The library is implemented as a C++ class, which is constructed by passing in an initialized stream and the pin number of the busy line on your processor. The example provided shows how this can be done.
The library does not attempt to cover all functionality of the module, but rather provides a basic function to play MP3 files within subdirectories. In particular, it does not cover the module query commands.
See API Documentation
Concepts
Notes on the Hardware
For wiring questions and questions about the module command set, refer to the DY-SV17F documentation.
My personal notes (your experience may vary):
- Note that logic levels on the module are 3.3V even when it's powered by a 5V suppy. Happiness is greater when you DO NOT pull the Rx, Tx, and Busy pins to +5V. If you are driving the module with an Arduino platform such as the Nano that uses 5V logic, use a voltage divider when connecting the arduino output pins to the mp3 module Rx pin. A voltage divider with 1kΩ resistor to the 5V signal and a 2kΩ resistor to ground seems to work OK.
- The module really likes to have 10K pull-down resistors on CON1 and CON2, and a 10K pull-up resistor from CON3 to the +3.3V pin (NOT the +5V pin!) of the module.
- It seems to be good to use a 1K resistor between your Arduino Tx pin and the module Rx pin, as well as between the Arduino GPIO pin you are using to monitor the busy signal and the module busy/CON3 pin.
Once again, please note that these are just my empirical notes, for what it's worth.
Using the Example
- The library allows you to play a file on the MP3 module specified by a string and determine whether the file is playing.
- For my purposes, I defined a naming convention for directories and files. Each directory has a two-digit name like "\03\", and each file has a three-digit name with the file extension like "001.mp3".
In order for the example to work, you need to add one or more mp3 files to your mp3 module. The format shown must be adhered to exactly,
with a 2 digit directory name "\04", a 3-digit file name "001", and the extension ".mp3". This is a limitation of the example, and not of the module itself.
\04\001.mp3
\04\002.mp3
\04\003.mp3
etc.
Note: When you send strings to the module, you need to include an asterisk "*" after the directory specification and instead of the dot before the extension, like this: "/04*/002*MP3". This is a module limitation as far as I can tell.
- The update() function is a debug aid that monitors the busy line and outputs busy state changes to your serial monitor. It's meant to be called at the top of the loop() function. You generally do not need it for regular operation.
- The isBusy() function returns the current state of the busy line. If the function returns 'true', you can assume that the mp3 previously requested is being played.
- The playStringWait() function will send the requested file specification to the module and wait up to 250mS for the track to start playing. If playing successfully starts, the function returns 'true'. My experience has been that the module takes between 90 and 130 milliseconds before the busy signal becomes active.
- The playString() function will send the requested file specification to the module and return without waiting. This allows you to continue doing other things in your loop. If it's important for your application, you can use isBusy() to check for success at a later time.