"SD failed, or not present" on MEGA2560 R3 with Music Maker

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
Momoware
 
Posts: 3
Joined: Thu Oct 28, 2021 11:24 am

"SD failed, or not present" on MEGA2560 R3 with Music Maker

Post by Momoware »

I have spent the past day troubleshooting why the music maker shield doesn't recognize my microSD card to no success. I would greatly appreciate any help! I have some prior understanding of coding but am really a novice when it comes to the inner workings of circuits.

I followed the Adafruit guide initially: https://learn.adafruit.com/adafruit-mus ... r/assembly

The message I got:
"Adafruit VS1053 Simple Test
VS1053 found
SD failed, or not present"


Here are a few things I tried:
1) Tried with three different microSD cards, formatted with SDFormatter. No success.

I thought it might be an issue with SD card reader and Mega boards in general so I wanted to see if I could get the default "Cardinfo" or the SdFat library "SdInfo" sketches to work.
2) Tried following setting different chipSelect pins and adding "pinMode(10, OUTPUT); digitalWrite(10, HIGH)" as this articles shows https://embedjournal.com/arduino-sd-car ... on-failed/ (I tried both 53 and 10 for the pinMode
3) In this post, a user was able to modify "if (!card.init(SPI_HALF_SPEED, chipSelect))" into "if (!card.init(SPI_QUARTER_SPEED, chipSelect))" to get their SD card initialization code working. I copied their code but that didn't work either.

I really don't know what else to try. I am now waiting for a new music maker shield, a UNO and another MEGA to see if it might be the boards themselves.

I've attached photos of my setup. Thanks in advance!

The shield:
IMG_7273.jpg
IMG_7273.jpg (152.27 KiB) Viewed 749 times
IMG_7274.jpg
IMG_7274.jpg (116.63 KiB) Viewed 749 times
My Arduino Mega:
IMG_7275.jpg
IMG_7275.jpg (144.07 KiB) Viewed 749 times
The code I used (It's just the code from the guide):

Code: Select all

/*************************************************** 
  This is an example for the Adafruit VS1053 Codec Breakout

  Designed specifically to work with the Adafruit VS1053 Codec Breakout 
  ----> https://www.adafruit.com/products/1381

  Adafruit invests time and resources providing this open source code, 
  please support Adafruit and open-source hardware by purchasing 
  products from Adafruit!

  Written by Limor Fried/Ladyada for Adafruit Industries.  
  BSD license, all text above must be included in any redistribution
 ****************************************************/

// include SPI, MP3 and SD libraries
#include <SPI.h>
#include <Adafruit_VS1053.h>
#include <SD.h>

// define the pins used
//#define CLK 13       // SPI Clock, shared with SD card
//#define MISO 12      // Input data, from VS1053/SD card
//#define MOSI 11      // Output data, to VS1053/SD card
// Connect CLK, MISO and MOSI to hardware SPI pins. 
// See http://arduino.cc/en/Reference/SPI "Connections"

// These are the pins used for the breakout example
#define BREAKOUT_RESET  9      // VS1053 reset pin (output)
#define BREAKOUT_CS     10     // VS1053 chip select pin (output)
#define BREAKOUT_DCS    8      // VS1053 Data/command select pin (output)
// These are the pins used for the music maker shield
#define SHIELD_RESET  -1      // VS1053 reset pin (unused!)
#define SHIELD_CS     7      // VS1053 chip select pin (output)
#define SHIELD_DCS    6      // VS1053 Data/command select pin (output)

// These are common pins between breakout and shield
#define CARDCS 4     // Card chip select pin
// DREQ should be an Int pin, see http://arduino.cc/en/Reference/attachInterrupt
#define DREQ 3       // VS1053 Data request, ideally an Interrupt pin

Adafruit_VS1053_FilePlayer musicPlayer = 
  // create breakout-example object!
//  Adafruit_VS1053_FilePlayer(BREAKOUT_RESET, BREAKOUT_CS, BREAKOUT_DCS, DREQ, CARDCS);
  // create shield-example object!
  Adafruit_VS1053_FilePlayer(SHIELD_RESET, SHIELD_CS, SHIELD_DCS, DREQ, CARDCS);
  
void setup() {
  Serial.begin(9600);
  Serial.println("Adafruit VS1053 Simple Test");
  SPI.begin();
  SD.begin(CARDCS);

  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
  }

  // list files
  printDirectory(SD.open("/"), 0);
  
  // Set volume for left, right channels. lower numbers == louder volume!
  musicPlayer.setVolume(20,20);

  // Timer interrupts are not suggested, better to use DREQ interrupt!
  //musicPlayer.useInterrupt(VS1053_FILEPLAYER_TIMER0_INT); // timer int

  // If DREQ is on an interrupt pin (on uno, #2 or #3) we can do background
  // audio playing
  musicPlayer.useInterrupt(VS1053_FILEPLAYER_PIN_INT);  // DREQ int
  
  // Play one file, don't return until complete
  Serial.println(F("Playing track 001"));
  musicPlayer.playFullFile("/track001.mp3");
  // Play another file in the background, REQUIRES interrupts!
  Serial.println(F("Playing track 002"));
  musicPlayer.startPlayingFile("/track002.mp3");
}

