Go Down

Topic: Arduino UNO + Arduino Ethernet Shield - can't read SD card (Read 3 times) previous topic - next topic

esalmon

I am trying to run the Example/SD/listfiles sketch on my Uno/Ethernet Shield combo and it keeps returning:

Initializing SD card...initialization failed!

I formatted the 2G SD card as FAT 32 and added a two files and a directory to test it.

I have nothing else hooked up to the Arduino and it is connected to the PC via USB.

Here is the code - should be from the default sketch:

Code: [Select]

  Serial.print("Initializing 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);

  if (!SD.begin(10)) {
    Serial.println("initialization failed!");
    return;
  }



Thanks!

SurferTim

Digital pin 4 is the SS for the SD card. Try this in your setup() routine:
Code: [Select]
Serial.print("Initializing SD card...");
 // disable the ethernet SPI
 pinMode(10, OUTPUT);
 digitalWrite(10,HIGH);

 // SD card SS pin is digital 4
 if (!SD.begin(4)) {
   Serial.println("failed!");
   return;
 }
 else
 {
   Serial.println("ok");
 }


edit: change bad spelling.

esalmon

That was it, thanks!  It is working!  I used a different message in the println..but clearly it is working now.

Again, thanks!

Code: [Select]

Initializing SD card...Init...OK!
initialization done.
FILE1 16
DIR1/
FILE2 21
done!

Faye_V

Hi everyone,

I'm having trouble with my SD card and I've tried what SurferTim said, but I keep getting the "Card failed or not present" message, I wanted to ask you where exactly do I have to connect the pins of the SD card on the Arduino (I'm using an Arduino UNO Rev3), I've already tried connecting the CS pin of the card on digital pins 4 and 10 but didn't work either way.

Thank you in advance for your help!

SurferTim

What SD device do you have? Obviously not on the ethernet shield. A link to the SD device would help.

Go Up