Qwiic MP3 Trigger – SparkFun DEV-16892
Sometimes you just need an MP3 to play. Whether it’s a theme song as you enter the room or a power song when you are working out. The SparkFun Qwiic MP3 Trigger takes care of all the necessary requirements, all you need to do is send a simple I2C command and listen to whatever is on your micro SD card. Utilizing our handy Qwiic system, no soldering is required to connect it to the rest of your system. However, we still have broken out 0.1″-spaced pins in case you prefer to use a breadboard.
When a USB-C cable is connected to the Qwiic MP3 Trigger the contents of the microSD card appear as a jump drive. Simply plug in the Qwiic MP3 Trigger and you’ll be transferring MP3s, no need for drivers and no need for WAV or Vorbis conversion! Sound output is provided via a 3.5mm headphone jack or poke-home connector allowing an external speaker to be connected without soldering. Your supplied speaker is boosted by a Class-D mono amplifier capable of outputting up to 1.4W making it capable of being incredibly loud! Volume is software selectable between 32 levels while equalization can be tuned to be sure your classical hits sound different from your jazz dance routines. If you don’t want to deal with any programming, there are four trigger pins. When pin 3 is pulled low the T003.mp3 file will immediately be played. This allows you to start playing sound effects with the touch of a button! By pulling multiple pins down simultaneously the four triggers can play up to ten tracks: T001 to T010.
All settings including volume, EQ, and I2C address are stored in NVM and loaded at each power-up. The I2C address of the Qwiic MP3 Trigger can be modified via a solder jumper or be assigned using a software command. Multiple Qwiic MP3 Triggers can be chained together on a single bus allowing for simultaneous track mixing and triggering.
We’ve written an extensive Arduino library to make MP3 playing over I2C a breeze. Play tracks, change volume, play next/previous, check if the track is playing, stop play, change EQ, and change I2C address are all supported.
Qwiic MP3 Trigger Features:
- Operating voltage: 3.3V
- Current consumption:
- 40mA standby
- 40mA when playing over headphones at any volume level
- 150mA-300mA when driving an external 8Ω speaker at a full volume setting
- microSD supports 128MB to 32GB cards
- Volume, EQ setting, and I2C address settings stored in non-volatile memory and loaded at each power-on
- WT2003S MP3 decoder IC provides USB access to microSD socket (up to 32GB) and MP3 decoding
- ATtiny84 receives I2C commands and controls the MP3 decoder
- The poke-home connector allows for sturdy but temporary speaker connection without soldering
- Trigger pins 1, 2, 3, and 4. When pins 1+4 are pulled low simultaneously T005.mp3 will play
- Up to 255 tracks can be loaded onto the SD card and triggered via the I2C interface
- Built-in TPA2005D1 based 1.4W Class-D mono amplifier
- Address jumper to select between I2C address 0x37 (default) and 0x38. I2C address is also configurable via software to one of 110 different addresses.
- USB-C Connector
- Qwiic Connector
Qwiic MP3 Trigger Schematic:
Getting Started with the Qwiic MP3 Trigger:
MP3 and ATtiny84:
At the heart of the Qwiic MP3 Trigger is the WT2003S MP3 decoder IC. This IC reads MP3s from the microSD card and will automatically mount the SD card as a jump drive if USB is detected. The ATtiny84A receives I2C commands and controls the MP3 decoder.
SD and USB:
The SparkFun Qwiic MP3 Trigger works with 512MB to 32GB cards formatted in FAT32. Up to 255 songs can be loaded onto Qwiic MP3 Trigger.
The easiest way to add and remove MP3s to the Qwiic MP3 Trigger is to attach a USB C cable. This will enumerate the microSD card as a jump drive making it extremely easy to access the files on the card. Alternatively, if you don’t want to use USB, you can eject the microSD card and read/write to it using a normal USB SD adapter.
Qwiic Connectors:
The Qwiic MP3 Trigger from SparkFun includes two Qwiic connectors to make daisy-chaining this music player with a large variety of I2C devices. Checkout Qwiic for your next project.
The I2C pins broken out on the board are tied directly to the Qwiic connectors.
Audio Amplifier:
The speaker is boosted by a Class-D mono amplifier capable of outputting up to 1.4W. What does 1.4W mean? It’s incredibly loud; great for making sure your mech effects are heard on the *con floor (i.e. _Comic_ – con, _Def_ – con, etc.) and wonderful for annoying your officemates. Both outputs have volume controlled by the SET_VOLUME
 command and is selectable between 32 levels. Additionally, there are PTH holes beside both connectors if a soldered connection is preferred.
