Skip to content

Arduino SD.begin Fails to Initialize Card

DodaTech Updated 2026-06-26 1 min read

In this tutorial, you'll learn about Arduino SD.begin Fails to Initialize Card. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

The Problem

SD.begin() returns false even with an inserted and formatted SD card.

Quick Fix

Wrong

SD.begin(10);  // CS pin may be wrong for the board
SD.begin() returns false (card not initialized).
#include <SD.h>

const int chipSelect = 4;  // Some SD modules use pin 4

void setup() {
  Serial.begin(9600);
  while (!Serial);
  
  Serial.print("Initializing SD card on CS=");
  Serial.println(chipSelect);
  
  if (!SD.begin(chipSelect)) {
    Serial.println("Card failed, or not present");
    return;
  }
  Serial.println("Card initialized.");
  
  Serial.print("Volume size: ");
  Serial.print(SD.vol()->volumeSize());
  Serial.println(" MB");
}

void loop() { }
Initializing SD card on CS=4
Card initialized.
Volume size: 7634 MB

Prevention

The CS pin varies by board and SD module. Common pins: Uno (10), Ethernet shield (4), some modules (4 or 10). Check wiring: CS to pin X, MOSI to 11, MISO to 12, SCK to 13. Ensure the card is formatted as FAT16 or FAT32. Power the SD module from 5V, not 3.3V (some need 5V).

DodaTech engineers apply these same patterns across Doda Browser, DodaZIP, and Durga Antivirus Pro for production IoT reliability.

FAQ

### Why does SD.begin fail with Ethernet shield?

Ethernet and SD share the SPI bus and may conflict. The Ethernet library uses pin 4, SD uses pin 10. Set the correct CS for each and use SPI.beginTransaction/endTransaction.

What format does the SD library support?

FAT16 and FAT32. exFAT and NTFS are NOT supported by the standard Arduino SD library.

Can I use SD with SPI on ESP32?

Yes, but the built-in SD library may not work. Use the SD_MMC library for ESP32's SDMMC peripheral. The SPI pins can be reassigned.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro