Arduino UNO + Arduino Ethernet Shield - can't read SD card

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:

  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!

Digital pin 4 is the SS for the SD card. Try this in your setup() routine:

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.

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

Again, thanks!

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

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!

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

I'm actually using an 2 GB Sandisk microSD card, with a Kingston SD card adapter, both work fine on the computer. You're right, I'm not using the ethernet shield, so I just soldered some pins to a card holder.

What card holder? How is it wired? How are you powering it? Are you using the 3.3v power pin on the Arduino? If so, there may not be enough power available on that pin. Only 50ma available from that regulator, and some SD cards could use up to 100ma.

The Uno has 5v data pins, and the SD card has 3.3v data pins. Most SD cards have some type of logic level converter to do the voltage conversion, and a 3.3v regulator onboard for the power.

Thank you for your quick response, I've wired it like the schematics shown on this topic http://arduino.cc/forum/index.php/topic,8863.0.html , I ripped the card holder from a multiple card-to-USB reader, and maybe it doesn't have enough power because the arduino 3.3V is also connected to an RTC (chronodot that uses few mA, 200µA according to specifications), could this be the problem?

That could be part of it. If you have a 3.3v regulator, set it up to use the 5v pin on the Uno as the supply. If not, you can try powering the SD card with two new AA batteries just for a test. Leave the ground connected to the Uno for a data ground.

The other part could be the voltage divider resistors for the data lines. They are not as good as a logic level converter.

Ok I'll try those two things, thank you very much!