Fiverr gig
$15 — I will help you with your project and simulate it for you
Hire me
🤖 Arduino Projects

Arduino Micro SD Card Module Project

The Engineer PostMay 29, 20265 min read
Arduino Micro SD Card Module Project — Arduino UNO tutorial cover image

Welcome to this beginner-friendly Arduino tutorial on the sd card. By the end of the guide, you'll wire the module to an Arduino UNO, flash a short sketch, and read live values on the Serial Monitor — no prior electronics experience required.

What you'll learn

  • How the module works in plain language
  • The exact parts you need and how to wire them safely
  • The full Arduino IDE sketch with comments
  • Common issues and how to fix them
Arduino Micro SD Card Module Project — overview

Hardware you'll need

ComponentQtyNotes
Arduino UNO1Main microcontroller board
Micro SD Card Module1SPI-based storage module
Micro SD Card1Formatted in FAT16/FAT32
Jumper WiresAs neededFor connections
Breadboard1Optional for easy wiring
Arduino Micro SD Card Module Project — wiring diagram

Arduino code

Open the Arduino IDE, paste the sketch below into a new file, install any libraries the sketch #includes (Tools → Manage Libraries), select your board and COM port, then click Upload.

#include <SD.h>
const int chipSelect = 10;
File myFile;

void setup() {

  // Open serial communications and wait for port to open:
  Serial.begin(9600);

  // wait for Serial Monitor to connect. Needed for native USB port boards only:
  while (!Serial);


  check_and_create_file();
  write_text();
}

void loop() {

  // nothing happens after setup finishes.
}


void check_and_create_file()
{
  Serial.print("Initializing SD card...");

  /*Check if the SD card exist or not*/
  if (!SD.begin(chipSelect)) {
    Serial.println("initialization failed!");
    while (1);
  }

  Serial.println("initialization done.");

  if (SD.exists("data_log.txt"))
    Serial.println("data_log.txt exists.");

  else
  {
    Serial.println("data_log.txt doesn't exist.");


    /* open a new file and immediately close it:
      this will create a new file */

    Serial.println("Creating data_log.txt...");

    myFile = SD.open("data_log.txt", FILE_WRITE);

    myFile.close();

    /* Now Chec agin if the file exists in
      the SD card or not */

    if (SD.exists("data_log.txt"))
      Serial.println("data_log.txt exists.");

    else
      Serial.println("data_log.txt doesn't exist.");
  }
}


void write_text()
{
  myFile = SD.open("data_log.txt", FILE_WRITE);

  // if the file opened okay, write to it:
  if (myFile) {
    Serial.print("Writing to data_log.txt...");
    myFile.println("testing 1, 2, 3.");
    // close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening data_log.txt");
  }

  // re-open the file for reading:
  myFile = SD.open("data_log.txt");
  if (myFile) {
    Serial.println("data_log.txt:");

    // read from the file until there's nothing else in it:
    while (myFile.available()) {
      Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening data_log.txt");
  }
}

How it works

The sketch initialises serial communication and the sd card driver in setup(), then in loop() it samples the sensor at a regular interval and prints the result to the Serial Monitor at 9600 baud. Open the Serial Monitor (Ctrl+Shift+M) after upload to see live readings.

Project ideas & applications

  • Data loggers (temperature, humidity, GPS)
  • Event recording systems
  • Portable storage for embedded systems
  • Projects needing large storage beyond Arduino’s memory

Troubleshooting checklist

  • No readings: verify the baud rate in Serial Monitor matches the sketch (usually 9600).
  • Garbage characters: wrong baud rate or loose GND wire.
  • Library not found: install the exact library referenced in the #include line via Library Manager.
  • Sensor not detected (I²C): run an I²C scanner sketch to confirm the address.

What to build next

Once the basic readout works, try logging values to an SD card, sending them over Wi-Fi with an ESP32, or pushing them to a Blynk IoT dashboard. Pair this module with our simulator round-up to prototype the circuit before soldering.

Frequently Asked Questions

Q.What library do I need for the sd card?

Open Arduino IDE → Tools → Manage Libraries, then search for any library named in the sketch's #include lines and install the latest version.

Q.Why does the Serial Monitor show nothing?

The most common cause is a baud-rate mismatch — set the Serial Monitor to 9600 baud (bottom-right dropdown) so it matches Serial.begin(9600) in the code.

Q.Can I use this with an ESP32 instead of Arduino UNO?

Yes. The sd card works with any 3.3-5 V microcontroller. Just remap the wiring to ESP32 I/O pins and keep the rest of the sketch the same.

TEP

The Engineer Post

Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.

Related projects

Browse all 50+ projects