Go Down

Topic: SD card not communicating with arduino (Read 170 times) previous topic - next topic

ilkogamer

Jan 13, 2021, 08:47 pm Last Edit: Jan 14, 2021, 03:17 pm by ilkogamer
Hey guys I am working on a simple project but this SD card won't communicate with the arduino. I tried and checked my wiring and code multiple times, i have not found any mistakes yet the serial monitor prints SD fail every time. I use Arduino Uno R3 + WiFi  and SD card module from geeetech.com.
This is my code:

#include "SD.h"
#define SD_ChipSelectPin 10
#include "SPI.h"

void setup()
{

  Serial.begin(9600);
  if (!SD.begin(SD_ChipSelectPin))
  {
    Serial.println("SD fail");
    return;
  }
}

void loop()
{
 // put your main code here, to run repeatedly:
}


The image linked below is my wiring except the resistor.
Also this is my first post so if I have anything that could be improved just let me know.
Thank you for all your answers.


dannable

I don't know which version of the SD library you are using, but I've never included SPI.h as well.

Could you take a moment to read the sticky post at the top of this section about how to use the forum?

ilkogamer

Do you think the SPI library is causing it?

dannable

What happens when you remove the line #include "SPI.h"?

ilkogamer


markd833

Just a thought, but what happens if you change setup() to:
Code: [Select]
void setup()
{

  Serial.begin(9600);
  if (!SD.begin())
  {
    Serial.println("SD fail");
    return;
  }
}

The SD library docs say that it defaults to using pin 10.

dannable

If that doesn't work, try setting the CS pin to output before SD.begin:

Code: [Select]

  pinMode(SD_ChipSelectPin, OUTPUT);

ShermanP

I'd suggest running one of the examples from the SD library, such as CardInfo, and see if that works.  If it doesn't, then either the CS pin is wrong, or your wiring is wrong.  Your wiring picture is too low-res for me to see what's going on.

Go Up