Go Down

Topic: SD.begin() returns false (Read 1 time) previous topic - next topic



I would like to test an SD module. I downloaded a library and ran the example sketch.
The CardInfo example works perfectly. It displays the type and size of the SD card.

All other examples dont work. The SD.begin(10) command always returns false. However this command is not used in the CardInfo sketch but in all others.


The SD.begin(10) command always returns false.

Is 10 the correct pin?


If your SD slot is on an ethernet shield, you will need to go thru a procedure to get both to work together. The below test code has a method to get both started. I've noticed that if I start the ethernet card the usual way, I have to power down the arduino before I can get the SD cared to work again.

Code: [Select]

//zoomkat 12/26/12
//SD server test code
//open serial monitor to see what the arduino receives
//address will look like when submited
//for use with W5100 based ethernet shields

#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
String readString;


void setup(){


  // disable w5100 while setting up SD
  Serial.print("Starting SD..");
  if(!SD.begin(4)) Serial.println("failed");
  else Serial.println("ok");

  Ethernet.begin(mac, ip, gateway, gateway, subnet);



void loop(){
  // Create a client connection
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();

        //read char by char HTTP request
        if (readString.length() < 100) {
          //store characters to string
          readString += c;
        //if HTTP request has ended
        if (c == '\n') {

          Serial.println(readString); //print to serial monitor for debuging

          client.println("HTTP/1.1 200 OK"); //send new page
          client.println("Content-Type: text/html");
          //client.println("Content-Type: image/jpeg");
          //client.println("Content-Type: image/gif");
          //client.println("Content-Type: application/x-javascript");
          //client.println("Content-Type: text");

          //File myFile = SD.open("boom.htm");
          File myFile = SD.open("HYPNO.JPG");
          //File myFile = SD.open("BLUEH_SL.GIF");
          //File myFile = SD.open("SERVOSLD.HTM");
          if (myFile) {
            // read from the file until there's nothing else in it:
            while (myFile.available()) {
            // close the file:

            //stopping client

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   8)


Yes, 10 is the correct pin. As I said, one sketch works so I assume the wiring is correct and the SD card is formated correctly etc.

And Im working with a "standalone" SD module, not an Ethernet shield.


Yes, 10 is the correct pin. As I said, one sketch works so I assume the wiring is correct and the SD card is formated correctly etc.

One sketch that doesn't use the chip select pin works. None that do use it do. I wouldn't assume, then, that 10 is the correct pin.

I'd suggest trying other pins. How are you connecting the SD reader to the Arduino?

Go Up