Unable to initialize SD reader from Arduino UNO

Like so many others, my Example SD code fails at the "SD.begin" line. I've tried the many suggestions in the relative thread and google searches. I'm frustrated at the lack of information available from the library code as to the error. In looking through the SD.cpp code, the begin function returns the AND of initialize the H/W, validating the volume and validating the root. If any of these fail, "begin" returns false. I've tried making some code changes in SD.cpp and adding the library to my sketch but the IDE always chooses the system library code over mine. My C++ skills are too weak to create an alternate named library entry.

My question is two-fold:

  1. Is anyone aware of an SD library that provides more information for the failure to initialize (e.g. H/W vs SD card)?
  2. Is there an easy way to direct the IDE to choose my modified SSD.cpp over the system library?

Many thanks in advance.

Can you please provide details of the hardware. A link to the SD module that you use would be a start, a schematic (photo of a pencil/paper drawing is fine) how you have it connected could help as well. Do you have anything else connected to the Uno?

Which type of SD card do you use? What is the size?
How did you format the card? There is a dedicated tool for it.

How did you add the library to your sketch? I have the SD library installed twice

  1. C:\Users\yourUsername\AppData\Local\Arduino15\libraries\SD
  2. C:\Users\yourUsername\Documents\Arduino\libraries\SD
    When I compile, it takes the second one.
Multiple libraries were found for "SD.h"
  Used: C:\Users\yourUsername\Documents\Arduino\libraries\SD
  Not used: C:\Users\yourUsername\AppData\Local\Arduino15\libraries\SD

So you can copy the original SD directory (complete) to the second directory above and modify that.

To my knowledge, there is only one alternative library, SdFat. I do not know if it gives more detailed information on errors but you can try.

I've been remiss in thanking you earlier for your quick reply. I'd hoped to be able to share progress but only frustration to date. I tried putting the entire SD driver in my sketch folder (not library) but it didn't compile. Error was some kind of duplicate function definition between my ".h" file and a system library. I suspect that some combination of files in the sketch folder and IDE library will work but I have not tried all the permutations. I tried modifying the file in the IDE library directory but the compiler objected. I added a single comment line and that created an error.

I've ordered some new SD cards to eliminate the possibility that either the card is bad (unlikely) or I blew it out. If I strike out there, I'll come hat in hand with photos and details asking for more help.

Paul

Generally speaking, if the CardInfo example doesn't work, it's usually because:

  1. The wiring is wrong, or specifically the CS line is not on the right pin.
  2. Something is wrong with power to the SD card.
  3. The card is SDXC or bigger. The IDE library is limited to SD and SDHC unless they've changed that recently.

There is a 4th possibility: a bad SD module. I ordered a second module and substituted it into the same wiring and the example worked. This goes back to my premise that the driver could have more informative by responding more definitively (indirectly via new getError() method) saving me wasted time checking the SD card and continuous reformatting. This is not a gripe post. I would be happy to properly prepose the suggestion if someone will direct me to the appropriate place.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.