

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 an essential tool for projects requiring large amounts of non-volatile memory. This module is widely used in applications such as data logging, file storage, multimedia playback, and firmware updates.
Common applications and use cases:








The SD Card Module typically has 6 pins. Below is the pinout and description:
| Pin | Name | Description |
|---|---|---|
| 1 | GND | Ground connection |
| 2 | VCC | Power supply input (3.3V or 5V, depending on the module) |
| 3 | MISO | Master In Slave Out - SPI data output from the SD card to the microcontroller |
| 4 | MOSI | Master Out Slave In - SPI data input from the microcontroller to the SD card |
| 5 | SCK | Serial Clock - SPI clock signal |
| 6 | CS | Chip Select - Used to select the SD card module during SPI communication |
VCC pin to a 5V or 3.3V 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.Below is an example of how to use the SD Card Module with an Arduino UNO:
#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...");
// Initialize the SD card
if (!SD.begin(chipSelect)) {
Serial.println("SD card initialization failed!");
return; // Stop if the SD card cannot be initialized
}
Serial.println("SD 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
Serial.println("Data written to example.txt.");
} else {
Serial.println("Error opening example.txt for writing.");
}
}
void loop() {
// Nothing to do here
}
SD Card Initialization Fails:
CS pin is correctly defined in your code and connected to the correct pin on the microcontroller.File Not Found or Cannot Be Opened:
Corrupted Data or Communication Errors:
Module Not Detected:
Q: Can I use microSD cards with this module?
A: Yes, most SD Card Modules support both standard SD and microSD cards using an adapter.
Q: What is the maximum SD card size supported?
A: This depends on the module and library used. Typically, cards up to 32GB (FAT32) are supported.
Q: Can I use multiple SD Card Modules on the same SPI bus?
A: Yes, but each module must have a unique CS pin to avoid conflicts.
Q: Why is my SD card not detected after formatting?
A: Ensure the card is formatted as FAT16 or FAT32. ExFAT and NTFS are not supported by most libraries.
By following this documentation, you can effectively integrate the SD Card Module into your projects for reliable data storage and retrieval.