Skip to main content

wokwi-microsd-card Reference

microSD card with SPI interface

caution

The microSD card simulator is still in beta. The interface/behavior are prone to change!

Pin names

NameDescription
CDCard detect *
DOSPI data output (MISO)
GNDGround
SCKSPI clock
VCCVoltage supply
DISPI data input (MOSI)
CSChip select

* The CD pin is connected to ground when there's no card in the socket. In the simulator, there's always a card in the socket, so this pin is always disconnected.

Simulation Behavior

The microSD card is automatically initialized with a FAT16 file system, and all your project files are copied into it.

Arduino code example

The example below uses the popular SdFat Arduino library. It prints a list of all the files in the card. The code assumes the following connections:

SD card pinArduino Uno pin
SCK13
DO12
DI11
CS10
#include "SdFat.h"

#define SPI_SPEED SD_SCK_MHZ(4)
#define CS_PIN 10

SdFat sd;

void setup() {
Serial.begin(115200);
if (!sd.begin(CS_PIN, SPI_SPEED)) {
if (sd.card()->errorCode()) {
Serial.println("SD initialization failed.");
} else if (sd.vol()->fatType() == 0) {
Serial.println("Can't find a valid FAT16/FAT32 partition.");
} else {
Serial.println("Can't determine error type");
}
return;
}

Serial.println("Files on card:");
Serial.println(" Size Name");

sd.ls(LS_R | LS_SIZE);
}

void loop() {
}

Run this example on Wokwi

Simulator examples