The ATMega 328 mounted on the Arduino UNO board has 512 bytes of EEPROM to store your data, without loosing them when you poweroff the Arduino UNO board,
This amount of data could seem to small, but for a large number of projects this is quite enough. If you have to store, for example, temperature data once a minute for 50 days you need to add some hardware.
If the Arduino system is working close to your PC, you can interface it using the serial line and then the PC will store data.
In some cases the Arduino system has to work far from other intelligent hardwares, for example imagine you want to monitorize the temperature in a forest, you have to put a large number of Arduino boards on the trees, then when you want, you have to take them back to retrieve info from them. In this case you can use a SD Card.
On the market, you can find a lot of SD CARD at low prices, no matter which one you want to use, their functionalities are the same, they only differ for starage capacity and access time. The interface is the same so you can change the card without change your project. In this tutorial I'm going to use an old 128 MB SD card from lexar, and then a newer 4GB SD card from Verbatim. I'm going to use two different cards only to show that you won't need different hardware to interface different cards.
Now let's start, playing with the SD card:
SD cards work with 3.3V level, they have 9 pins as shown below:
Bill Of Materials
To build a board to interface Arduino with a SDCard you need the following materials:
- A pinhead six pins long
- 3 3,3 Kohm resistors
- 3 1,8 Kohm resistors
- A small piece of stripboard
- A SD card connector (i'm using one from an old and broken memory card reader)
We are going to use the resistors to build the resistive dividers, so we can use the 3,3 V starting from the 5V I/O of Arduino.
Building the Board
You have to wire the circuit has shown in the following pictures.
Here you are a simple scheme to realize the circuit over a stripboard.
Let's Make a test to try that the board works.
Connect the pins on the board with the corresponding pins on the Arduino board, plug a SD card into the connector and power on your Arduino board.
Now on the Arduino IDE compile and upload the following code (it is available in File->Examples->SD->ReadWrite), and wait for the results: