Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.

VS1053 help
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

VS1053 help

by cadab321 on Fri Jul 17, 2020 5:12 pm

Hello there. I will try to be descriptive as possible. I am currently making a radio that plays at 5pm daily. Linked are all used parts. ... 2749.l2649 ... 2749.l2649 ... 2749.l2649 ... 2749.l2649 ... 2749.l2649 ... 2749.l2649 ... 2749.l2649 ... 2749.l2649

Anyways, below is a schematic of my project. Note that the VS1053 used in the schematic is a different model than the one I am currently using but it is the same nonetheless.


Below is my code:

Code: Select all | TOGGLE FULL SIZE

#include <SPI.h>
#include <SD.h>
#include <Adafruit_VS1053.h>

#define CLK 9 // SPI Clock, shared with SD card
#define MISO 12 // Input data, from VS1053/SD card
#define MOSI 11 // Output data, to VS1053/SD card
#define RESET 13 // VS1053 reset pin (output)
#define CS 10 // VS1053 chip select pin (output)
#define DCS 8 // VS1053 Data/command select pin (output)
#define DREQ 4 // VS1053 Data request pin (into Arduino)
#define CARDCS 6 // Card chip select pin

Adafruit_VS1053_FilePlayer musicPlayer = Adafruit_VS1053_FilePlayer(RESET, CS, DCS, DREQ, CARDCS);

//// For FM Transmitter ////
#include <Wire.h>
#include <Adafruit_Si4713.h>
#define RESETPIN 5  // Reset pin at pin 5
#define FMSTATION 10510      // 10230 == 102.30 MHz

Adafruit_Si4713 radio = Adafruit_Si4713(RESETPIN);

#include <avr/sleep.h>  //this AVR library contains the methods that controls the sleep modes
#define interruptPin 2  //Pin we are going to use to wake up the Arduino Pin2
#include <DS3232RTC.h>  //RTC Library

void setup() {
  Serial.println("Couldn't find radio?");
  pinMode(interruptPin, INPUT_PULLUP); //Set pin d2 to input using the builtin pullup resistor

  if (! musicPlayer.begin()) { // initialise the music player
    Serial.println(F("Couldn't find VS1053, do you have the right pins defined?"));
    while (1);
  Serial.println(F("VS1053 found"));

  if (!SD.begin(CARDCS)) {
    Serial.println(F("SD failed, or not present"));
    while (1);  // don't do anything more
  Serial.println("SD OK!");
  musicPlayer.setVolume(20, 20);

  if (! radio.begin()) {  // begin with address 0x63 (CS high default)
    Serial.println("Couldn't find radio?");
    while (1);

  Serial.print("\nSet TX power");
  radio.setTXpower(115);  // dBuV, 88-115 max

  Serial.print("\nTuning into ");
  Serial.println(FMSTATION % 100);
  radio.tuneFM(FMSTATION); // 102.3 mhz

  // This will tell you the status in case you want to read it from the chip
  Serial.print("\tCurr freq: ");
  Serial.print("\tCurr freqdBuV:");
  Serial.print("\tCurr ANTcap:");

  // initialize the alarms to known values, clear the alarm flags, clear the alarm interrupt flags
  RTC.setAlarm(ALM1_MATCH_DATE, 0, 0, 0, 1);
  RTC.setAlarm(ALM2_MATCH_DATE, 0, 0, 0, 1);
  RTC.alarmInterrupt(ALARM_1, false);
  RTC.alarmInterrupt(ALARM_2, false);

  tmElements_t tm;
  tm.Hour = 15;               // set the RTC to an your time (HOUR, MINUTE, SECOND)
  tm.Minute = 38;
  tm.Second = 30;
  tm.Day = 17;
  tm.Month = 7;
  tm.Year = 2020 - 1970;      // tmElements_t.Year is the offset from 1970
  RTC.write(tm);              // set the RTC from the tm structure

  time_t t; //create a temporary time variable so we can set the time and read the time from the RTC
  t = RTC.get(); //Gets the current time of the RTC
  RTC.setAlarm(ALM1_MATCH_HOURS , 0, 45, 15, 0); // Setting alarm 1 to go off at 17:00:00, Syntax: RTC.setAlarm(What to match , Seconds, minutes, hours, days);
  // clear the alarm flag
  // configure the INT/SQW pin for "interrupt" operation (disable square wave output)
  // enable interrupt output for Alarm 1
  RTC.alarmInterrupt(ALARM_1, true);
  Serial.println("initialization done."); 


void loop() {
  delay(500);//wait 5 seconds before going to sleep. In real senairio keep this as small as posible

void Going_To_Sleep() {
  sleep_enable();//Enabling sleep mode
  attachInterrupt(digitalPinToInterrupt(interruptPin), wakeUp, LOW);//attaching a interrupt to pin d2

  set_sleep_mode(SLEEP_MODE_PWR_DOWN);//Setting the sleep mode, in our case full sleep
  time_t t;// creates temp time variable
  t = RTC.get(); //gets current time from rtc
  Serial.println("Sleep  Time: " + String(hour(t)) + ":" + String(minute(t)) + ":" + String(second(t))); //prints time stamp on serial monitor
  delay(1000); //wait a second to allow the led to be turned off before going to sleep
  sleep_cpu();//activating sleep mode

  Serial.println("just woke up!"); //next line of code executed after the interrupt
  t = RTC.get();
  Serial.println("WakeUp Time: " + String(hour(t)) + ":" + String(minute(t)) + ":" + String(second(t))); //Prints time stamp

  delay(10000); // Wait 10 sec after wakeup before playing the file
  /////////// Play Music File //////////////////////
  Serial.print("\tCurr ASQ: 0x");
  Serial.println(radio.currASQ, HEX);
  Serial.print("\tCurr InLevel:");
  Serial.println("Start playing music.");

  musicPlayer.sineTest(0x44, 500); // Make a tone to indicate VS1053 is working
  musicPlayer.playFullFile("one.mp3");  // name of the mp3 file

  if (musicPlayer.stopped()) {
    Serial.println("Done playing music.");
  //Set New Alarm
  RTC.setAlarm(ALM1_MATCH_HOURS , 0, 45, 15, 0); // Setting alarm 1 to go off at 17:00:00 (5:00 pm) everyday
  // clear the alarm flag


void wakeUp() {
  Serial.println("Interrrupt Fired");//Print message to serial monitor
  sleep_disable();//Disable sleep mode
  detachInterrupt(digitalPinToInterrupt(interruptPin)); //Removes the interrupt from pin 2;

Strangely, I always get the response:
Couldn't find VS1053, do you have the right pins defined?
in the COM panel.

Can anyone provide some insight/feedback and help my project get running?

Posts: 1
Joined: Fri Jul 17, 2020 5:08 pm

Re: VS1053 help

by bayviewboom on Thu Sep 03, 2020 9:32 pm

Hi, did you find your solution?
Posts: 6
Joined: Thu May 08, 2014 7:26 pm

Please be positive and constructive with your questions and comments.