Accessing SD Card completely fails on Arduino Ethernet

Hi all,

i'm writing to this forum after googling around. No problem solver found :confused:

I have the following problem:

using the "SD Files" Example from the reference (http://www.arduino.cc/en/Tutorial/Files)
the only output I get is:

Initializing SD card...initialization failed!

I'm using:

  • Arduino Ethernet
  • Kingston 4GB class 10 micro SD card
  • SanDisk 8GB Ultra class 10
  • Arduino IDE 1.6.4

both were formatted with SD-Formatter and are working well in the PC

Thanks in advance
Thomas

Try disabling the w5100 before calling SD.begin(4). Power off the Arduino for a few seconds after uploading the code with this change, then power it on. Sometimes the SD gets locked up, and I don't know why.

void setup()
{
  Serial.begin(115200);

  // disable w5100 SPI while starting SD
  pinMode(10,OUTPUT);
  digitalWrite(10,HIGH);

  Serial.print(F("Starting SD.."));

  if(!SD.begin(4)) {
    Serial.println(F("failed"));
  }
  else {
    Serial.println(F("ok"));
  }

  // rest of your setup

Just a thought...

Hi Tim

I saw this hint already in a post from 2012 (i think) and tested but no success.

my SD card init section looks like this:

  Serial.print("Initializing SD card...");

  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);

  while (!SD.begin(4)) {
    Serial.println("initialization failed!");
  }
  Serial.println("initialization done.");
  
  myFile = SD.open("test.txt", FILE_WRITE);

...and btw the "sd card thing" is the first step in this project. My plan is to use the network interface...so disabling the network is not an option. :slight_smile:

I even cannot believe that this normal...others are using it i think.

Now i have cross checked the code on an arduino leonardo with wifi shield and the code works!

And now it dawns on me...powering the arduino over usb and using the sd-card is not really a good idea...even a powered usb hub does not solve the problem...you have to power it over the power connector :slight_smile: :slight_smile: :slight_smile:

This post was created while testing around...
and because of the tricky behaviour of a leonardo board/serial i connected the power....and bingo!

hope this helps somebody else :slight_smile:

Problem solved.

Thanks

...and btw the "sd card thing" is the first step in this project. My plan is to use the network interface...so disabling the network is not an option. :slight_smile:

It does not disable the w5100. It disables the w5100 SPI interface. That happens every time you use any SPI device. The slave select is taken LOW to enable the SPI on that device, the transfer is sent/received, then the slave select is taken HIGH to disable the device SPI bus.

And now it dawns on me...powering the arduino over usb and using the sd-card is not really a good idea...even a powered usb hub does not solve the problem...you have to power it over the power connector :slight_smile: :slight_smile: :slight_smile:

It is a good idea for me. I've been using usb power for years now.