Skip to main content

Grove - MP3 v3.0

The Grove - MP3 is a 20x40mm super mini Music module based on WT2003S-20SS audio decoder. It supports high-quality MP3 format audio files with a sampling rate of 8~48KHz and a bit rate of 8~320Kbps. In order to expand the storage capacity, we added a TF card slot on the back of the module. TF card adopts DIO interface mode, supports up to 32GB, supports FAT16, FAT32 file system. Now with this little music module, you can carry hundreds and thousands of music in your pocket.

As the name indicates, the Grove - MP3 V3 is the upgraded version of Grove - MP3 V2. Compared with Grove MP3 V2, the V3 added a JST2.0 speaker port, so that you can output the audio via speaker and 3.5mm earphone at the same time.

Feature

  • Supports MP3 format audio files
  • Sampling rate: 8~48KHz / bit rate: 8~320Kbps
  • Support up to 32GB TF card
  • Support speaker and earphone output audio at the same time
  • Compatible with 3.3V and 5V platform.
  • Support 32-level volume adjustment

Specification

ParameterValue
Supply voltage3.3V / 5V
Sampling rate8~48KHz / bit rate: 8~320Kbps
InterfaceI2C(Default I2C Address: 0x36) & Non-Changeable
OutputSpeaker/3.5mm Audio Jack
ResolutionSupport 32-level volume adjustment

Hardware Overview

Platforms Supported

ArduinoRaspberry Pi

Getting Started

Play With Arduino

Materials required

Seeeduino V4.2Base ShieldGrove - MP3 V3 -Music Player
enter image description hereenter image description hereenter image description here
Get ONE NowGet ONE NowGet ONE Now

In addition, you can consider our new Seeeduino Lotus M0+, which is equivalent to the combination of Seeeduino V4.2 and Baseshield.

Hardware Connection

  • Step 1. Connect the Grove - MP3 V3 Music Player to the D2 port of the Base Shield.

  • Step 2. Plug Grove - Base Shield into Seeeduino.

  • Step 3 Connect the Seeeduino to PC via a USB cable.

Software

