Qwiic MP3 Trigger Hookup Guide

Pages
Contributors: Nate
Favorited Favorite 3

Command Set

The SparkFun Qwiic MP3 Trigger library takes care of all these commands for you. However, if you want to implement your own interface, the following commands are available (see list below). The Qwiic MP3 Trigger uses standard I2C communication to receive commands and send responses. By default, the unshifted I2C address of the Qwiic MP3 Trigger is 0x37. The write byte is 0x6E and the read byte is 0x6F.

Here is an example I2C transaction showing how to set the volume level to 10:

Logic trace showing 0x6E 0x07 0x0A

Here is an example I2C transaction showing how to read the device ID (0x39):

Logic trace showing 0x6E 0x10 0x6F 0x39

The following commands are available:

  • STOP 0x00 - Stops any currently playing track
  • PLAY_TRACK 0x01 [TRACKNUMBER] - Play a given track number. For example 0x01 0x0A will play the 10th MP3 file in the root directory.
  • PLAY_FILENUMBER 0x02 [FILENUMBER] - Play a file # from the root directory. For example 0x02 0x03 will play F003.mp3.
  • PAUSE 0x03 - Pause if playing, or starting playing if paused
  • PLAY_NEXT 0x04 - Play the next file (next track) located in the root directory
  • PLAY_PREVIOUS 0x05 - Play the previous file (previous track) located in the root directory
  • SET_EQ 0x06 [EQ_SETTING] - Set the equalization level to one of 6 settings: 0 = Normal, 1 = Pop, 2 = Rock, 3 = Jazz, 4 = Classical, 5 = Bass. Setting is stored to NVM and is loaded at each power-on.
  • SET_VOLUME 0x07 [VOLUME_LEVEL] - Set volume level to one of 32 settings: 0 = Off, 31 = Max volume. Setting is stored to NVM and is loaded at each power-on.
  • GET_SONG_COUNT 0x08 - Returns one byte representing the number of MP3s found on the microSD card. 255 max. Note: Song count is established at power-on. After loading files on the SD card via USB be sure to power-cycle the board to update this value.
  • GET_SONG_NAME 0x09 - Returns the first 8 characters of the file currently being played. Once the command is issued the MP3 Trigger must be given 50ms to acquire the song name before it can be queried with an I2C read.
  • GET_PLAY_STATUS 0x0A - Returns a byte indicating MP3 player status. 0 = OK, 1 = Fail, 2 = No such file, 5 = SD Error.
  • GET_CARD_STATUS 0x0B - Returns a byte indicating card status. 0 = OK, 5 = SD Error. Once the command is issued the MP3 Trigger must be given 50ms to acquire the card status before it can be queried with an I2C read.
  • GET_VERSION 0x0C - Returns two bytes indicating Major and Minor firmware version.
  • CLEAR_INTERRUPTS 0x0D - Clears the interrupt bit.
  • GET_VOLUME 0x0E - Returns byte that represents the volume level.
  • GET_EQ 0x0F - Returns byte that represents the EQ setting.
  • GET_ID 0x10 - Returns 0x39. Useful for testing if a device at a given I2C address is indeed an MP3 Trigger.
  • SET_ADDRESS 0xC7 [NEW_ADDRESS] - Sets the I2C address of Qwiic MP3 Trigger. For example 0x6E 0xC7 0x21 will change the MP3 Trigger at I2C address 0x37 to address 0x21. In this example 0x6E is device address 0x37 with write bit set to 1. Valid addresses are 0x08 to 0x77 inclusive. Setting is stored to NVM and is loaded at each power-on.

Command Que

The ATtiny84A receives commands over I2C. It then records the I2C commands into a command que. The que is sent FIFO over serial to the WT2003S at 9600bps. The WT2003S then requires an undetermined amount of time to respond. This means that commands are not instantaneously executed by the Qwiic MP3 Trigger and some commands may require a certain amount of time to before the Qwiic MP3 Trigger has loaded a valid response.

I2C traces showing how to read a song name

An Example GET_SONG_NAME. Do you know the answer?

For example, GET_SONG_NAME can be issued by the master microcontroller to the Qwiic MP3 Trigger. The QMP3 then transmits a serial command to the WT2003S. After a certain amount of time (unfortunately there are no max times defined by the WT2003S datasheet) the WT2003S will respond via serial. This can take 15 to 40ms. At that time, the song name will be loaded onto the Qwiic MP3 Trigger and can be read over I2C by the master microcontroller.

In order to avoid clock stretching by the Qwiic MP3 Trigger and tying up the I2C bus, the Qwiic MP3 Trigger will release the bus after every command is received. Therefore, it is up to the user to wait the minimum 50ms between the WRITE GET_SONG_NAME and the READ I2C commands.

Power Up Time

The MP3 decoder IC on the Qwiic MP3 Trigger is the WT2003S. It requires approximately 1500ms after power on to mount the SD card. Normally, the Qwiic MP3 Trigger is powered while the user writes and re-writes sketches so the user does not notice this boot time. The boot time only comes into effect when user initially powers their project. The main controller (such as an Uno) needs to wait up to 2 seconds before giving up communicating with the Qwiic MP3 Trigger. The SparkFun Qwiic MP3 Trigger library takes care of the 2 second wait but if you’re writing your own implementation then consider the following example code:

language:c
if (isConnected() == false)
{
    delay(2000); //Device may take up to 1500ms to mount the SD card

    //Try again
    if (isConnected() == false)
        return (false); //No device detected
}
return (true); //We're all setup!

Maximum Song Count

Up to 255 songs can be loaded onto Qwiic MP3 Trigger and triggered through the command interface.