Arduino and SD card interfacing example

This topic shows how to get started with Arduino and SD card (microSD cards). It shows how to read information about SD card connected to the Arduino board. The example reports volume type, free space and other information using the SD library, sending it over the serial port. Also Proteus simulation of the Arduino and SD card is available with a small video.

Arduino has a very nice SD card library, with this library the interfacing is very simple. The Arduino SD library allows for reading from and writing to SD cards. It is built on sdfatlib by William Greiman. The library supports FAT16 and FAT32 file systems on standard SD cards and SDHC cards. It uses short 8.3 names for files.

The communication between the microcontroller and the SD card uses SPI, which takes place on digital pins 11, 12, and 13 (on most Arduino boards) or 50, 51, and 52 (Arduino Mega). Additionally, another pin must be used to select the SD card. This can be the hardware SS pin – pin 10 (on most Arduino boards) or pin 53 (on the Mega) – or another pin specified in the call to SD.begin().

Hardware Required:

  • Arduino board
  • SD card with FAT16 or FAT32 file system
  • SD card socket (connector)
  • 10K ohm resistor
  • 3 x 3.3K ohm resistor
  • 3 x 2.2K ohm resistor
  • Breadboard
  • Jumper wires

The circuit:
Example circuit schematic diagram is shown below.

Arduino SD card interface circuit

(Grounded terminals are connected together)

The SD card is supplied from the Arduino board with 3.3V.

In the circuit there are 3 voltage dividers, each one consists of 2.2K and 3.3K resistors, they are used to step down 5V that comes from the arduino into 3V which is sufficient for the SD card signals. The voltage dividers are used for SD card signals: SCK (serial clock), MOSI (master out slave in) and SS (chip select). The Arduino sends these signals from pins 13, 11 and 10 respectively. The SD card MISO is connected directly to the arduino because this path is used by the SD card to send data to the arduino (with voltage of 3.3V).
Connecting the SD card directly to the arduino without voltage level converters or voltage dividers may damage it.

Arduino Code:
I got the code below from arduino examples (with minor modifications), it collects information about the SD card connected to the Arduino and print it to Arduino IDE serial monitor.

I placed an empty (with no file) 2GB micro SD card with FAT16 file system and I got the result shown below:

arduino sd card seral monitor

and the following image shows a 8GB micro SD card formatted with FAT32 file system. There are 3 folders in this SD card: Images, Videos and Audio, the Images folder contains 1 file named Photo (Photo.jpg with extension) and the other folders are empty:

arduino micro sd card fat32 serial monitor

If there is no card or the Arduino can’t connect to it, serial monitor will display the message below:

arduino sd card no connection

Proteus simulation of the example is shown in the video below:

Proteus simulation file download:
SD card image file download:


7 thoughts on “Arduino and SD card interfacing example”

  1. My proteus 8.9 sp0 is showing
    Internal exception: access violation in module ‘UNKNOWN’ [55d54447]

    If you got same error when you was working on this project please help me. And please give us link of Arduino library which you are using.

    Thank you

  2. hi i connected sd card interfacing with Arduino uno and i given pin description MOSI 11, MISO 12, SCK 13, CS 10, iam try to save the ultrasonic sensor values in sd card excel format if any body can know this please reply me thank you

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top