

The SD Card Module is a compact and versatile component designed to interface SD cards with microcontrollers. It enables the storage and retrieval of data, making it ideal for applications requiring large amounts of non-volatile memory. Commonly used in data logging, multimedia storage, and file transfer systems, the SD Card Module is a staple in embedded systems and IoT projects.








| Pin Name | Pin Number | Description |
|---|---|---|
GND |
1 | Ground connection |
VCC |
2 | Power supply input (3.3V or 5V, depending on the module) |
MISO |
3 | Master In Slave Out - SPI data output from the SD card to the microcontroller |
MOSI |
4 | Master Out Slave In - SPI data input from the microcontroller to the SD card |
SCK |
5 | Serial Clock - SPI clock signal |
CS |
6 | Chip Select - Activates the SD card for communication |
VCC pin to a 3.3V or 5V power source (check your module's specifications) and the GND pin to ground.MISO, MOSI, SCK, and CS pins to the corresponding SPI pins on your microcontroller.MISO: Pin 12MOSI: Pin 11SCK: Pin 13CS: Any digital pin (commonly Pin 10)SD library to simplify communication with the SD card.#include <SPI.h>
#include <SD.h>
// Define the Chip Select (CS) pin for the SD card module
const int chipSelect = 10;
void setup() {
// Initialize serial communication for debugging
Serial.begin(9600);
while (!Serial) {
; // Wait for the serial port to connect (for native USB boards)
}
Serial.println("Initializing SD card...");
// Check if the SD card is present and can be initialized
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// Don't proceed if the SD card initialization fails
while (1);
}
Serial.println("Card initialized successfully!");
// Create or open a file on the SD card
File dataFile = SD.open("example.txt", FILE_WRITE);
// Check if the file opened successfully
if (dataFile) {
dataFile.println("Hello, SD card!"); // Write data to the file
dataFile.close(); // Close the file to save changes
Serial.println("Data written to file.");
} else {
Serial.println("Error opening file.");
}
}
void loop() {
// Nothing to do here
}
CS pin is unique if multiple SPI devices are connected.SD library for optimal performance and compatibility.SD Card Initialization Fails
File Not Opening
FILE_WRITE or FILE_READ).Data Corruption
file.close() and avoid removing the SD card while the module is powered.Slow Performance
Can I use microSD cards with this module? Yes, most SD Card Modules support microSD cards with FAT16 or FAT32 formatting.
What is the maximum SD card size supported?
This depends on the module and library used. Typically, cards up to 32GB are supported with the Arduino SD library.
Can I connect multiple SD Card Modules to one microcontroller?
Yes, but each module must have a unique CS pin to avoid conflicts on the SPI bus.
Why is my SD card not detected? Ensure proper wiring, correct voltage levels, and that the SD card is inserted securely.