tip
    If this is the first time you work with Arduino, we strongly recommend you to see [Getting Started with Arduino](https://wiki.seeedstudio.com/Getting_Started_with_Arduino/) before the start.
  • Step 1. Copy your .mp3 music file to the tf card and save them in the root location in the tf card.

  • Step 2. Download the Seeed_Serial_MP3 Library from Github.

note
    Refer How to install library to [install library](https://wiki.seeedstudio.com/How_to_install_Arduino_Library/) for Arduino.
  • Step 3. Restart the Arduino IDE. Open WT2003S_Terminal_Player example via the path: FileExamplesSeeed_Serial_MP3_PlayerWT2003S_Terminal_Player. You can play .mp3 format music file using this moudle, and use 3.5mm Audio Jack, Speaker via JST2.0 speaker port or even output both in the same time.

The WT2003S_Terminal_Player Example code is as follow:

#include "WT2003S_Player.h"

#ifdef __AVR__
#include <SoftwareSerial.h>
SoftwareSerial SSerial(2, 3); // RX, TX
#define COMSerial SSerial
#define ShowSerial Serial

WT2003S<SoftwareSerial> Mp3Player;
#endif

#ifdef ARDUINO_SAMD_VARIANT_COMPLIANCE
#define COMSerial Serial1
#define ShowSerial SerialUSB

WT2003S<Uart> Mp3Player;
#endif

#ifdef ARDUINO_ARCH_STM32F4
#define COMSerial Serial
#define ShowSerial SerialUSB

WT2003S<HardwareSerial> Mp3Player;
#endif


uint8_t vol = 10;
uint32_t spi_flash_songs = 0;
uint32_t sd_songs = 0;
STROAGE workdisk = SD;
struct Play_history {
uint8_t disk;
uint16_t index;
char name[8];
}* SPISong, *SDSong;

void readSongName(struct Play_history* ph, uint32_t num, STROAGE disk) {
Mp3Player.volume(0);
delay(100);
switch (disk) {
case SPIFLASH:
Mp3Player.playSPIFlashSong(0x0001);
break;
case SD:
Mp3Player.playSDRootSong(0x0001);
break;
case UDISK:
Mp3Player.playUDiskRootSong(0x0001);
break;
}
ShowSerial.println("2...");
for (int i = 0; i < num ; i++) {
delay(300);
ph[i].disk = disk;
ph[i].index = Mp3Player.getTracks();
Mp3Player.getSongName(ph[i].name);
Mp3Player.next();
}
ShowSerial.println("4...");
Mp3Player.pause_or_play();
Mp3Player.volume(14);
delay(100);
}

void getAllSong() {
uint8_t diskstatus = Mp3Player.getDiskStatus();
ShowSerial.println(diskstatus);
spi_flash_songs = Mp3Player.getSPIFlashMp3FileNumber();
ShowSerial.print("SPIFlash:");
ShowSerial.println(spi_flash_songs);
if (spi_flash_songs > 0) {
SPISong = (struct Play_history*)malloc((spi_flash_songs + 1) * sizeof(struct Play_history));
readSongName(SPISong, spi_flash_songs, SPIFLASH);
}
if (diskstatus && 0x02) { // have SD
sd_songs = Mp3Player.getSDMp3FileNumber();
ShowSerial.print("SD:");
ShowSerial.println(sd_songs);
if (sd_songs > 0) {
SDSong = (struct Play_history*)malloc((sd_songs + 1) * sizeof(struct Play_history));
ShowSerial.println("1...");
readSongName(SDSong, sd_songs, SD);
}
}
}
void printSongs() {
ShowSerial.print("-------------------");
ShowSerial.print("index");
ShowSerial.print("<-------->");
ShowSerial.print("name");
ShowSerial.print("-------------------");
ShowSerial.println();
ShowSerial.println("-------------------spi flash-------------------------------");
for (int i = 0 ; i < spi_flash_songs; i++) {
ShowSerial.print("-------------------");
ShowSerial.print(SPISong[i].index);
ShowSerial.print("<-------->");
ShowSerial.print(SPISong[i].name);
ShowSerial.print("-------------------");
ShowSerial.println();
}
ShowSerial.println("-------------------sd card-------------------------------");
for (int i = 0 ; i < sd_songs; i++) {
ShowSerial.print("-------------------");
ShowSerial.print(SDSong[i].index);
ShowSerial.print("<-------->");
ShowSerial.print(SDSong[i].name);
ShowSerial.print("-------------------");
ShowSerial.println();
}
}

void setup() {
while (!ShowSerial);
ShowSerial.begin(9600);
COMSerial.begin(9600);
ShowSerial.println("+++++++++++++++++++++++++++++++++++++++++++++++++++++");
Mp3Player.init(COMSerial);

ShowSerial.println("0...");
getAllSong();
printMenu();
printSongs();
}

void loop() {
if (ShowSerial.available()) {
char cmd = ShowSerial.read();
switch (cmd) {
case '+': {
ShowSerial.print("Volume up: ");
vol = Mp3Player.getVolume();
Mp3Player.volume(++vol);
ShowSerial.print(vol);
ShowSerial.println();
break;
}
case '-': {
ShowSerial.print("Volume down: ");
vol = Mp3Player.getVolume();
if (--vol > 31) {
vol = 0;
}
Mp3Player.volume(vol);
ShowSerial.print(vol);
ShowSerial.println();
break;
}
case 't': {
uint8_t status;
ShowSerial.print("status:");
status = Mp3Player.getStatus();
if (status == 0x01) {
ShowSerial.print("playing");
}
if (status == 0x02) {
ShowSerial.print("stop");
}
if (status == 0x03) {
ShowSerial.print("pause");
}
ShowSerial.println();
break;
}
case 'n': {
Mp3Player.next();
break;
}
case 'p': {
Mp3Player.pause_or_play();
break;
}
case 'w': {
Mp3Player.playMode(SINGLE_SHOT);
break;
}
case 'x': {
Mp3Player.playMode(SINGLE_CYCLE);
break;
}
case 'y': {
Mp3Player.playMode(CYCLE);
break;
}
case 'z': {
Mp3Player.playMode(RANDOM);
break;
}
case 'c': {
ShowSerial.print(Mp3Player.copySDtoSPIFlash());
break;
}
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
ShowSerial.print("play:");
if (workdisk == SD) {
Mp3Player.playSDRootSong(cmd - '0' - 1);
ShowSerial.print(cmd + ": ");
ShowSerial.print(SDSong[cmd - '0'].name);
}
if (workdisk == SPIFLASH) {
Mp3Player.playSPIFlashSong(cmd - '0' - 1);
ShowSerial.print(cmd + ": ");
ShowSerial.print(SPISong[cmd - '0'].name);
}
ShowSerial.println();
break;
default:
break;
}
}
}

void printMenu(void) {
ShowSerial.println("MP3 Command List:");
ShowSerial.println("-----------------");
ShowSerial.println("'+' or '-' : raise/lower volume");
ShowSerial.println("'1' ~ '9' : select a song");
ShowSerial.println("'n' : next song");
ShowSerial.println("'s' : switch play disk, spi flash");
ShowSerial.println("'p' : play or pause");
ShowSerial.println("'w' : set playmode single no loop");
ShowSerial.println("'x' : set playmode single loop");
ShowSerial.println("'y' : set playmode all loop");
ShowSerial.println("'z' : set playmode random");
ShowSerial.println("'c' : Copy mp3 to SPIFlash");
ShowSerial.println(" (Yes, this really does go by copy order.)");
ShowSerial.println();
ShowSerial.println("Any other key to show this menu");
ShowSerial.println();
}
  • Step 3. Upload the demo. If you do not know how to upload the code, please check How to upload code.

  • Step 4. Open the Serial Monitor of Arduino IDE by click Tool-> Serial Monitor. Or tap the ++ctrl+shift+m++ key at the same time. Set the baud rate to 9600.

  • Step 5. The result should look like below. Follow the command list to play music or use other useful features.

FAQ

Q1# TF card cannot be recognized.

A1: Check the file system of the TF card, make sure it is FAT16 or FAT32 file system.

Resources

Tech Support

if you have any technical issue. submit the issue into our forum.


Loading Comments...