void loop() {
  // File is playing in the background
  if (musicPlayer.stopped()) {
    Serial.println("Done playing music");
    while (1) {
      delay(10);  // we're done! do nothing...
    }
  }
  if (Serial.available()) {
    char c = Serial.read();
    
    // if we get an 's' on the serial console, stop!
    if (c == 's') {
      musicPlayer.stopPlaying();
    }
    
    // if we get an 'p' on the serial console, pause/unpause!
    if (c == 'p') {
      if (! musicPlayer.paused()) {
        Serial.println("Paused");
        musicPlayer.pausePlaying(true);
      } else { 
        Serial.println("Resumed");
        musicPlayer.pausePlaying(false);
      }
    }
  }

  delay(100);
}


/// File listing helper
void printDirectory(File dir, int numTabs) {
   while(true) {
     
     File entry =  dir.openNextFile();
     if (! entry) {
       // no more files
       //Serial.println("**nomorefiles**");
       break;
     }
     for (uint8_t i=0; i<numTabs; i++) {
       Serial.print('\t');
     }
     Serial.print(entry.name());
     if (entry.isDirectory()) {
       Serial.println("/");
       printDirectory(entry, numTabs+1);
     } else {
       // files have sizes, directories do not
       Serial.print("\t\t");
       Serial.println(entry.size(), DEC);
     }
     entry.close();
   }
}

User avatar
Momoware
 
Posts: 3
Joined: Thu Oct 28, 2021 11:24 am

Re: "SD failed, or not present" on MEGA2560 R3 with Music Ma

Post by Momoware »

I forgot to link the post I mentioned for 3). It's this one here viewtopic.php?f=31&t=114710&start=15

For the Cardinfo sketch, I followed some code like this:
It also fails at initialization. I don't fully understand what the "chipSelect" pin is, so I just tried different pin numbers (4, 7, 10...), but none of the worked. I also replaced the SD library with an older version (1.0.8), which some users claimed to fix the problem, but that didn't work for me either.

Code: Select all

/*
  SD card test

  This example shows how use the utility libraries on which the'
  SD library is based in order to get info about your SD card.
  Very useful for testing a card when you're not sure whether its working or not.

  The circuit:
    SD card attached to SPI bus as follows:
 ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila
 ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila
 ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila
 ** CS - depends on your SD card shield or module.
 		Pin 4 used here for consistency with other Arduino examples


  created  28 Mar 2011
  by Limor Fried
  modified 9 Apr 2012
  by Tom Igoe
*/
// include the SD library:
#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;
SdVolume volume;
SdFile root;

// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
// MKRZero SD: SDCARD_SS_PIN
const int chipSelect = 10;

void setup() {
  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }


  Serial.print("\nInitializing SD card...");

  // we'll use the initialization code from the utility libraries
  // since we're just testing if the card is working!
  if (!card.init(SPI_HALF_SPEED, chipSelect)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    while (1);
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }

  // print the type of card
  Serial.println();
  Serial.print("Card type:         ");
  switch (card.type()) {
    case SD_CARD_TYPE_SD1:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32
  if (!volume.init(card)) {
    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");
    while (1);
  }

  Serial.print("Clusters:          ");
  Serial.println(volume.clusterCount());
  Serial.print("Blocks x Cluster:  ");
  Serial.println(volume.blocksPerCluster());

  Serial.print("Total Blocks:      ");
  Serial.println(volume.blocksPerCluster() * volume.clusterCount());
  Serial.println();

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("Volume type is:    FAT");
  Serial.println(volume.fatType(), DEC);

  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks
  volumesize *= volume.clusterCount();       // we'll have a lot of clusters
  volumesize /= 2;                           // SD card blocks are always 512 bytes (2 blocks are 1KB)
  Serial.print("Volume size (Kb):  ");
  Serial.println(volumesize);
  Serial.print("Volume size (Mb):  ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Gb):  ");
  Serial.println((float)volumesize / 1024.0);

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  root.openRoot(volume);

  // list all files in the card with date and size
  root.ls(LS_R | LS_DATE | LS_SIZE);
}

void loop(void) {
}

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: "SD failed, or not present" on MEGA2560 R3 with Music Ma

Post by mikeysklar »

I would go over the solder points again. It is not bad, but some of the flow looks like possible cold joints. I see you have the jumpers and the 2x3 header in place which are necessary for the mega.

What are the exact specs of your SD cards that you have tried? Make / model / size? I've seen issued with anything 32GB or larger.

User avatar
Momoware
 
Posts: 3
Joined: Thu Oct 28, 2021 11:24 am

Re: "SD failed, or not present" on MEGA2560 R3 with Music Ma

Post by Momoware »

mikeysklar wrote:I would go over the solder points again. It is not bad, but some of the flow looks like possible cold joints. I see you have the jumpers and the 2x3 header in place which are necessary for the mega.

What are the exact specs of your SD cards that you have tried? Make / model / size? I've seen issued with anything 32GB or larger.
Hi I just received another music maker shield today and it worked. My MicroSD cards are 8gbs. I don't know if it was a solder problem or not...

User avatar
mikeysklar
 
Posts: 14165
Joined: Mon Aug 01, 2016 8:10 pm

Re: "SD failed, or not present" on MEGA2560 R3 with Music Ma

Post by mikeysklar »

Glad the new one worked.

You might as well go over the old units solder joints just to see if it was a soldering issue.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”