Arduino Micro SD Card Module Project

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

Hardware you'll need
| Component | Qty | Notes |
|---|---|---|
| Arduino UNO | 1 | Main microcontroller board |
| Micro SD Card Module | 1 | SPI-based storage module |
| Micro SD Card | 1 | Formatted in FAT16/FAT32 |
| Jumper Wires | As needed | For connections |
| Breadboard | 1 | Optional for easy wiring |

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
#includeline 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.
You may also like
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.
The Engineer Post
Embedded systems engineer and educator. Writes weekly tutorials at EmbedLab to help beginners ship real hardware.
Related projects

Arduino Soil Moisture Sensor Project
Step-by-step Arduino tutorial: wire the soil moisture to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.

Arduino MPU6050 Sensor Module
Step-by-step Arduino tutorial: wire the mpu6050 to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor. Use it for diy self-balancing robot using arduino.
 — Arduino UNO tutorial cover image](/uploads/arduino-covers/interfacing-max4466-microphone-amplifier-module-with-arduino.webp)
Interfacing MAX4466 microphone amplifier module with Arduino
Step-by-step Arduino tutorial: wire the max4466 microphone amplifier to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.
 — Arduino UNO tutorial cover image](/uploads/arduino-covers/interfacing-ir-sensor-module-with-arduino.webp)
Interfacing IR Sensor Module with Arduino
Step-by-step Arduino tutorial: wire the ir to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.
 — Arduino UNO tutorial cover image](/uploads/arduino-covers/interfacing-dual-axis-joystick-module-with-arduino.webp)
Interfacing Dual Axis Joystick Module with Arduino
Step-by-step Arduino tutorial: wire the dual axis joystick to an Arduino UNO, upload the example sketch, and read live values on the Serial Monitor.



