CRTC Electronics

Click here to edit subtitle

MP3s on ESP

Play mp3s on an ESP8266

0. install the libraries to the Arduino IDE
1. Code the ESP
2. Put MP3s on the SD card
3. Wire the ESP and Player

Install the Libraries

1. Download the libraries:  https://github.com/DFRobot/DFPlayer-Mini-mp3

2. Install the libraries:

  1. in arduino IDE click Sketch -> Include Library -> Add .ZIP Libraries
  2. in the dialog box find click on the libraries you downloaded

 

1. Code


#include <SoftwareSerial.h>

#include <DFPlayer_Mini_Mp3.h>



SoftwareSerial mp3Serial(5,4);


void setup () {

   Serial.begin (9600);

   mp3_set_serial (mp3Serial); 

   mp3_set_volume (15);

}


void loop () {        

   mp3_play (1);

   delay (16000);

  mp3_next ();

  delay (16000);

  mp3_prev ();

  delay (6000);

  mp3_play (4);

  delay (6000);

}


/*

   mp3_play (); //start play

   mp3_play (5); //play "mp3/0005.mp3"

   mp3_next (); //play next 

   mp3_prev (); //play previous

   mp3_set_volume (uint16_t volume); //0~30

   mp3_set_EQ (); //0~5

   mp3_pause ();

   mp3_stop ();

   void mp3_get_state (); //send get state command

   void mp3_get_volume (); 

   void mp3_get_u_sum (); 

   void mp3_get_tf_sum (); 

   void mp3_get_flash_sum (); 

   void mp3_get_tf_current (); 

   void mp3_get_u_current (); 

   void mp3_get_flash_current (); 

   void mp3_single_loop (boolean state); //set single loop 

   void mp3_DAC (boolean state); 

   void mp3_random_play (); 

 */

2. SD Card's MP3s

The FS format should be either FAT16  or FAT32 (MS DOS filesystems)
Create "mp3" folder in the root of the card and put there several mp3 files with the following names:
[4 digits][anything_else].mp3. e.g.:
0001.mp3
0002_AC_DC_hell_bells.mp3

3. Wiring Diagram 

ESP8266 about ~$3.50

Diymall Mini MP3 Player ~$2.50