VS1053 Library issues.

It took me forever and a day to figure out what was not working.

I try to play an mp3 using the adafruit vs1053 library and it works fine if I use

musicPlayer.playFullFile("test.mp3") This stops code execution until the file is done playing.

However If I use musicPlayer.startPlayingFile("test.mp3") the file will not play but code execution does not stop. Go figure.

Here is the confusing part to me... This code snippit from the cpp file.

PlayFullFile works, and it calls startPlayingFile. so why the heck does calling startPlayingFile not work from my sketch. Or any sketch for that matter.

 boolean Adafruit_VS1053_FilePlayer::playFullFile(const char *trackname) {
  if (! startPlayingFile(trackname)) return false;

  while (playingMusic) {
    // twiddle thumbs	   
    delay(5);           // give IRQs a chance
  // music file finished!
  return true;

boolean Adafruit_VS1053_FilePlayer::startPlayingFile(const char *trackname) {
  // reset playback
  sciWrite(VS1053_REG_MODE, VS1053_MODE_SM_LINE1 | VS1053_MODE_SM_SDINEW);
  // resync
  sciWrite(VS1053_REG_WRAMADDR, 0x1e29);
  sciWrite(VS1053_REG_WRAM, 0);

  currentTrack = SD.open(trackname);
  if (!currentTrack) {
    return false;

  // don't let the IRQ get triggered by accident here

  // As explained in datasheet, set twice 0 in REG_DECODETIME to set time back to 0
  sciWrite(VS1053_REG_DECODETIME, 0x00);
  sciWrite(VS1053_REG_DECODETIME, 0x00);

  playingMusic = true;

  // wait till its ready for data
  while (! readyForData() ) {
#if defined(ESP8266)

  // fill it up!
  while (playingMusic && readyForData()) {
  // ok going forward, we can use the IRQ

  return true;

I checked my dreq and even rewired it to a different pin but nothing seems to work. I am not sure what I am missing here. Can someone point me in the right direction.

The libraries have been modified to support SdFat. That part appears to be working fine.

I am using a Mega with a seeed music sheild v 1.3.

I got this to work using a timer instead of an interrupt. A Little help please

Pin 18 on a mega is a hardware interrupt. Why didn't it work.

#define BREAKOUT_CS 16 // VS1053 chip select pin (output)
#define BREAKOUT_DCS 17 // VS1053 Data/command select pin (output)
#define DREQ 18 // VS1053 Data request, ideally an Interrupt pin
#define BREAKOUT_RESET 19 // VS1053 reset pin (output)
#define CARDCS 10 // Card chip select pin
#define VS1053_FILEPLAYER_PIN_INT 18 // Added 10-31-2017 QK.
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt

This works

  if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT))

this does not

if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT)) // DREQ int

I would prefer to use a hardware interrupt.

This is odd because this symbol is defined in Adafruit_VS1053.h so this redefinition should generate a compiler error. The interrupt pin number is defined by DREQ in the original library.

#define VS1053_FILEPLAYER_PIN_INT 18 // Added 10-31-2017 QK.

If you are using a modified fork of the Adafruit library, revert to the original version. I suggest posting your sketch code to get more help.

Try adding Serial.print messages in the library to verify the code is doing what you expect. The useInterrupt function has commented out a Serial.print message which will tell you whether the interrupt function has been attached. Uncomment it and see if the message appears or not. If not, it has something to do with VS1053_FILEPLAYER_PIN_INT.

The function feeder is the interrupt service routine so to determine whether it is being called or not, add some digitalWrites to toggle a GPIO pin. Hook up an LED and see if it blinks or not. If it does not, the interrupt attach failed.

Your comment on the adafruit library having it defined was the answer. in the Adafruit_VS1053.h the pin was defined as


I changed it to #define VS1053_FILEPLAYER_PIN_INT 18 and it works on the hardware interrupt now.


Now If i can just get it to work on DUE.

Trying to get this working on due. After much deliberation ( AKA Cursing and frustration) I figured out where it is crashing but why is beyond me. I think it has something to do with SPI.

Here is the part of the library that it crashes at. This line "Serial.println("DEBUG: SD Card Disabled Starting SPI for VS1053 ");" Shows up on the serial monitor like this

">>> Intializing VS1053 MP3 Player chip (NOTE: This is in my sketch to call the VS1053 Begin)
DEBUG: SD Card Disabled Starting SPI for"

If I add the delay sometimes it will get a little further but not much. The SPI for the VS 1053 never gets activated. If it gets that far in the code it just hangs and will not go any further.

boolean VS1053_FilePlayer::begin(void) {
  // Set the card to be disabled while we get the VS1053 up
  pinMode(_cardCS, OUTPUT);
  digitalWrite(_cardCS, HIGH);  
  Serial.println("DEBUG: SD Card Disabled Starting SPI for VS1053 ");
  uint8_t v  = VS1053::begin(); 
  return (v == 4);

uint8_t VS1053::begin(void) {
  //Serial.println("DEBUG: VS1053 Configuring SPI ");
  if (_reset >= 0) {
	Serial.println("DEBUG ---------- Reset >=0 ");
    pinMode(_reset, OUTPUT);
    digitalWrite(_reset, LOW);

  pinMode(_cs, OUTPUT);
  digitalWrite(_cs, HIGH);
  pinMode(_dcs, OUTPUT);
  digitalWrite(_dcs, HIGH);
  pinMode(_dreq, INPUT);

  if (! useHardwareSPI) {
	  Serial.println("DEBUG ---------- Not using Hardware SPI");
    pinMode(_mosi, OUTPUT);
    pinMode(_clk, OUTPUT);
    pinMode(_miso, INPUT);
	Serial.println("DEBUG ---------- Non Hardware -cs SPI Started");
  } else {
	Serial.println("DEBUG ---------- SPI Started");
	Serial.println("DEBUG ---------- SPI Mode set to MODE0");
	Serial.println("DEBUG ---------- SPI Bit Order MSB");
    Serial.println("DEBUG ---------- SPI CLock Divider set to 128");	
  Serial.println((sciRead(VS1053_REG_STATUS) >> 4));

  return (sciRead(VS1053_REG_STATUS) >> 4) & 0x0F;

My Configuration is pin 10 for the SD Card CS and Pin 52 for the VS1053 CS. Mosi, Miso, and SCLK are on the 6pin header. (Sorry I forgot the name of it.)

This works fine on mega. but will not work on due.

I think this may have something to do with the reset in this code. I pulled my Serial prints out and added them back one line at a time. I found that when it gets to the reset it is locking up.

void VS1053::reset() {
  // TODO: http://www.vlsi.fi/player_vs1011_1002_1003/modularplayer/vs10xx_8c.html#a3
  // hardware reset
  if (_reset >= 0) {
    digitalWrite(_reset, LOW);
    digitalWrite(_reset, HIGH);
  digitalWrite(_cs, HIGH);
  digitalWrite(_dcs, HIGH);

  sciWrite(VS1053_REG_CLOCKF, 0x6000);

  setVolume(40, 40);

There is a bug fix involving _cardcs. Try running the latest version of the library from github.com.

This is version 1.0.4 it is the newest version i found.

is there a newer one that I am not finding?

1.0.4 includes all the fixes. I had to git pull to update my local copy.

I can only guess _reset, _cs, or _dcs are not set to the correct pins. Maybe Serial.print the values of _reset, _cs, _dcs inside the reset function to make sure. Or is it possible there is other hardware connected to the same pins?

That looks OK

>>> Intializing VS1053 MP3 Player chip
DEBUG: Card CS 10
DEBUG: SD Card Disabled Starting MP3 Chip 
DEBUG: Reset 19
DEBUG: mosi 109
DEBUG: miso 108
DEBUG: clk 110
DEBUG: Not Using Hardware SPI
DEBUG: Getting ready for reset 
D  "And I think i just might crash right here..."

I ordered a different mp3 shield to see if I can get it to work. My first issue was not getting it to read the SD Card with SD Fat. I found 3 resistors in series with the miso, mosi, and clock lines that were causing that issue. Now it reads the SD but will not communicate with the VS1053B.

I am guessing the resistors are included because the board was intended for use with 5V AVR but the vs1053 used 3.3V logic. Since Due uses 3.3V logic the resistors are not needed and must be removed. Is it possible the other pins such as _reset, _cs, _dcs have the same problem?

The Adafruit VS1053 feather wing board is designed for 3.3V operation. I used it with an ESP8266 board (3.3V logic) with no problems.

Finally got it.

2 Issues

The resistors and an unsoldered pin on the vs1053 chip. Quality control issue there. The pin was just sitting on the solder on the reset line.

I reflowed the entire chip and replaced the 1.8K resistors with 1 Ohm resistors. Now I just can't forget to keep it away from the Mega board or I may get some smoke.

So with the seeed studio music player v 1.2 replace R3, R31, R32, R33, R24, R29 and R26 with 1 ohm resistor to get it working on a Arduino Due. ( At Your Own risk )

I have it working with A Fat 32 16gig SD Card Also.

Now to integrate it into the Gauges and clock.

Thank You for the help. I will keep you updated on my progress.

I can't get the FM Radio to work on DUE. The SI4703 chip will not initialize. It appears to lock up the DUE. The SI4703 work great on mega but not on DUE. It is a i2c interface with a pin for reset. I think the issue is in the wire library. Or at least that is the way it looks to me.

I am using this library I commented out A4 and A5 also tried changing them to 20 and 21. No Luck. I also tried with it hooked up to A4 and A5.

I am unfamiliar with i2c that does not have address. Unless I am misunderstanding what I am reading it uses pin 2 to initialize the device and start communication on the bus. There is not and address involved. I did find a document that said it had an address of 0x11 So I tried it with a i2c scanner sketch and it comes back as no devices found.