MicroSD card error

Breakout boards, sensors, other Adafruit kits, etc.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

MicroSD card error

Post by coding1227 »

Dear Adafruit team

I recently bought a mini SD Card reader (http://www.adafruit.com/products/254) to use with my Arduino Uno. As I am finally having a chance to try it out, I am getting the following error:

Type any character to start
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X1,0X0

I've tried two other miniSD cards, all of which werefirst FAT formatted, and then when tested they gave me the same error message. The SDFat sketch I am using is attached below. I've double & triple-checked all the wiring and it is all correct. I am using short wires (5 inches long) connected to a breadboard.

By any chance, have you seen this kind of error before? Thanks in advance for your help with this!

Code: Select all

// Ported to SdFat from the native Arduino SD library example by Bill Greiman
// On the Ethernet Shield, CS is pin 4. SdFat handles setting SS
const int chipSelect = 10;
/*
 SD card read/write
  
 	 
 */
#include <SdFat.h>
SdFat sd;
SdFile myFile;

void setup() {
  Serial.begin(9600);
  while (!Serial) {}  // wait for Leonardo
  Serial.println("Type any character to start");
  while (Serial.read() <= 0) {}
  delay(400);  // catch Due reset problem
  
  // Initialize SdFat or print a detailed error message and halt
  // Use half speed like the native library.
  // change to SPI_FULL_SPEED for more performance.
  if (!sd.begin(chipSelect, SPI_HALF_SPEED)) sd.initErrorHalt();

  // open the file for write at end like the Native SD library
  if (!myFile.open("test.txt", O_RDWR | O_CREAT | O_AT_END)) {
    sd.errorHalt("opening test.txt for write failed");
  }
  // if the file opened okay, write to it:
  Serial.print("Writing to test.txt...");
  myFile.println("testing 1, 2, 3.");

  // close the file:
  myFile.close();
  Serial.println("done.");

  // re-open the file for reading:
  if (!myFile.open("test.txt", O_READ)) {
    sd.errorHalt("opening test.txt for read failed");
  }
  Serial.println("test.txt:");

  // read from the file until there's nothing else in it:
  int data;
  while ((data = myFile.read()) >= 0) Serial.write(data);
  // close the file:
  myFile.close();
}

void loop() {
  // nothing happens after setup
}




User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

Post some photos showing your soldering and connections to the Arduino.

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

sure. Please see attached
Attachments
photo 3.JPG
photo 3.JPG (146.46 KiB) Viewed 1684 times
photo 2.JPG
photo 2.JPG (137.88 KiB) Viewed 1684 times
photo 1.JPG
photo 1.JPG (143.91 KiB) Viewed 1684 times

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

one more
Attachments
photo 4.JPG
photo 4.JPG (116.27 KiB) Viewed 1684 times

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

From what I can see, your solder and connections are OK.
Double check the continuity of the jumpers. We have seen a few bad ones. Also make sure that all the jumpers are firmly gripped in the breadboard. If not, move to an adjacent hole for a more solid connection.

Also try running the "cardinfo" sketch. That sometimes gives more useful diagnostic information.

User avatar
pburgess
 
Posts: 4161
Joined: Sun Oct 26, 2008 2:29 am

Re: MicroSD card error

Post by pburgess »

Looks like you're connecting to the 3V pin for power. Use the 5V pin instead (to the 5V pin on Arduino), leave 3V disconnected. This is crucial for the level-shifter to actually level-shift.

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

Hi guys

thank you so much for the suggestions. I really appreciate your help with this. I tried all the things you mentioned (using the 5v pin connected to the 5v Arduino pin), checked the continuity of the jumpers (all are good), as well as their connections to the breadboard itself (no loose ones). Still no luck...

I also run the SD "cardinfo" sketch (after changing the chipSelect to 10), and it doesn't look like it is recognizing it either. The output I am getting is:


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?

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

* did you change the chipSelect pin to match your shield or module?
Did you? For cardinfo by default it is 4. You need to change it in this section of code:

Code: Select all

// 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 = 10;   

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

yes, I did. Here is the code that I used. As you can see, it has the chipSelect set to 10.

Code: Select all

/*
  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 = 10;    

void setup()
{
 // Open serial communications and wait for port to open:
  Serial.begin(9600);
   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?");
    return;
  } 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:
      Serial.println("SD1");
      break;
    case SD_CARD_TYPE_SD2:
      Serial.println("SD2");
      break;
    case SD_CARD_TYPE_SDHC:
      Serial.println("SDHC");
      break;
    default:
      Serial.println("Unknown");
  }

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


  // 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);
  Serial.println();
  
  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.println(volumesize);
  Serial.print("Volume size (Kbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);
  Serial.print("Volume size (Mbytes): ");
  volumesize /= 1024;
  Serial.println(volumesize);

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


void loop(void) {
  
}

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

Make sure that your card is fully seated in the holder. It looks a bit crooked in the photos.

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

Thanks, but no worries... The card is fully seated in the breadboard. I've made super sure of that, as well as that all the connections are working, that the wiring is correct, that the programming sketches are configured correctly, etc.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

Thanks, but no worries... The card is fully seated in the breadboard
Not what I was asking. Is the SD card fully seated in the card holder? It is not straight in the photos.

User avatar
coding1227
 
Posts: 32
Joined: Tue Apr 30, 2013 5:00 pm

Re: MicroSD card error

Post by coding1227 »

Wuaaauu! You have the eyesight of a hawk! I can't believe how it is that I missed this. You were right... I am so sorry for my oversight with this.

Thank you soooo much for your help! :) I think it is time for me to buy some reading glasses ;)
Last edited by coding1227 on Wed Nov 27, 2013 7:11 pm, edited 1 time in total.

User avatar
adafruit_support_bill
 
Posts: 88154
Joined: Sat Feb 07, 2009 10:11 am

Re: MicroSD card error

Post by adafruit_support_bill »

So it is working now?

Locked
Please be positive and constructive with your questions and comments.

Return to “Other Products from Adafruit”