SD card initialization failure

Using Arduino 1.0.6 + Arduino UNO R3 I am unable to get the SD card initialized.

External MP3 is RS232 by mdfly

Per the MP3 Pin assignment, I have the following

MP3 PIN 15 to Arduino TX
MP3 PIN 17 to Right Speaker
MP3 PIN 18 to Left Speaker
MP3 PIN 19 to Arduino GND
MP3 PIN 20 to Arduino 5V (Uno connected to external power supply)

Everything appears connected correctly. Using Cardinfo example code in Arduino (below), SanDisk 4GB SD card fails to initialize.

  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 <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
const int chipSelect = 4;    

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

  Serial.print("\nInitializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
  pinMode(10, OUTPUT);     // change this to 53 on a mega

  // 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 is inserted?");
    Serial.println("* Is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
  } else {
   Serial.println("Wiring is correct and a card is present."); 

  // print the type of card
  Serial.print("\nCard type: ");
  switch(card.type()) {
    case SD_CARD_TYPE_SD1:
    case SD_CARD_TYPE_SD2:

  // 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");

  // print the type and size of the first FAT-type volume
  uint32_t volumesize;
  Serial.print("\nVolume 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 *= 512;                            // SD card blocks are always 512 bytes
  Serial.print("Volume size (bytes): ");
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;

  Serial.println("\nFiles found on the card (name, date and size in bytes): ");
  // list all files in the card with date and size | LS_DATE | LS_SIZE);

void loop(void) {

Initializing SD card...initialization failed. Things to check:
* is a card is inserted?
* Is your wiring correct?
* did you change the chipSelect pin to match your shield or module?

Card was formatted using SDCard formatter, not through windows. I double checked the wiring and it all looks good. Tried 3 different cards all with the same result. Seems to be a fairly common problem based on forum searching, but have not come across a definitive conclusion. Any idea what's going on?

Per the MP3 Pin assignment, I have the following

Are those the only pins connected from the device to the Arduino? If so, you are missing all the SPI pins.

Currently yes, per the spec sheet for the .mp3 player and relayed to me by mdfly tech staff.

I see the SPI pins on the Arduino (digital 10-13), but no such corresponding pins on the .mp3.

My guess is that only the MP3 card itself has access to the SD card. You tell the card to play a file and it finds it on the card and plays it. But the CardInfo sketch, and any others like it, aren't going to be able to see the card. The command set shown on the last page of the spec sheet suggests that you can't have useful names for the files - they must be named 001.mp3, 002.mp3, ... up to 199.mp3


I already have the .mp3 file named 001.mp3, so the file naming is not the problem. The previous poster mentioned missing SPI pins to the Arduino. I'll have to contact MDfly to see if they can assist.

You're missing my point entirely. There are no SPI pins on the MDfly. You cannot access the SD card on the MDfly at all. All you can do is send commands to the MDfly to tell it which file to play.


BTW. Looks like you'll have to be careful how you wire up the MDfly. It requires a 12V supply. If you touch the wrong wire to 12V, you could blow up your Arduino. (Been there, done that with a Teensy)

Pete +EDIT: Their spec sheet says 12V but their website says 6-12V.

You’re missing my point entirely.
There are no SPI pins on the MDfly. You cannot access the SD card on the MDfly at all. All you can do is send commands to the MDfly to tell it which file to play.


Fair enough, then I won’t waste anymore time trying to get that sketch to work

The MDFLY is powered connected to the Arduino with an external 9V power supply, so I’m good there. I’m using a sketch (code below) with an added command to play the 001.mp3 file at the bottom. The MDFLY is connected correctly and the Arduino validates the code correctly. I can upload it and the activity light on the MDFLY shows that the sound is playing, but all I hear is a distorted version of the .mp3. Very strange.

 Stepper Motor Control - one revolution

 This program drives a unipolar or bipolar stepper motor.
 The motor is attached to digital pins 8 - 11 of the Arduino.

 The motor should revolve one revolution in one direction, then
 one revolution in the other direction.

 Created 11 Mar. 2007
 Modified 30 Nov. 2009
 by Tom Igoe


#include <Stepper.h>
#include <SD.h>
File myFile;
int x = 0;
const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  // set the speed at 60 rpm:
  // initialize the serial port:

void loop() {
 if (x <= 10)
 { // step one revolution in one direction:
  // delay(500);
  // step one revolution in the other direction:
  // Serial.println("counterclockwise");
 // myStepper.step(-stepsPerRevolution);
 // delay(500);
File datafile ="001.mp3");}

What does the stepper motor have to do with this? The Serial output that the stepper section of the code generates will interfere with the MDfly stuff.

File datafile ="001.mp3");

I thought it was clear that you can't access the files on the SD card. This command cannot access the MDfly no matter how hard or how often you try. The only thing you can do with the MDfly is send it serial commands to tell it to play a track (or a random selection) and the spec is rather cryptic about how that is done.

all I hear is a distorted version of the .mp3.

The spec also doesn't explain what the audio output is designed to drive so there's no way to be sure how the stereo output should be wired

I think your best bet is to read through this thread and try the library that's referenced there. NOTE that it uses different Arduino pins for connecting Rx and Tx to MDfly.


The gist of the code is to have the stepper motor turn and the .mp3 file play at the same time.

I had serial begin and serial write in the code. I added the figuring that might be the trick to getting it working

I’ll take a look at the link you provided. Thanks for all your help.

@Cmjb13, do not cross-post. Other thread removed.

For what it’s worth, the manufacturer attached a datasheet for a similar model that identifies the other pins.

AU5121.pdf (888 KB)

Would anyone know why the code below would fail to play a single .mp3 file? This sketch appears to be as simple as it gets

void setup(){

void loop(){

I have also tried Serial.write ("001.mp3") to no avail.