loading
Picture of Arduino DIY SD Card Logging Shield
module-bottom.jpg
Ready-made SD card logging shields for the Arduino typically cost in
the range of $15 - $25. This is quite reasonable, but we might save a
couple of bucks if we make our own. Not to mention all the fun in building it.


Forget about soldering wires to a bare SD card socket. It's just too much
hassle, and for about the same price as a socket you can get a breakout
board. The cheapest SD card breakout board seems to be the notorious
LC Studio model. You can locate them for a bit more than $2 on eBay,
and this includes free shipping all the way from from China.
Do a search for "Arduino SD Card" and up pop quite a few of of these babies.

 
Remove these adsRemove these ads by Signing Up

Step 1: Materials Needed

Picture of Materials Needed
4050.chip.jpg
16-pin-ic-socket.jpg
stackable-headers.jpg

LC Studio SD card breakout board           $2.00 - $3.00 (on eBay)
4050 non-inverting hex buffer                    $1.12   (Radio Shack cat. # 55050840)
16-pin IC socket                                            $0.25
blank protoshield                                          $4.00 - $6.00
set of stackable headers                             $1.50   [2x8 and 2x6]
1 x 8-pin stackable header                         $0.50
1 x 8-pin male header (non-stackable)    $0.50
2 x 8-pin male headers                               $1.00
2 x 6-pin male header                                 $1.00
1 mini LED                                                     $0.25
1 mini pushbutton switch                            $0.25
1 470 ohm resistor                                       $0.25
hookup wire
solder
SD card (the older low-density 1 or 2 GB kind)



Looks like we've spent $14+ already, almost the cost of a ready-made SD
card shield. But, hopefully you can find or scavenge at least a couple
of the above components in your junk box, from a previous project,
or from a broken gadget or two. If you're halfway serious about DIY
Arduino projects, then you already have a couple of protoshield boards
and header sets stockpiled.

Step 2: The breakout board pins

Picture of The breakout board pins
lc-card-pins.02.png
There are reports that a few of the LC Studio units are defective
(well, whaddya expect for $2?), so the first thing to do is check for shorts.
Use the ohms function of your multimeter to make sure that the MISO and
MOSI pins are not shorted to ground.


The male header pins on the LC Studio board are
clearly marked on the board (see illustrations).

Each pin in the top row connects across to the corresponding pin
in the bottom row, so you can use either pin in any given two-pin column.

These breakout boards are quite nice, especially at the price.
They include a 3.3v regulator chip on-board, so we can supply +5v
at the +5v input and leave the +3.3v input disconnected. Unfortunately,
+5v inputs are not dropped to +3.3v, so we'll have to make some provision
for this ourselves if we don't wish to damage the SD cards.
More on this in the next step.

Step 3: Using a level shifter

Picture of Using a level shifter
Constructing the project looks pretty simple at first glance.
Just connect power and ground, and the four signal pins.
It's only a matter of figuring out which four (digital) Arduino pins
to connect to, right? Well, yes, but there's a complication.

SD cards, like many recent electronic devices, operate on a 3.3 volt logic
level. But, most Arduinos output 5 volts on their digital logic outputs for ON.
A direct connection of 5v to an SD card could fry it. So, what do we do?

The best solution is something called a level shifter. Essentially, this means
putting 5v on the input of a non-inverting buffer and getting 3.3v from the output.
Shifting the voltage level, get it?
But just how is this magic accomplished?
One way is to use a CMOS hex buffer IC,
here a 4050, and power it (pin 1, Vdd) at 3.3v.
Put 5v on the input of one of the gates,
and you get 3.3v on the output of that particular
buffer. For example, with 3.3 v on pin 1 (Vdd) and
pin 8 connected to ground, a 5v logic level on
input pin 14 (gate 6) results in 3.3v on output pin 15.

Step 4: Populating the protoshield (1)

Picture of Populating the protoshield (1)
Now, let's build the shield.

We'll use a blank protoshield PC board. A number of vendors sell these,
with prices ranging from $4 and up.

Install the reset switch, LED(s), resistor(s), and male and female headers in
the appropriate places on the protoshield board. This is probably
not the first shield you've built, so I won't go into too much detail.

The headers are next

Step 5: Populating the protoshield (2)

Picture of Populating the protoshield (2)
inst-headers-3.jpg
Installing-the-headers.jpg
inst-headers-2.jpg
Populating-the-component-side.jpg
It's time to position and align the headers. This can be tricky. Use an
already-built shield, and slip the female headers over the bottom rows
of the header pins, then flip the assembly over and position it on your
protoshield. Solder the protruding pins underneath the protoshield,
on the solder side of the board.


Install the male headers, but this time use an Arduino board to align them.


With the standards components soldered on the protoshield, we're
ready to install the SD card breakout board.

Step 6: Installing the breakout board

Picture of Installing the breakout board
ic_socket.jpg
lc-position-headers.jpg
upside-down.jpg
Now, we'll mount the SD card breakout board and level-shifter IC on the
protoshield. First, position and solder the IC socket.



Next, we'll create a plugin "socket" for the LC Studios board.
This will consist of two adjoining parallel rows of female headers.

Position the set of two 8-pin female headers (1 standard and 1 stackable)
atop the pins on the LC Studios board. This will set the alignment and
spacing. (See next-to-last photo.) Note that the we are using the
stackable header because it provides a longer pin surface to attach
wires to on the solder side of the board. It's also convenient to be able
to bend the long pins and attach them directly to the ground and +5v busses,
as necessary. Whether you place the stackable header in front or in back
doesn't matter -- whatever works better for you.


Flip over the LC Studios board and place it upside-down on the
protoshield so the bottom pins of the headers go through to the solder side
in the desired position (last photo).


We'll connect and solder the pins according to the hookup diagrams
in the next step.

Step 7: Connecting the pins of the breakout board

Picture of Connecting the pins of the breakout board
lcstudio.schematic.png
sdcard_schem.02.png
underneath01.jpg
underneath02.jpg
underneath03.jpg
Continue by hooking up the wiring to/from the LC Studios board.

LC board                4050               Arduino
-------------                -------               ----------
Gnd.                        [8] Gnd.           Gnd.
                                 [1] 3.3v
+5v                                                  +5v
+3.3v not connected*

CS                            [15]
                                  [14]                 D4

MOSI                        [12]
                                  [11]                  D11

SCK                          [10]
                                   [9]                   D13

MISO                                                 D12



These are the standard connections used by most existing sketches
which read/write SD cards. We'll do some of the wiring/soldering
on the underside, the solder side of the protoboard.
Now we see why stackable headers, with their long pins, are useful.
They provide nice attachment points for hooking on and soldering wires.


Carefully examine the wiring and our soldering for shorts and solder
bridges. Particularlly check for a short between the +5v and ground busses.
Using the ohms function of a multimeter is helpful.

Step 8: Plugging in the components

With the wiring and soldering complete, we'll carefully plug in the 4050
IC and the LC Studios board. Make sure the orientation of the 4050
is correct.

We're ready for the "smoke test." Plug the completed board into an
Arduino, apply power . . . and pray.


Pictured is the completed shield, with LC Studios board, plugged into our
very own Hackduino (http://www.instructables.com/id/Haywired-Hackduino/).


No smoke? Didn't burn anything out? Great! Switch off the power, then
insert an SD card -- the "obsolete" 1 or 2 GB variety. The newer high-density
4 GB and up varieties may not work.

Step 9: The final test

Picture of The final test
Let's see if it works. Connect up the Arduino-with-shield
assembly to our laptop with the USB connector cable and fire up the Arduino IDE.
Load the Examples -> SD -> Cardinfo sketch. Compile and upload it.
Again, a little prayer wouldn't hurt.

Success!

Step 10: Notes

Picture of Notes
  • The LC board has a 5v -> 3.3v regulator IC.
  • That's why the 3.3v pin is not connected.
  • The MISO pin on the LC board is an output and goes directly to the
  • Arduino, so no level shifting is necessary.
  • The meanings of the pin designations:
  • CS   = Chip Select
  • MOSI = Master Out, Slave In
  • MISO = Master In,  Slave Out
  • SCK  = Slave Clock
  •  
  • Really, folks, it's not about slavery or S&M. A master is the
  • controlling device, and the slave is the device getting signals
  • from the master. Sorry about the unsettling connotations, but it's
  • all engineering jargon, that is,  geekspeak, so to speak.
  • As noted in a previous step, higher-capacity SD cards may not work because
  • our point-to-point wiring might add noise and delays to the signal lines.
  • Try one of your old 1 or 2 GB cards.
  • Almost all the examples that come with the Arduino SD library work
  • with our DIY shield. Only the "SD Card read/write" example fails,
  • possibly due to timing considerations because of point-to-point
  • wiring.
1-40 of 55Next »
sompost2 years ago
Hi, first of all this is a great project and exactly what I was looking for!

Now my question: can I power the level shifting circuit (CD4050) from the regulator on the SD breakout board? I don't mind soldering a wire to the board if I can avoid a separate regulator for the level shifter.

Thanks!
thegrendel (author)  sompost2 years ago
Thank you for the praise.

As for getting the 3.3 v Vcc from the SD breakout board,
I honestly don't know. Try it and see if it works, In any case,
please leave a follow-up comment here giving the result of
your experiment.

Possible problems are that the regulator on the SD board
might not be up to spec, and that you might have some sort
of ground loop. I don't see that it would damage anything
even if it didn't work.
I'm using a cheap $2 SD card reader, the sort that doesn't work because of a missing ground link. Having fixed that, I was indeed able to use the 3.3V from the on-board voltage regulator (there's a dedicated pin). Yes!!

My level shifter uses (schottky-)diodes for the 5V to 3.3V signals, and a BSS138 for the 3.3V to 5V signal. It seemed simpler than using a 4050.

Thanks again
AravindR38 months ago

there is problem in writing the data into the file???? i dont know why????????

thegrendel (author)  AravindR38 months ago
I need more details. There are a couple of possible causes.
High capacity SD cards (> 2 GB) do not work.
You may need to lower the write speed.
davidbarcomb8 months ago

Useful project. Thank you

isnt it even easier to just use a 3.3V arduino board (like http://goo.gl/4Er5Bw) from the beginning?

thegrendel (author)  anders_malmberg1 year ago

Can I change the pins? Im building a project uncluding the card-reader and a RFID transmitter and some of the pins is already taken.

thegrendel (author)  anders_malmberg1 year ago

I'm not sure. Certain of the pins, such as SCK and MOSI/MISO seem to be dedicated. Could you change the RFID pins?

I noticed now that I have to change to a different card-reader. I tried to connect a openlog shield (https://www.sparkfun.com/products/9530) witch is using TX and RX for communication and that seems to work.

can I just breadboard this and jump it straight to the arduino uno from the breakout board?

thegrendel (author)  flubbersaurus1 year ago
It would probably work if the jumper wires are kept short.
Remember -- these are signal lines.
NV1T1 year ago

OBTW, the +3V3 pin on my LC Studio board (which appears to be identical to the one pictured in the Instructable) is an OUTPUT from the on-board 3V3 regulator. When you apply +5V to the corresponding input pin, +3V3 appears.. My adapter is not going to be a proper shield; instead, I'm building it on a small hunk of perfboard and using DIP headers and a short piece of ribbon cable to connect it to the 'duino. (A shield wouldn't work for me anyway, as I'm using a SparkFun Arduino Pro Mini board, which is about the size of a postage stamp.)

NV1T1 year ago

You can also use a 74LVC245 instead of a CD4050 if you have one laying around (as I do).

thegrendel (author)  NV1T1 year ago
Yes, indeed. There are a number of suitable level-shifter buffer chips.
thegrendel (author) 1 year ago
Another alternative is one of the newer generation of switchable
5v/3.3v Arduinos. Or a Hackduino powered at 3.3v. See one of
my other Instructables on my experience of building a couple
of these babies.
nblyumberg1 year ago

Can you elaborate a little bit on the last paragraph? It's a little confusing with regards to the 5v input on the SD card module. First you say that we can supply +5v at the +5v input and that the module includes a 3.3v regulator but then you state that the +5v input is not dropped to 3.3v? So is it safe or not to connect the +5v from the Arduino over to the +5v input on the module without any additional logic?

thegrendel (author)  nblyumberg1 year ago
Feeding the data lines of an SD card with 5v logic will likely work.
For a while. But, you do so at your own risk. You may burn out
the card. Danger!
Thank you for your reply! I'll add a logic shifter to the project.
thegrendel (author)  nblyumberg1 year ago
5v to power the breakout board is okay, as the on-board regulator
will drop it to 3.3v. But, 5v on the logic lines is NOT okay, so that's why
you need the level shifters.

Interesting, I wired up the breakout board without level shifting the signal lines after I posted the comment and was able to write and read from an old 2GB SandDisk SD card. What are the side effects of not adding the level shifting logic on the signal lines? Data corruption or the SD card will die after short use?

anv1 year ago
You can findSD shields for $1.50. In example: http://www.ebay.es/itm/330809484080
thegrendel (author)  anv1 year ago
Yes, on eBay / Spain. And this particular vendor has had
payment problems lately.
anv thegrendel1 year ago
I am in Spain, and boughth many things on ebay + paypal. Never had problems. Chinese vendors are very concerned about the paypal voting.
mrmonteith2 years ago
I was wondering about that. I found item #221242530114 on ebay and several others that stated specifically they support 3.3 or 5v levels on inputs as well as supply voltage. Guess it depends on the device. I wish they would supply data sheets.
thegrendel (author)  mrmonteith2 years ago
Data sheets? Data sheets?
We don' need no steenkin' data sheets.

If they supplied data sheets and docs, then they wouldn't be selling
these breakout boards for a coupla bucks, shipping included. If you want docs and tech support, then buy the same products for about $10 more from Adafruit or Sparkfun.
thegrendel (author) 2 years ago
If you've been having problems with this and other SD card shields,
try slowing down the read speed. To do this, you'll need to alter
SD card and/or FAT library files. I won't go into detail on this, since
mistakes can have bad consequences, so don't try it unless you're
confident that you know what you're doing.

A hint (you'll want HALF_SPEED or less):

Sd2Card.h:uint8_t const SPI_FULL_SPEED = 0;
Sd2Card.h:uint8_t const SPI_HALF_SPEED = 1;
Sd2Card.h:uint8_t const SPI_QUARTER_SPEED = 2;
Sd2Card.h:uint8_t const SPI_EIGHTH_SPEED = 3;
Sd2Card.h:uint8_t const SPI_SIXTEENTH_SPEED = 4;
Sd2Card.h: bool init(uint8_t sckRateID = SPI_FULL_SPEED,
SdFat.h: uint8_t sckRateID = SPI_FULL_SPEED) {
SdFat.h: bool init(uint8_t sckRateID = SPI_FULL_SPEED,
SdFatmainpage.h:card.init(SPI_HALF_SPEED) to initialize the SD card.

r.vlad2 years ago
Great instructable , I've made it on protoboard and it's working good with a 4GB SDHC card. I had one of those LC Studio SD breakout's around and didn't know how to use it, this was exactly what I needed, only needed to buy an CD4050 for 0.5$.
thegrendel (author)  r.vlad2 years ago
Thanks, Vlad. Everyone who constructs this encourages the
next one to make it. I appreciate your comments.
n3mi2 years ago
Hi! I did it a little bit differently and it worked so I'll just share it. I used this breakout wich I assume is the same :
http://dx.com/p/sd-card-reading-writing-module-for-arduino-deep-blue-142121
If you use the 5v input at the breakout board, most of the pins that go to the sd card will get regulated to 3.3v, that's good for pins 1, 3, 6, 7, 9 and 10 (1 being the one next to c4). So in order to regulate pins that belong to CS, MOSI and SCK I used three IRU1050-33 which are fixed 3.3V regulators (definitely overkill but I did not have a 4050 in my bag). It worked like a charm and even with 8gb SD =). Hope it's good info.
thegrendel (author)  n3mi2 years ago
Yes. Alternate ways of getting to the same place
are always interesting.

As Ruddy Kipling said,
"There are nine and sixty ways
of constructing tribal lays,
And every single one of them is right!"
n3mi2 years ago
great article!, one question though, is there a reason to not use the 3.3v output from the arduino board as the input to the 3.3v pin at the sd breakout board instead of using the level shifter?
thegrendel (author)  n3mi2 years ago
Using the 3.3v from the Arduino board would probably work,
but note that the 5v source on the board is good for 500 ma,
whereas the 3.3v regulator can only output 100 ma max.
Strider30192 years ago
How do you get free shipping from China when there are customs fees?
thegrendel (author)  Strider30192 years ago
The seller absorbs the shipping and custom fees.
Look for eBay listings that say "free shipping."
Isn't it about $25 minimum on a shipment? How could that be absorbed on a low cost item?
thegrendel (author)  Strider30192 years ago
I don't know about any minimum, and I've quite often ordered items
on eBay for as low as $1, total, with free shipping from China.
diy_bloke2 years ago
great info. nevertheless..... the fact that one might already have a few protoboards afcourse does not really alter the price of this :-)
thegrendel (author)  diy_bloke2 years ago
Not having to buy a protoboard knocks $5 or $6 off the
cost of building this. All the same, as I pointed out,
the purpose of the project is not so much to save money
as it is educational (and recreational). And, yes,
thank you for the compliment.
1-40 of 55Next »