Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Component Documentation

How to Use SD Card Module: Examples, Pinouts, and Specs

Image of SD Card Module
Cirkit Designer LogoDesign with SD Card Module in Cirkit Designer

Introduction

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:

  • Data logging for sensors in IoT projects
  • Storing configuration files or firmware updates
  • Multimedia storage for audio, video, or images
  • File-based communication between microcontrollers and external systems

Explore Projects Built with SD Card Module

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Arduino UNO SD Card Data Logger
Image of sd card: A project utilizing SD Card Module in a practical application
This circuit consists of an Arduino UNO connected to an SD card module. The Arduino provides power and ground to the SD module and interfaces with it using SPI communication through digital pins D10 (CS), D11 (MOSI), D12 (MISO), and D13 (SCK). The setup is intended for reading from or writing to an SD card using the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Arduino UNO Battery-Powered Data Logger with Micro SD Card Storage
Image of arduino sd: A project utilizing SD Card Module in a practical application
This circuit is designed to interface an Arduino UNO with a Micro SD Card Module for data storage, powered by two 18650 Li-ion batteries through a USB plug and controlled by a rocker switch. The Arduino communicates with the SD card module via SPI protocol and is also connected to the USB plug for potential data transfer or power supply.
Cirkit Designer LogoOpen Project in Cirkit Designer
ESP32-C3 and Micro SD Card Module for Data Logging
Image of Esp 32 super mini with MicroSd module: A project utilizing SD Card Module in a practical application
This circuit features an ESP32-C3 microcontroller interfaced with a Micro SD Card Module. The ESP32-C3 handles SPI communication with the SD card for data storage and retrieval, with specific GPIO pins assigned for MOSI, MISO, SCK, and CS signals.
Cirkit Designer LogoOpen Project in Cirkit Designer
Heltec LoRa V2 with SD Card Data Logging
Image of LoRa SD: A project utilizing SD Card Module in a practical application
This circuit connects an SD card module to a Heltec LoRa V2 microcontroller for data storage and retrieval. The SD module is interfaced with the microcontroller via SPI communication, utilizing the CS, SCK, MOSI, and MISO pins. Power is supplied to the SD module from the microcontroller's 5V output, and both modules share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Explore Projects Built with SD Card Module

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of sd card: A project utilizing SD Card Module in a practical application
Arduino UNO SD Card Data Logger
This circuit consists of an Arduino UNO connected to an SD card module. The Arduino provides power and ground to the SD module and interfaces with it using SPI communication through digital pins D10 (CS), D11 (MOSI), D12 (MISO), and D13 (SCK). The setup is intended for reading from or writing to an SD card using the Arduino.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of arduino sd: A project utilizing SD Card Module in a practical application
Arduino UNO Battery-Powered Data Logger with Micro SD Card Storage
This circuit is designed to interface an Arduino UNO with a Micro SD Card Module for data storage, powered by two 18650 Li-ion batteries through a USB plug and controlled by a rocker switch. The Arduino communicates with the SD card module via SPI protocol and is also connected to the USB plug for potential data transfer or power supply.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of Esp 32 super mini with MicroSd module: A project utilizing SD Card Module in a practical application
ESP32-C3 and Micro SD Card Module for Data Logging
This circuit features an ESP32-C3 microcontroller interfaced with a Micro SD Card Module. The ESP32-C3 handles SPI communication with the SD card for data storage and retrieval, with specific GPIO pins assigned for MOSI, MISO, SCK, and CS signals.
Cirkit Designer LogoOpen Project in Cirkit Designer
Image of LoRa SD: A project utilizing SD Card Module in a practical application
Heltec LoRa V2 with SD Card Data Logging
This circuit connects an SD card module to a Heltec LoRa V2 microcontroller for data storage and retrieval. The SD module is interfaced with the microcontroller via SPI communication, utilizing the CS, SCK, MOSI, and MISO pins. Power is supplied to the SD module from the microcontroller's 5V output, and both modules share a common ground.
Cirkit Designer LogoOpen Project in Cirkit Designer

Technical Specifications

  • Operating Voltage: 3.3V (logic level) with onboard voltage regulator for 5V input
  • Current Consumption: ~100mA (varies with SD card type and operation)
  • Supported SD Card Types: Standard SD and microSD cards (FAT16/FAT32 file systems)
  • Communication Protocol: SPI (Serial Peripheral Interface)
  • Dimensions: Typically 42mm x 24mm x 12mm (varies by manufacturer)

Pin Configuration and Descriptions

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

Usage Instructions

How to Use the SD Card Module in a Circuit

  1. Power the Module: Connect the VCC pin to a 5V or 3.3V power source (depending on the module) and the GND pin to ground.
  2. Connect SPI Pins:
    • Connect the MISO, MOSI, SCK, and CS pins to the corresponding SPI pins on your microcontroller.
    • For Arduino UNO, the SPI pins are:
      • MISO: Pin 12
      • MOSI: Pin 11
      • SCK: Pin 13
      • CS: Any digital pin (commonly Pin 10)
  3. Insert an SD Card: Ensure the SD card is formatted to FAT16 or FAT32 before inserting it into the module.
  4. Load the Required Library: Use the SD library (pre-installed in the Arduino IDE) to interface with the SD card.

Example Code for 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...");

  // 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
    Serial.println("Data written to file.");
  } else {
    Serial.println("Error opening file.");
  }
}

void loop() {
  // Nothing to do here
}

Important Considerations and Best Practices

  • Voltage Levels: Ensure the module is compatible with your microcontroller's logic level (3.3V or 5V). Most modules have onboard regulators and level shifters.
  • SD Card Formatting: Always format the SD card to FAT16 or FAT32 before use. Unformatted or unsupported file systems may cause initialization errors.
  • Chip Select Pin: Avoid conflicts by ensuring the CS pin is unique if multiple SPI devices are connected.
  • Data Integrity: Always close files after writing to ensure data is saved properly.

Troubleshooting and FAQs

Common Issues and Solutions

  1. SD Card Initialization Fails:

    • Ensure the SD card is properly inserted and formatted to FAT16 or FAT32.
    • Verify the CS pin is correctly defined in the code and connected to the correct pin on the microcontroller.
    • Check the power supply voltage and current requirements.
  2. File Not Opening or Writing:

    • Confirm the file name follows the 8.3 filename convention (e.g., example.txt).
    • Ensure the SD card is not write-protected or full.
  3. Corrupted Data or Files:

    • Avoid removing the SD card while the module is powered.
    • Always close files after writing to prevent data corruption.
  4. Module Not Detected:

    • Double-check all connections, especially the SPI pins.
    • Verify the module's power supply and ground connections.

FAQs

Q: Can I use a microSD card with an adapter?
A: Yes, microSD cards with standard SD adapters are fully compatible with the module.

Q: What is the maximum SD card size supported?
A: Most modules support up to 32GB SD cards formatted to FAT32. Larger cards may require additional libraries or configurations.

Q: Can I use multiple SD card modules in one project?
A: Yes, but each module must have a unique CS pin to avoid SPI conflicts.

Q: Is the SD card module compatible with 3.3V microcontrollers like ESP32?
A: Yes, the module is compatible with 3.3V logic levels. Ensure the power supply matches the module's requirements.

By following this documentation, you can effectively integrate the SD Card Module into your projects for reliable data storage and retrieval.