How to Handle SD Card with Arduino

Reading or writing in SD Card with Arduino is fairly easy to do. Internally, Arduino already provides a specific library for interacting with SD Card, called 'SD.h' library. This library has capability to read various types of SD cards, such as SD card, mini SD and micro SD. In terms of hardware, you'll need an SD card reader module or a shield or a SD card reader embedded in another shield. For example SD card reader which is embedded in another example is an Ethernet shield. You will found SD card (micro SD) slot in this shield.  So, if you buy an Ethernet shield you will also got another advantage, i.e. read and write micro SD card as an extra storage for your system.

As an initial experiment, please prepare Arduino board (ex: Uno or any other type), Ethernet shield and of course, a micro SD card. If you don’t have Ethernet shield, you can use an individual dedicated SD card module that is widely available in the market.

Arduino - SD Card Sketch Handle

Next, open example sketch 'CardInfo' through File-Examples-SD-CardInfo menu in Arduino IDE (Integrated Development Environment) software. You can download it in if you don’t have the software. Upload the sketch to your Arduino board immediately to get knowledge how to interfacing SD card with Arduino.

Next, open Serial Monitor window from Tools-Serial Monitor menu in the IDE. There should have been a display like in the picture below

Easy enough, right? Only in less than 5 minutes you can read some info from your micro SD card.
In closing, basically a module/SD Card reader (shield) to read using intermediary communication protocol synchronous called SPI (Serial Peripheral Interface). They require at least three pins to communicate with their pairing devices, i.e. MISO, MOSI, and CLK. This is why in the sketch related to SD Card access, always include 'SPI.h' library besides 'SD.h' library. And how lucky Arduino users they are, because Arduino eco-system provided a ready-made library for any purposes. Imagine if you had to write it from the scratch. Hmm, it could curly your fingers and brain J .

Thus this tutorial as an introduction ‘how to’ handle SD Card with Arduino. In next tutorial I will discuss how to read and write data on the SD Card especially for/from micro SD using Ethernet shield.
Next Post »