edit

Grove - MP3 v2.0

Grove - MP3 v2.0 is a tiny-sized and compact audio module. It supports various audio file operations for an audio file of MP3, WAV and WMV format, such as random music playing, play music in specific files, and so on. With serial communication, you can use all predefined command or command combinations to do all operations on music files. This module also supports general file systems such as FAT16 and FAT32. It gets a Grove UART interface, a 3.5 mm audio jack and a micro-SD slot. With this module, you can add some noise to your silent applications.

Version

Product Version Changes Released Date
Grove - MP3 v1.0 Initial April 28 2013
Grove - MP3 v2.0 Change to KT403A Dec 15 2015

Features

  • General operations on audio files
  • On-board micro-SD slot and 3.5 mm audio jack
  • Support sample rate of 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48(KHz)
  • 24-bit DAC output, 90 dB (at Max.) dynamic output range, signal-noise ratio at 85 dB
  • MP3, WMV and WAV audio format and FAT16, FAT32 files system supported
  • Embed 10 levels of equalization in total

Tip

More details about Grove modules please refer to Grove System

Application ideas

  • Middle-level audio module for any applications.

Specifications

Parameter Value
Input 5 V (DC)
Operating current (no signal output state) less than 15 mA
Operating current less than 40 mA
Chip KT403A (datasheet)
Chip LDO output voltage 3.3 V
Chip output current 100mA(at Max.)
File formats supported MP3, WAV, WMA
Maximum memory supported for SD card 8 GB
Sampling rate 8 / 11.025 / 12 / 16 / 22.05 / 24 / 32 / 44.1 / 48(KHz)

Platforms Supported

Arduino Raspberry Pi BeagleBone Wio LinkIt ONE

Caution

The platforms mentioned above as supported is/are an indication of the module's hardware or theoritical compatibility. We only provide software library or code examples for Arduino platform in most cases. It is not possible to provide software library / demo code for all possible MCU platforms. Hence, users have to write their own software library.

Hardware Overview

Getting Started

Note

If this is the first time you work with Arduino, we firmly recommend you to see Getting Started with Arduino before the start.

Play With Arduino

Hardware

  • Step 1. Prepare the below stuffs:
Seeeduino V4.2 Base Shield Grove - MP3 v2.0
enter image description here enter image description here enter image description here
Get One Now Get One Now Get One Now

Note

We need SD card with music inside and Headset/earphone or stereo with 3.5 mm audio jack as well.

  • Step 2. Connect Grove-MP3 v2.0 to port D2 of Grove-Base Shield.
  • Step 3. Plug Grove - Base Shield into Seeeduino.
  • Step 4. Connect Seeeduino to PC via a USB cable.

Note

If we don't have Grove Base Shield, We also can directly connect Grove-MP3 v2.0 to Seeeduino as below.

Seeeduino Grove-MP3 v2.0
5V Red
GND Black
D3 White
D2 Yellow

Software

Here is the code.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
/*
 * MP3_Play_Test.ino
 * A quick start example for Grove-Serial MP3 Player V2.0
 * Note: The MP3 chip of Grove-Serial MP3 Player V2.0 is different from Grove-Serial MP3 Player V1.0
 * Description: This demo let you can send instruction 1-8 to control the Grove-Serial MP3 Player, via the serial port.
 *
 * Copyright (c) 2015 seeed technology inc.
 * Author     : Wuruibin
 * Created Time: Dec 2015
 * Modified Time:
 * 
 * The MIT License (MIT)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 */


#include <SoftwareSerial.h>
#include <MP3Player_KT403A.h>

static uint8_t recv_cmd[8] = {};


// Note: You must define a SoftwareSerial class object that the name must be mp3, 
//       but you can change the pin number according to the actual situation.
SoftwareSerial mp3(2, 3);

