[solved] Can't get SD card to be detected by Arduino Pro Micro

Sorry if this is not the right forum. I am very new to the world of arduino and currently working on a USB rubber ducky. I am using an arduino pro micro for this.

Connections (From card reader to the board):-

  • VCC from reader to VCC in arduino.

  • GND from reader to GND in the arduino.

  • MOSI to pin 16 on arduino.

  • MISO to pin 14.

  • SCK to pin 15.

  • CS to pin 4.

I am trying to run the CardInfo example code from arduino IDE that tries to detect an SD card. I have made sure that the pin in the code is also set to 4.

CardInfo program output:

"Initializing SD card...initialization failed. Things to check:

  • is a card inserted?
  • is your wiring correct?
  • did you change the chipSelect pin to match your shield or module?"

Also, I am using the 5V variant of the board and in the IDE, I have selected the board as "Arduino Leonardo" (I am able to execute basic scripts like opening an notepad and writing to it etc).

Currently feel all lost. Any help would be appreciated.

Your setup sounds OK but double check the wiring as MISO/MOSI mixups are common. Have you got another Arduino of any kind to the card reader with ?

Thanks for your reply. I have double checked the wiring and it seems fine. I dont have another board to test the card reader with. I have attached an image of the wiring on a breadboard.

Googling this, I found one thread that might explain the problem:

https://forums.adafruit.com/viewtopic.php?f=25&t=65541

Apparently the default CS pin D17 isn't brought out to the headers on the Micro. The suggested solution is to change the default CS to D10 in the library itself. Then you would also make that change in your wiring and in CardInfo.

It's not clear why this would make a difference since CardInfo defines CS to whatever you want, and should override the default. But it's a simple change, and you can change it back if it doesn't work. And it seems the problem must have something to do with CS.

You might be able to test the CS theory. If you're on the right CS pin, your meter should show some activity on that line when you run CardInfo - not just constant 5V. CS is active low.

Another possible test is to run Card Info once, then disconnect CS from the Micro, and connect the card module's CS directly to ground, then hit the Micro's Reset button, if it has one, or just quickly connect the Reset pin to ground, and see if CardInfo works then. Basically, you are making the SD always selected. I've never tried this test, but it might work.

The only other thing I can think of concerns your SD module. Your picture doesn't show the front, but it should have a 3.3V voltage regulator and a voltage level shifter chip of some kind, probably a 74xxx125. If it doesn't have those, then you would need to be using a 3.3V Micro.

I have tried doing the things you mentioned, still no luck. I have attached a picture of card reader front.

The chip on the right reads -

LVC125A
7150006
YXD18
310

Honestly at this point I am suspecting a hardware issue. Probably should use a multimeter to check if the board is supplying voltage and the reader is working fine? Apart from that I cant think of anything. Do you think I should buy any other arduino board that works better? (The reaon I chose a pro micro was because of its small size and keyboard controller functionality).

The SD module looks right.

You could try something like a Nano. But my guess is there's nothing wrong with your Micro. It's just a matter of figuring out what's wrong. You did day you have the 5V Micro, right?

Yeah thats right, I have a 5V version

Well I'm stumped. Unless you have a scope, it's hard to see what's happening on the lines.

You said you told the IDE it was a Leonardo, but the Pro Micro is actually a Sparkfun device. Did you have to download drivers or anything from Sparkfun to get it to run?

I think the best thing to do is for you to start a new thread in Storage, and ask if anyone is able to run CardInfo on a Pro Micro with a microSD module.

Sorry I wasn't able to help you. The 32u4 stuff is a bit off my beaten path.

I think the best thing to do is for you to start a new thread in Storage, and ask if anyone is able to run CardInfo on a Pro Micro with a microSD module.

It would be better to move this topic to Storage so that the full history is presented. Do not start a new topic on the same subject

Report to moderator if you want it moved

@ShermanP Thanks for your help. I'll move the thread to storage forum but just answering your question, I didn't have to install any additional drivers to get it to run. Maybe I should try and reinstall the drivers following sparkfun guidelines. I'll give it a go.

Edit

I have tried uninstalling the arduino IDE, following this sparkfun link - (Pro Micro & Fio V3 Hookup Guide - SparkFun Learn) and reinstalling the IDE with the right drivers.

