Go Down

Topic: Unable to Write to SD Card (Read 356 times) previous topic - next topic


Hey all, hoping for some help with SD card logging. I've been stuck on this for a few days and I don't really know how to proceed.


I'm using an Arduino Uno. I purchased a SD card module which didn't have level shifting I was sometimes able to write to the card but it was unreliable and I'm pretty sure I fried it.

I read that it was something to do with how power was sent to the card and it needed to snap quickly between on and off. (Sorry I'm probably butchering this terminology). I read that level shifting was the solution to this so I then ordered a 5-pack of micro sd card modules that have level shifting and a new 2gb micro SD card.

I only got the 5-pack because they were cheap together. I've tried all 5 and every time I get "Card Failure". I'm assuming that even if quality control was not super high, there's a pretty high likelihood that at least one of the 5 should work.

Formatting and Cards

  • I've tried the 2gb card and a 64gb card I had around.
  • I have tried formatting FAT16 and FAT32.
  • I've tried formatting with the SD Association's SDFormatter app and with diskutil on Mac.


I've re-wired it multiple times. I've tried two Arduino Uno's. And as I mentioned above, I did get the non-level-shifting card to write a couple times. So I'm fairly sure my wiring is correct.

  • SCLK at pin 13
  • MISO at pin 12
  • MOSI at pin 11
  • CS at pin 8
  • Ground at ground
  • I read that the SD cards are 3.3v but I've tried hooking up VCC to 3.3 and 5v.


This is the simplest version of the code that I had working before I fried the card with the first SD card module I got. It's printing "Card Failure" to the console so SD.begin isn't even working.

Code: [Select]

#include <SD.h>

//MOSI = Pin 11
//MISO = Pin 12
//SCLK = Pin 13
int CS_pin = 8;

void setup() {
  Serial.println("Initializing Card");
  pinMode(CS_pin, OUTPUT);
  digitalWrite(CS_pin, HIGH);
  // Initialize Card
  if (!SD.begin(CS_pin)) {
    Serial.println("Card Failure");
  Serial.println("Card Ready");
  // Write log file header
  File logFile = SD.open("brdlog.csv", FILE_WRITE);
  if (logFile) {
    logFile.println("Header 1, Header 2, Header 3, Header 4, Header 5");
    Serial.println("Header 1, Header 2, Header 3, Header 4, Header 5");
  } else {
    Serial.println("Couldn't open log file");

void loop() {
  // Write data to log file
  File logFile = SD.open("brdlog.csv", FILE_WRITE);
  if (logFile) {
    logFile.println("1, 2, 3, 4, 5");
    Serial.println("1, 2, 3, 4, 5");
  } else {
    Serial.println("Couldn't open log file");


I re-wired it again with new wires (into the same points) and it worked as expected. So strange, I never expected a wire to be bad.

Go Up