Instructables

Arduino DIY SD Card Logging Shield

Featured
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.
thegrendel (author) 1 month 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 month 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 month 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 month 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?

anv3 months ago
You can findSD shields for $1.50. In example: http://www.ebay.es/itm/330809484080
thegrendel (author)  anv3 months ago
Yes, on eBay / Spain. And this particular vendor has had
payment problems lately.
anv thegrendel3 months ago
I am in Spain, and boughth many things on ebay + paypal. Never had problems. Chinese vendors are very concerned about the paypal voting.
mrmonteith9 months 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)  mrmonteith9 months 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) 1 year 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.vlad1 year 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.vlad1 year ago
Thanks, Vlad. Everyone who constructs this encourages the
next one to make it. I appreciate your comments.
sompost1 year 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)  sompost1 year 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.
n3mi1 year 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)  n3mi1 year 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!"
n3mi1 year 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)  n3mi1 year 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.
How do you get free shipping from China when there are customs fees?
thegrendel (author)  Strider30191 year 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)  Strider30191 year 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_bloke1 year 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_bloke1 year 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.
I realy dont want to nitpick, but it does not. That is the same as ordering all the parts, let them lie idle for a week and then build the thing saying it is free 'because you had all the parts laying around'
The cost to the project, if using a protio "laying around" would be indirect SO basically THIS prioject would be cheaper assuming the proto (as an example) was purchased for another reason and never used the outlay for THIS project would be less...

SO although the cost is still the same with the above considerd the outlay for THIS project is less so we can split hairs all day seeing as this is so VERY important?--- or is it? So VAUE =$14 and expenditure in this case = $8+/-

GREAT instructable!
Sounds like politician-style accounting.
naeger1 year ago
Hi, thanks for this great instructable! Could you elaborate on the "not-compatible with SDHC cards" a bit please? I have several SD cards lying around here but they are all SDHC. What would have to be changed to reduce the noise/delays you mention? Is it somehow possible to make it work with SDHC cards? What about the ready-made SD shields, do they work with SDHC cards? Thanks a lot!
Chris
thegrendel (author)  naeger1 year ago
As I understand it, the difficulty with SDHC cards is that they
require narrower and more precise timing on the data lines.
This can cause problems with haywired leads, such as you find
in this project. And the ATMega 328 chip itself may not be fast
enough to interface with these cards.

I suggest that you find references on the Net on this, as I certainly
don't represent myself as being very knowledgeable about it.
OK. Thanks for the clarification. As far as I have seen even the commercial SD card shields don't work with anything above 2GB. See the comments in https://www.sparkfun.com/products/9802. What a pity I don't have the old SD cards anymore....
http://www.dealextreme.com/p/2gb-micro-tf-card-with-sd-card-adapter-black-128032?item=2

$3.80 for 2GB with free shipping
florinc naeger1 year ago
My WiseClock 4 (http://timewitharduino.blogspot.ca/), using ATmega1284, works with SDHC as well. It's a matter of software, not hardware.
naeger florinc1 year ago
Thanks for the hint! I will have a look into your project! ... Chris
thegrendel (author)  naeger1 year ago
You can still find 1 and 2 GB SD cards on eBay and a few
other places, such as All Electronics. They typically sell in
the range of $3 - $5 each.
naeger1 year ago
OK, one more question :) ... I read the description on several of the SD card modules like for example: http://www.ebay.com/itm/SD-Card-Module-Slot-Socket-Reader-For-Arduino-ARM-MCU-Read-And-Write-/170817952203?pt=LH_DefaultDomain_0&hash=item27c58b19cb ... it clearly states: "Support 5V/3.3V input" no mentioning of the necessity to shift down the logic input level from 5V to 3.3V! If you look closely at the picture there is a resistor connected between each data pin and the SD card holder. Wouldn't this already do the trick (provided that the resistor has a value so that 1.7V fall off to the resistor and the remaining 3.3V fall off to the SD card)? Wouldn't this also fix the problem with noise and allow SDHC cards? ... Have you ever tried to directly wire up the module without the level shifter (and measure with a volt meter how many volts reach the sd card slot)? Thanks again for answering my questions :)
dahas naeger1 year ago
That 4 resistors is for PullUP the line of the SD-Card to dont get garbage from wire.
As they say "Support 5V/3.3V input" is more like power supply not the real data line input.
Is like you buy a toaster who say will work at 110V or 220V that's the input for him but internaly he can run on other power. Sorry i did that mistake few times looking at 5V/3.3V the LC Studio SD-CARD is one of my mistake but can be easy fix.
I have Polux SD-Card who have lvl shifter who work with uSD-card but in fact never got it working (means to can read any of my cards) he will work but not with my sdcard.
thegrendel (author)  dahas1 year ago
I agree with you, dahas, these are pullup resistors,
and they do no level-shifting on the data lines.
And, I'll warn again against applying +5v to the
SD card inputs.
Ah, OK, thanks a lot for the clarification on the pull up resistors! The explicit "supports 3.3V and 5V" did confuse me. But you are right. Thank you for your help!
Pro

Get More Out of Instructables

Already have an Account?

close

PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!