Audio Outputs:
A standard 3.5mm audio jack is provided making it easy to play your tunes over headphones or amplified desktop speakers or any other amplifier.
A poke-home connector labeled Speaker is also provided in parallel to the 3.5mm jack. This is a friction fit type connector; simply push stranded or solid core wire (22AWG or larger) into the hole and the connector will grip the wire.
To use an external speaker, solder two wires onto the speaker and insert the wires into the poke home connector.
Qwiic MP3Â I/O Pins:
There are several I/O pins broken out on the board, which are described in the table below.
Pin Name | Type | Description |
---|---|---|
RST | Input | Active low. Pull this pin low to reset the ATtiny84A, effectively resetting the Qwiic MP3 Trigger. |
INT | Output | Active low. Goes low when track is finished playing. Goes high again when CLEAR_INTERRUPTS command is issued. |
SCL | Input | Serial clock line of I2C interface. Qwiic MP3 Trigger does implement clock stretching and will hold the clock line low if it is unable to receive additional I2C data. |
SDA | Input/Output | Serial data line of I2C interface. |
3.3V | Power | Qwiic MP3 Trigger can be powered from 2.8V to 3.3V. Anything greater than 3.6V will damage the microSD card. |
GND | Power | The ground pin. |
Trigger 1-4 | Input | When a trigger pin is pulled to ground, the corresponding T00X.mp3 file is played. Pins can be combined to play T001 to T010. Pins are 5V tolerant. |
Qwiic MP3Â Triggers:
There are four trigger pins at the top of the board. When pulled low these pins begin playing whatever file is named T001.mp3
 to T010.mp3
. For example, if you attach a momentary button to Pin 3 and GND, when you press that button the T003.mp3
 file will immediately be played. This allows you to start playing sound effects with the touch of a button without any programming!
- Single Trigger – For a basic triggered setup, load four files named T001.mp3, T002.mp3, T003.mp3, and T004.mp3 on the microSD card. Use a wire or button to connect a trigger pin to ground and the associated track will begin playing. Once you have the setup working, use any momentary button to allow a user to cause an MP3 to start playing.
- Using Multiple Triggers – By pulling multiple pins down simultaneously the four triggers can play up to ten tracks: T001 to T010. When a trigger pin is detected the pin values are added together. For example, pulling pins 2 and 4 low at the same time will play trackÂ
T006.mp3
 as will pulling pins 1, 2, and 3 low at the same time. - Interrupt Pin – The Qwiic MP3 Trigger has an INT pin which is configured as an open-drain pin with an on board 10K Ohm pull-up. The INT pin will go low when a track has stopped playing. Once the CLEAR_INTERRUPTSÂ
0x0D
 command has been received, the INT pin will become high-impedance and will return to a high level. If you have multiple devices with bussed interrupt pins you may want to cut the INT jumper to remove the 10K pull-up resistor.
Qwiic MP3 Trigger Library:
The SparkFun Qwiic MP3 Trigger Arduino library demonstrates how to control all the features of the Qwiic MP3 Trigger. We recommend downloading the SparkFun library through the Arduino library manager by searching ‘SparkFun MP3 Trigger‘. Alternatively you can grab the zip here from here!
Once you have the library installed checkout the various examples.
- Example1:Â Play the first MP3 track on the microSD card.
- Example2:Â Play the next track on the microSD card.
- Example3:Â Play a particular file. For exampleÂ
mp3.playFile(3);
 will play F003.mp3. - Example4: Stop and pause tracks.
- Example5:Â Kitchen sink example showing setting of volume, equalizer, get song name, get song count, get firmware version, etc.
- Example6:Â Change the I2C address of the MP3 Trigger. Allows multiple Triggers to live on the same I2C bus.
- Example7:Â Shows how to start the library using a different Wire port (for example Wire1).
- Example8:Â Demonstrates how to check for the end-of-song interrupt and begin playing the song again.
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.
Notes and tips:
- While USB is connected to a computer, MP3 playing is disabled. However, as long as D+/D- are not connected, you can power the board over USB from a USB wall adapter or power bank and still use the Qwiic MP3 Trigger normally.
- If you are moving just a few MP3 files, the USB C cable will work perfectly fine. However, if you need to move large amounts of data to the SD card, we suggest a normal USB SD adapter. The write speed to the SD card through a USB C cable is slower than a few MBs per second.
- The volume can be adjusted in software using the SET_VOLUMEÂ
0x07
 command (see Command Set section). The volume setting is saved to NVM (non-volatile memory) and loaded at power on.
Jonathan Mill –
I kept losing connection with the host when transferring a large amount of files. Moving smaller batches seems to have fixed this and the board works great.