SD-card on Arduino

There are Arduino shields (like the modern Ethernet shield) that allow you to attach an SD card to your arduino. However if you are building a project that just needs a way to store data, then such a shield might be overkill.
It is possible to directly attacht an SD card to an Arduino and even then there is a cheap way and a more expensive elegant way.
The elegant way is to buy an SD card holder to solder on a circuitboard. These however come at a price.
Another way is to use the SD to microSD converter  that comes with most micro SD cards and use that one to solder to the circuitboard. Obviously that has a limitation as one then only can use micro SD cards and not the regular size SD cards.

SD card

The circuit in fact is pretty easy. other than ground and a powersupply line (3.3 V) you only need to connect 4 lines, 3 of which need a simple level adapter.

The Arduino SD library is very easy to use with easy to follow examples and it supports FAT16 and FAT32 file systems but note that it only supports one open file at a time and can only use short 8.3 file names.

For easy connection on a circuitboard consider soldering the pins to an angled header.

The resistors R1 – R7 can also be replaced by a 10k / 15k set and I have seen 1k8 and 3k3.
A better solution ofcourse would be to use a leveladaptor like a HEF4050 or an 74HC125 (such as in Lady Ada’s design)

With regard to Libraries that will work with this setup: There are 3 main libraries withint the Arduino development sphere:’SD’, ‘SDFat’ and ‘SDuFat’. These all should work. Just keep in mind that some of their examples still need the SSI pin (The chipselect) corrected because some boards will use pin 10, others will use pin 8 or pin 4.

If you are building this on breadboard and your connections might be a bit long, you may expect bus problems that will show up by e.g. problems with the initialization of the card. If that is the case. Try the example program of the SDuFat, as this library is one of the slowest. If that works, and the other library programs will still show problems, then at least you know that your card and connections are OK.

Then load the example sketch ‘SDinfo’  and find the line:

if (!card.init(SPI_HALF_SPEED, SdChipSelect)) {

change that to:

if (!card.init(SPI_SIXTEENTH_SPEED, SdChipSelect)) {


if (!card.init(SPI_QUARTER_SPEED, SdChipSelect)) {

and see if that will work. If it does, then your set up is OK but your wires are probably too long.


See also:

One thought on “SD-card on Arduino

Comments are closed.