MicroSD Card Module Reference
An SPI breakout for microSD cards, used for reading/writing files — commonly for data logging.
Pin names
| Name | Description |
|---|---|
| CD | Card Detect — indicates whether a card is inserted |
| DO | MISO — SPI data in |
| GND | Ground |
| SCK | SPI clock |
| VCC | Power (5V, regulated to 3.3V onboard) |
| DI | MOSI — SPI data out |
| CS | Chip Select |
Attributes
This component has no configurable attributes.
Usage
Connect VCC to 5V, GND to GND, SCK/DI (MOSI)/DO (MISO) to the board's
hardware SPI pins (13/11/12 on an Uno), and CS to any free digital pin. Read/write files
with the built-in SD library.
#include <SPI.h>
#include <SD.h>
const int CS_PIN = 4;
void setup() {
Serial.begin(9600);
if (!SD.begin(CS_PIN)) {
Serial.println("SD card init failed!");
return;
}
File logFile = SD.open("log.txt", FILE_WRITE);
if (logFile) {
logFile.println("Sensor reading: 42");
logFile.close();
}
}
void loop() {}
Examples
| Description | Attrs |
|---|---|
| Default microSD module | {} |
See also
- HX711 Load Cell Amplifier — pair with this module to log weight readings to a file
- DS1307 RTC — pair with this module to timestamp logged data