What You Need to Connect an SD Card Module
An SD card module lets your Arduino store large amounts of data on a microSD card. The module communicates with the Arduino through SPI (Serial Peripheral Interface), a standard protocol that uses four wires to send and receive information. You will need the module itself, an Arduino board, a microSD card, and five jumper wires to make the connection work.
The SD card module is a small circuit board with eight pins. Five of those pins carry the signals that matter for a basic setup: power, ground, and three data lines. The module also needs a microSD card inserted into the slot on its underside before you connect it to the Arduino.
Key Takeaways
- SD card modules connect to Arduino using four data pins (MOSI, MISO, SCK, CS) plus power and ground, for a total of six wires.
- The exact pin numbers on your Arduino depend on which board you have — Arduino Uno uses pins 11, 12, 13, and 10 by default, but other boards differ.
- You must insert a microSD card into the module before connecting it, and the card should be formatted as FAT32 for most libraries to recognize it.
- The SD card library comes built into the Arduino IDE, so you do not need to download anything separately to read and write files.
The Five Wires You Need to Connect
The SD card module has eight pins total, but only five carry signals in a standard setup. Two pins supply power and ground, and three pins handle data. The power pin (usually labeled VCC) connects to your Arduino's 5V output. The ground pin (GND) connects to any ground pin on the Arduino.
The three data pins are MOSI, MISO, and SCK. MOSI (Master Out Slave In) sends commands from the Arduino to the module. MISO (Master In Slave Out) sends data back from the module to the Arduino. SCK (Serial Clock) is a timing signal that synchronizes the communication. These three pins connect to specific pins on your Arduino board — the exact numbers depend on which Arduino model you have.
The fifth wire is the chip select pin, usually labeled CS or SS. This pin tells the module when the Arduino wants to talk to it. You can use almost any digital pin on your Arduino for this purpose, though pin 10 is the conventional choice on an Arduino Uno.
Pin Connections for Arduino Uno and Nano
| SD Card Module Pin | Arduino Uno/Nano Pin |
|---|---|
| VCC | 5V |
| GND | GND |
| MOSI | 11 |
| MISO | 12 |
| SCK | 13 |
| CS | 10 |
Arduino Mega boards use different pin numbers for SPI communication. On a Mega, MOSI is pin 51, MISO is pin 50, and SCK is pin 52. The chip select pin can still be pin 10, or you can choose a different digital pin. Arduino Due and other ARM-based boards have their own SPI pins — check the board's pinout diagram before wiring.
If your SD card module has pins labeled differently, look for a label on the board itself or check the datasheet that came with it. Some modules use different names for the same signals, such as DI instead of MOSI or DO instead of MISO.
Preparing the SD Card and Module
Insert the microSD card into the slot on the underside of the SD card module before you connect anything to the Arduino. The card should slide in with the label facing away from the board. You will hear a click when it seats properly. If the card does not click, remove it and try again — forcing it can damage the connector.
The microSD card should be formatted as FAT32 for the Arduino SD library to read it correctly. Most new cards come formatted this way, but if you have used the card in another device, it may use a different format. On Windows, right-click the card in File Explorer, select Format, choose FAT32, and click Start. On Mac, open Disk Utility, select the card, click Erase, and choose MS-DOS (FAT) as the format.
After formatting, you can create folders and files on the card using your computer before you ever connect it to the Arduino. This is useful for testing — you can write a sketch that reads those files to confirm the connection is working.
Writing and Testing Your First Sketch
The Arduino IDE includes the SD library by default, so you do not need to download anything. Open the IDE, go to File > Examples > SD, and select CardInfo. This sketch reads information about the card and prints it to the Serial Monitor, which tells you whether the connection is working.
Before you upload the sketch, check the chip select pin number at the top of the code. The CardInfo example uses pin 10 by default. If you connected your CS wire to a different pin, change the number in the line that says const int chipSelect = 10; to match your setup.
Upload the sketch to your Arduino, then open the Serial Monitor (Tools > Serial Monitor) and set the baud rate to 9600. If the connection is working, you will see information about your card, including its size and the files on it. If you see an error message instead, double-check that all five wires are connected to the correct pins and that the microSD card is fully inserted into the module.
Common Wiring Mistakes and How to Fix Them
The most frequent problem is connecting the data pins to the wrong Arduino pins. Each Arduino board has a different set of SPI pins, and using the wrong ones means the module will not respond. Check your board's pinout diagram — you can find these on the Arduino website or by searching "[your board name] pinout".
Another common issue is a loose microSD card. If the card is not fully inserted, the module cannot read it. Remove the card, look at the connector to make sure it is clean, and reinsert it until you hear the click. If the connector looks dirty or corroded, gently clean it with a dry cotton swab.
Power problems can also prevent the module from working. Make sure you are using the Arduino's 5V pin, not a 3.3V pin. Some SD card modules are designed for 3.3V, but most common modules expect 5V. Check the label on your module or its datasheet to be certain. If you are powering the Arduino from a USB cable, the 5V supply should be strong enough for the module.
Reading and Writing Files on the SD Card
Once the CardInfo sketch confirms your connection is working, you can write sketches that create new files, write data to them, and read data back. The SD library provides functions like SD.open() to open a file, file.println() to write a line of text, and file.read() to read data back.
A simple example: you could write a sketch that reads a temperature sensor every minute and logs the reading to a file on the SD card. The sketch opens a file called data.txt, writes the temperature and the time, closes the file, and waits 60 seconds before repeating. This lets you collect data over hours or days without losing it when the Arduino powers off.
The SD library documentation is built into the Arduino IDE. Go to Help > Reference and search for "SD" to see all available functions and examples. Each function includes a description and sample code showing how to use it.
Frequently Asked Questions
Can I use a 3.3V Arduino with an SD card module designed for 5V?
Most SD card modules work with both 3.3V and 5V, but check your module's datasheet to be sure. If your module is rated for 5V only and you power it with 3.3V, it may not respond. Arduino Due and other 3.3V boards often require a level shifter — a small circuit that converts 5V signals to 3.3V — if your module expects 5V logic.
What happens if I connect the wires to the wrong pins?
The module will not communicate with the Arduino, and the CardInfo sketch will print an error. The Arduino will not be damaged. Check your board's pinout diagram, disconnect the wires, and reconnect them to the correct pins. Then upload the sketch again.
Can I use a full-size SD card instead of a microSD card?
No. SD card modules are designed for microSD cards only. A full-size SD card will not fit in the slot. You can use a microSD card with an adapter if you want to read it on a computer, but the module itself requires a microSD card.
How much data can I store on the SD card?
That depends on the card's capacity. MicroSD cards range from 1 GB to 1 TB, though most people use 16 GB or 32 GB cards with Arduino projects. The Arduino SD library can handle any size card formatted as FAT32. A 16 GB card formatted as FAT32 gives you about 16 billion bytes of storage space.
Do I need to add a capacitor or resistor to the circuit?
For most setups, no. A basic connection with just the five wires works fine. Some people add a 100 microfarad capacitor between the 5V and GND pins on the module to smooth out power fluctuations, but this is optional for short wiring runs. If your Arduino is powered by a battery and the module behaves erratically, adding a capacitor may help.