Project:Arduino SD Card

From Nottinghack Wiki
(Redirected from Arduino SD Card)
Jump to: navigation, search

I'd like a nice way of storing masses of data for easy access from the Arduino. I'd also like a nice way to log data from the Arduino. SD card shields are nice but kinda pricey. I think I can do it on the cheap so I'm gonna have a go.

Ghetto SD Card 101

The ubiquitous SD (Secure Digital) card is an evolution of the earlier MMC (MultiMedia Card) and shares the same middle 7 pins which happen to be about 0.1" apart. Micro SD card adapters are about 10p so there's no point in not destroying one int he name of science! You can just solder a strip of pins directly onto the 7 contacts to make a cheap Micro-SD card holder. I used angled headers so I can hotmelt glue the adapter down to make it more sturdy for card insertion and removal.

(TODO: photos here!)

On the SD card there's a tiny microcontroller that does all the magic of saving data to flash memory and retrieving it when asked. You can talk to an SD card in a number of ways but here we will use the simplest: the standard Serial Peripheral Interface bus that is provided for free in our Arduino and is very well supported. We will need to put the SD card into SPI mode. This and the other variables of operation will be handled for us with a handy SD library that ships with the Arduino IDE: http://arduino.cc/en/Reference/SD. An SD card requires a supply voltage of between 2.7v to 3.6v and could draw around 80 mA of current. Unfortunately we won't be able to use the Arduino's 5v logic directly but we can make use of the 3.3v provided on a genuine Arduino Duemilanove or UNO (from the FTDI chip or equivalent). I also want to use this SD card on a Xino that has no 3.3v rail but I'll burn that bridge when I get to it!

Some initial thoughts: -

  • we talk to the SD card with SPI on digital pins 10, 11, 12, and 13 with Arduino as master and bitbanging the clock
  • I see this 6 resistor SD card adapter technique: http://didier.longueville.free.fr/arduinoos/?p=51
  • as well as the voltage divider technique to get 3.3v signals, I've seen that some of the cheap Chinese SD card adapters have an on-board 3.3v regulator and use 10k pullups to the 3.3v line - interesting but I'm not savvy enough to "just know" what's going on here!
  • I want my applications to be safe for card removal whilst powered up. I think that may be a feature of SD cards in general so it may just work with the SD library

OK, a quick voltage divider for the 3.3v logic using 1.8k and 3.3k resistors

  • 3.3k is Orange, orange, red
  • 1.8k is Brown, grey, red
  • hmm, I don't have either of these to hand right now! To the Hackspace!
 pin 1: CS, SS
 pin 2: DATAIN, MOSI
 pin 3: VSS1, GND
 pin 4: VDD, 3.3v VCC
 pin 5: CLK, SCK
 pin 6: VSS2, not connected
 pin 7: DATAOUT, MISO