void setup()
{
    mp3.begin(9600);
    Serial.begin(9600); 

    while(!Serial);

    Serial.println("Grove - Serial MP3 Demo");
    Serial.println(
        "Input command:\r\n\r\n"
        "P[ ] play music by default index\r\n"
        "Pm[ ] play music in MP3 folder by index\r\n"
        "Pf[ ][ ] play music by specify folder and index\r\n"        
        "p Pause\r\n"
        "R Resume\r\n"
        "N Next\r\n"
        "L Previous\r\n"
        "l Loop\r\n"
        "I Increase volume\r\n"
        "D Decrease volumern\r\n");

    delay(100);

    SelectPlayerDevice(0x02);       // Select SD card as the player device.
    SetVolume(0x0E);                // Set the volume, the range is 0x00 to 0x1E.
}

void loop()
{
    uint8_t len = 0;
    uint8_t i;

    if(Serial.available())
    {
        char chr = '\0';
        while(chr != '\n')  // Blockly read data from serial monitor
        {
            chr = Serial.read();
            // Serial.print(chr);
            recv_cmd[len++] = chr;        
        }
    }

    if(len > 0)
    {
        // Print reveiced data    
        // Serial.print("Received cmd: ");   
        // for(i = 0; i < len; i++) {
        //     Serial.print(recv_cmd[i]);
        //     Serial.print(" ");
        // }
        // Serial.println();

        switch (recv_cmd[0])
        {
            case 'P':
                if(recv_cmd[1] == 'm') 
                {
                    /** 
                      * Play music in "MP3" folder by index 
                      * example:
                      * "Pm1" -> ./MP3/0001.mp3
                    */
                    PlayMP3folder(recv_cmd[2] - '0');
                    Serial.print("Play ");
                    Serial.write(recv_cmd[2]);
                    Serial.println(".mp3 in MP3 folder");
                } 
                else if(recv_cmd[1] == 'f')
                {
                    /** 
                      * Play specify folder and music
                      * example:
                      * "Pf11" -> ./01/001***.mp3
                    */
                    SpecifyfolderPlay(recv_cmd[2] - '0',recv_cmd[3] - '0');
                    Serial.print("Play ");
                    Serial.write(recv_cmd[3]);
                    Serial.print("xxx.mp3");
                    Serial.print(" in folder ");
                    Serial.write(recv_cmd[2]);
                    Serial.println();

                } 
                else
                {
                    /** 
                      * Play music by default index
                      * example:
                      * "P1" -> ./***.mp3
                    */                
                    SpecifyMusicPlay(recv_cmd[1] - '0');
                    Serial.print("Play xxx.MP3 by index ");
                    Serial.write(recv_cmd[1]);
                    Serial.println();
                }            
                // Serial.println("Specify the music index to play");
                break;
            case 'p':
                PlayPause();            
                Serial.println("Pause the MP3 player");
                break;
            case 'R':            
                PlayResume();
                Serial.println("Resume the MP3 player");
                break;
            case 'N':            
                PlayNext();
                Serial.println("Play the next song");
                break;
            case 'L':
                PlayPrevious();
                Serial.println("Play the previous song");
                break;
            case 'l':
                PlayLoop();
                Serial.println("Play loop for all the songs");
                break;
            case 'I':
                IncreaseVolume();
                Serial.println("Increase volume");
                break;
            case 'D':
                DecreaseVolume();
                Serial.println("Decrease volume");
                break;
            default:
                break;
        }

        // clean data buffer
        for(i = 0; i < sizeof(recv_cmd); i++) {
            recv_cmd[i] = '\0';
        }
    }    
    delay(100);

//    printReturnedData();
}
  • Step 4. We will see the info at COM terminal as below.

Note

For advanced programming, you can download datasheet of chip KT403A.

  • Step 5. Please key in the related command to play the music.

Resources

Projects

Arduino Based Security Project Using Cayenne: Arduino based Home Security Project. SMS/email alerts when intruder detected. Personalized messages for authorized personnel.

Leaf Piano: We made a piano using a touch sensor, as well as leaves for piano keys.

Tech Support

Please submit any technical issue into our forum.