Go Down

Topic: SdFat for Due posted (Read 71234 times) previous topic - next topic


Good morning from Italy guys. There's no way to make it work. Can someone suggest me a tested "style" of micro SD adapter on Arduino due?


May 13, 2017, 03:36 am Last Edit: May 13, 2017, 11:43 am by ninja2
I doubt your problem is hardware and any 3V3 SD card will work if wired properly, and the sketch is written correctly. But to your question:

I have successfuly run a Sparkfun microSD shield on my Due but I had to do a little re-wiring on the shield as pins 11,12,13 do not support SPI on Due:

1) fold up pins 11,12,13 so they are not connected to Due
2) cut out shield above ICSP header so it is accessible from above shield
3) solder solid insulated wires (about 6cm long) into the plated through holes for pins 11,12,13. Strip the other ends and insert into ICSP as follows:
- pin D11 to ICSP pin 4 (MOSI)
- pin D12 to ICSP pin 1 (MISO)
- pin D13 to ICSP pin 3 (SCK)

(see photo attached)

My sketch is quite complex, but I've extracted & simplified the key parts that making the SD work for me:

Code: [Select]
#define CS_pin     8                  // Sparkfun microSD shield
#include <SPI.h>
#include <SdFat.h>
SdFat SD;
char logFileName[10] = "test1.csv";          // add 1 char for NULL terminator
void setup() {
  if (!SD.begin(CS_pin,SPI_FULL_SPEED)) {  // check SD is present & set to full speed
    Serial.println("[SD FAIL] STOP");            // tell the world if bad
    while(1) {}                                        // and stop forever

  // SD is working OK so write a few data rows to it...
  logfile = SD.open(logFileName,FILE_WRITE);

void loop() {
// other stuff here


sorry man, tried everything... now i'm trying to directly interface to an sd card but it doesn't work. May I try with something like soft spi? How can i do that?


You've already been given a working solution. If you're not prepared to post your current code and details of your chosen hardware and wiring (e.g. diagram) then I can't help you


My friend there is only one possible wiring and the code is the example of both built in sd library and sdfat library as well. I tried 3 different modules everything is working on avrs. Is there any pin i should set as output? Is there something that has to be pulled low? The wiring is perfect, i'm getting mad at it


What is the suggested SDCard Lib for the Arduino DUE ?


the ordinary SdFat library works fine, same as for MEGA

(see my question at post #62 and answers following)


May 20, 2018, 02:40 pm Last Edit: May 20, 2018, 02:44 pm by redou95100
hello guys,

im trying to connect my sd card directly to my arduino due's spi header (like this http://www.instructables.com/id/Arduino-DUE-SD-Card/) but it doesn't work. I checked many times the wires. Here is a picture of what i did https://ibb.co/h0K938 . I tried the exemple cardinfo of the SD lib and i got init failed.

help please..


Go Up