I connect the SD Card module as shown in the diagram with the chip select connected to the default pin 4 (I have also tried setting the chip select to pin 10). I’m using the 3.3V supply from the UNO to power the SD Card module.
I’m using version 1.2.4 of the SD library and running the CardInfo example on the Arduino IDE and I get the following error message.
Initializing SD card...Wiring is correct and a card is present.
Card type: SDHC
Could not find FAT16/FAT32 partition.
Make sure you've formatted the card
I’ve formatted the card and after reading some posts online, ensured that the card is FAT32 with an MBR partition table. I’ve tried formatting using different applications including the primary suggested one by SD Association (SD Memory Card Formatter | SD Association). This shows the SD card properties after formatting with the SD Association program.
Have you checked the cluster size? The guide for that example suggests this guide on calculating the right values to use during formatting, but I’m not sure how that relates to the SD library. Try 512 bytes and let us know how that goes.
Thanks James, I was using the default cluster size which for my 32GB SD card was 16KB.
I changed to 512 bytes (see image below) but I still get the exact same error. I had to use GNU parted to create the partition given the cluster size, the SD card association didn’t allow me to specify the cluster size.
I did some further digging into the error and found that it comes from the SPI communication. I’ve put some pictures of the execution sequence below. The return from the cardCommand function is what causes the error.
I’ve found a temporary solution. In the SD library as shown below I added a small delay which must be greater than or equal to 6ms and then I get the expected output of the CardInfo example.
I don’t understand why though, it seems that the SPI is busy and waiting for 6ms is enough to wait this out. But this should be taken care of the waitNotBusy function.