I trimmed everything out but the MP3 and RTC. Still failing here is the code.
// TIME
#include <DS3231.h> // I2C RTC
DS3231 rtc(SDA, SCL); // Init the DS3231 using the hardware interface
// SD
#include <avr/pgmspace.h>
#include <SPI.h>
#include <SdFat.h> // SD library with long filenames
#define CARDCS 8 // SD Card chip select pin
SdFat SD;
boolean hasSD=false;
// MP3
#include <VS1053SdFat.h>
// Pins for MP3
#define VS1053_CS 9 // VS1053 chip select pin.
#define VS1053_DCS 11 // VS1053 DCS pin.
#define VS1053_DREQ 12 // VS1053 DREQ pin.
#define VS1053_RESET 13 // VS1053 RESET pin.
VS1053_FilePlayer musicPlayer = VS1053_FilePlayer(VS1053_RESET, VS1053_CS, VS1053_DCS, VS1053_DREQ, CARDCS);
void setup() {
Serial.begin(9600);
rtc.begin(); // Initialize the rtc object.
initSD();
initMusicPlayer(); //MP3 Player
playMP3();
}
void loop() {
// Send Day-of-Week
Serial.print(rtc.getDOWStr());
Serial.print(" ");
// Send date
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
// Send time
Serial.println(rtc.getTimeStr());
// Wait one second before repeating :)
delay (1000);
}
void playMP3(){
if (musicPlayer.paused()) musicPlayer.pausePlaying(false); // Start the music player back up it it is paused.
if (! musicPlayer.startPlayingFile("test.mp3")) { // Play the track.
Serial.print("Could not open test.mp3 ");
delay(1000);
}
else{
Serial.println(F("Started playing test.mp3"));
}
}
void initMusicPlayer(){
Serial.println(F(">>> Intializing VS1053 MP3 Player chip"));
if (! musicPlayer.begin()) { // initialise the music player
Serial.println(F(">>> Could not Find VS1053, Do you have the correct pins defined"));
while (1); //This stops the code until the mp3 initializes.
}
//if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT)) // Timer Interrupt
if (! musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT)) // Hardware DREQ Interrupt
delay(100); // Give VS1053 some time to initialize.
Serial.println(F(">>> MP3 OK"));
musicPlayer.setVolume(0,0); // Set volume for left, right channels. lower numbers == louder volume!
}
void initSD(){
if (!SD.begin(CARDCS)) {
Serial.println(F(">>> SD Not Found!")); //SD failed, or not present
hasSD=false; // don't do anything more
}
else {
hasSD=true;
Serial.println(F(">>> SD OK"));
}
}
and here is the serial monitor output. I trimmed the most of the good reads out.
>>> SD OK
>>> Intializing VS1053 MP3 Player chip
DEBUG: Card CS 8
DEBUG: Reset 13
DEBUG: MP3_CS 9
DEBUG: MP3_DCS 11
DEBUG: MP3_DREQ 12
DEBUG: MP3_MOSI 0
DEBUG: MP3_MISO 0
DEBUG: MP3_CLK 0
DEBUG: Using Hardware SPI
DEBUG: Getting ready for reset
DEBUG: Reset Done
DEBUG: Using IRQ 12
>>> MP3 OK
Started playing test.mp3
Monday 01.01.2000 -- 00:00:07
...
Monday 01.01.2000 -- 00:00:15
01.01.2000 -- 00:00:17
Monday 01.01.2000 -- 00:00:18
...
Monday 01.01.2000 -- 00:01:12
Monday 00.40.2120 -- 00:01:14
Monday 01.01.2000 -- 00:01:15
...
Monday 01.01.2000 -- 00:01:48
`pG8y 01.01.2000 -- 00:01:49
Monday 01.01.2000 -- 00:01:50
...
Monday 01.01.2000 -- 00:04:11
I am thinking it is a conflict in the libraries but I am not sure what to look for.