I am now able to select Sparkfun pro micro from the board list instead of Arduino Leonardo. However the problem still persists. After a bit more research, I found this link - (https://forum.arduino.cc/index.php?topic=240815.0) where another user came across the same problem. He modified the Cardinfo code to print out the pins.

/*
 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 <SPI.h>
#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("SS_PIN ");
 Serial.println(SS_PIN);
 Serial.print("SS ");
 Serial.println(SS);

 Serial.print("MOSI_PIN ");
 Serial.println(MOSI_PIN);
 Serial.print("MOSI ");
 Serial.println(MOSI);

 Serial.print("MISO_PIN ");
 Serial.println(MISO_PIN);
 Serial.print("MISO ");
 Serial.println(MISO);

 Serial.print("SCK_PIN ");
 Serial.println(SCK_PIN);
 Serial.print("SCK ");
 Serial.println(SCK);

 Serial.print("\nInitializing SD card...");

 // 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 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) {

}

The output that I get from the code is:

"SS_PIN 10
SS 17
MOSI_PIN 16
MOSI 16
MISO_PIN 14
MISO 14
SCK_PIN 15
SCK 15

Initializing SD card...initialization failed. Things to check:

  • is a card inserted?
  • is your wiring correct?
  • did you change the chipSelect pin to match your shield or module?"

I have followed the steps outlined in the link and changed the SS_PIN in Sd2PinMap.h to 10 (found in arduino\libraries\SD\src\utility) which resulted in the SS_PIN to be 10 as above. I have also changed the value of SS in the file pins_arduino.h which came with sparkfun drivers to 10 (file found in Arduino_Boards-master\sparkfun\avr\variants\promicro). However this does not change the SS pin to 10 as seen in the code.

I suspect this is the problem since I dont have pin 17 on my board? Any ideas how I can change it?

I'm sorry your thread hasn't been noticed by someone who has actually used an SD module with a Pro Micro. If you found someone like that, you could compare notes.

This is a complete long shot, and I'm just guessing, but an alternative might be to use the SDFat.h library and its SDinfo example instead of SD.h and CardInfo.

If you just don't get any help here, there's a Sparkfun forum where you might do better.

I would recommend some debugging steps with simple programs to test each pin. With the SD module removed. Write a program to turn on CS and, with an LED and resistor attached, see if it turns on. Test each pin that way, separately. For MOSI, you'll want a program that reads the pin and either turns on an LED or sends serial data. This will tell you if you are using the correct pins.

The only other thing I can think of is that back in the day you needed to formally configure the default CS pin as an output even if you weren't using it. I don't know why, or if that's still a problem. But the fix for that would just be:

pinMode(17,OUTPUT);

Since I can't find good specs of the micro, maybe the i/o pins does output 3.3v logic levels? Instead of 5v. The your sd card reader might be the problem. I have the same sd card reader working on my nano without any trouble.

Best wishes and hope you doing well out there!

I found the solution to my problem!!!!

Fortunately my SD card was working but I made a noob mistake :confused: . The thing is that I was connecting my Arduino pro micro to the breadboard using the row pin headers without soldering them to the Arduino board. I was just simply placing my Arduino board on the pins array and the pins weren't making proper contact with the board pins. After soldering the pins to the board, it works now. The reason I did not solder it in the first place is because I watched a youtube video where the person did the same thing and his setup worked perfectly, which is why I assumed that you don't need to solder.

Thanks everyone and @ShermanP for helping me out.

That's great. But we need some clarification for the benefit of future readers. How much of all the stuff you tried was necessary in the end - changing the library CS default, installing the Sparkfun stuff? Does it work if you just do what you tried in the beginning - pretend it's a Leonardo?

Sorry for the late reply but I think in the end, the issue was I think just not soldering the pins to the board. Modifying library CS stuff definitely didn't really matter. That being said I was using the Sparkfun driver when it worked. I will give it another try by uninstalling everything and starting from scratch selecting Leonardo as the board.

Any video with the person not soldering the header pins in place is very wrong and you should not watch another video from that person...EVER. YouTube is full of people who don't know anything, but think they do.