Newbie problem with SD card, need guidance


Basically I want to know if I am headed in the right direction or am I screwing up right off the bat?

I bought 2 SD card reader modules from ebay

I connected the reader as per the diagram on the seller’s product page. (see attached pic)

I understand that it is using the resistors as a voltage divider to supply 3.3V to the inputs of the SD card. I read on some articles that you need to supply 3.3 V inputs (MOSI, CS, CLK) or you can burn your card.
I measured the voltage level going into the card on some of those pins and it is 3.3V
The diagram says to use 3.3k with 1.8k on MOSI and CS, 1k with 2.2k with SCK. I did not have exactly those so I used 1.5k and 3k everywhere which gives me the almost exact 3.3V as mentionned above.

I am using pin 10 for slave select, reflected in my code.
I know some people have used a level shifter instead for this in certain articles.

The setup section fails on init, I tried 2 cards on it.
I checked my wiring, and I find nothing wrong with it so far.
I still have some troubleshooting to do, but want to know if this setup has a shot at working or not.

#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SD.h>

#define I2C_ADDR 0x27
#define En_Pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7

int BTN1_pin = 4;
int LED_1_pin = 13;
int SD_SS_pin = 10;

byte BTN_Val, PREV_BTN_Val = LOW;
int num_pressed=0;

File myFile;

LiquidCrystal_I2C lcd (I2C_ADDR, En_Pin, Rw_pin, Rs_pin, D4_pin, D5_pin, D6_pin, D7_pin);
void setup()
  pinMode(BTN1_pin, INPUT);
  pinMode(LED_1_pin, OUTPUT);
  digitalWrite(LED_1_pin, LOW);
  lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
  lcd.print("SD Test");
  //lcd.print("Button to work");
  Serial.print("Initializing SD card...");
  pinMode(10, OUTPUT);
  if (!SD.begin(SD_SS_pin)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");  
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
  myFile ="test.txt", FILE_WRITE);
  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  // re-open the file for reading:
  myFile ="test.txt");
  if (myFile) {
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    // close the file:
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");




void loop()
  if ( BTN_Val == HIGH && PREV_BTN_Val == LOW )
    lcd.print("Send #");

     // tx msg
    //startM = millis();
  PREV_BTN_Val = BTN_Val;

Does the SD module have a 3.3V regulator on it for power?
(I can't open the link from here)

Yes it does have a 3.3V regulator, but that is for its operating voltage as far as I understand, but the inputs coming from the MCU are 5V and those, the card does not regulate. This is what I read so far is the issue.

Is the SD card formatted?

For the Arduino library we'll be discussing, and nearly every other SD library, the card must be formatted FAT16 or FAT32.


Found one problem, I could not get it to work with my arduino mini. Tried my uno and a 128m card and it worked fine, but a 1gig sd micro card with sd adapter never worked.

Based on the good ladyada article, I need a logic level converter to get it to work properly I think. That or get a better card reader. What do you expect for a 2$ sd card reader module? Resistor dividers are clearly nfot ideal for that setup according to the article.

Adafruit's reader has a logic level converter.

Is looking at it this way good?: as long as you know exactly what you are getting, ebay is fine?

I never buy those cheap ones. What if it stops working when you're saving important data (like temperature of your bathroom :wink: )

There are many resistors on the board. I can't see their markings but suspect they each connect to an SPI pin to prevent damage. If you want reliable results, use level shifters. Adafruit sells an sd module for like $15 (I know it's expensive). I use their sd logger shields. Didn't seem to have failed yet. I have dozen of them.

My understanding is that the adafruit one does not need a level shifters as they are built in.

Are you saying that mine will be fine with some level shifters?

I will be more careful about ebay stuff now that I am starting to learn. Easy to make those mistakes if you don’t know :slight_smile:

Right, adafruit modules have level shifters. Yours doesn't have. There's no circuit diagram so I can't say for sure what's on your board. I guess if you use a level shifter it will work fine.