Raspberry Pi Pico Sd Card Spi Storage Interface

About the project

Expand your Pico with removable FAT32 storage — log data, manage files, and interact via a Serial menu using SPI and a microSD module.

Project info

Difficulty: Easy

Estimated time: 1 hour

License: MIT license (MIT)

Items used in this project

Hardware components

USB-A to Mini-USB Cable USB-A to Mini-USB Cable x 1
SD Card module SD Card module x 1
Raspberry Pi Pico W Raspberry Pi Pico W x 1

Software apps and online services

Arduino IDE Arduino IDE

Hand tools and fabrication machines

Fritzing Fritzing x 1

Story

📘 Overview

Adding the Raspberry Pi Pico sd card Module opens up powerful possibilities — from logging sensor data to saving settings or text files. This project walks you through building an SD card storage interface for the Pico using an inexpensive microSD card module and the SPI bus. You’ll end up with a fully interactive Serial menu that lets you create, edit, read, and delete files on the SD card.

Raspberry Pi Pico sd card Module

Raspberry Pi Pico sd card Module

🧰 Why This Project Matters

The Pico’s onboard storage is limited. By connecting a microSD card via SPI:

  • You get gigabytes of removable storage for your projects.
  • You learn how embedded systems manage FAT32 file systems.
  • You unlock real-world use cases like data logging, configuration files, and persistent settings.

This setup works with any standard SD card module that includes a 3.3 V regulator and level shifting, ensuring safe operation with the Pico.

SD Card Module Pinout

SD Card Module Pinout

🔌 Hardware Requirements

You’ll need:

  • Raspberry Pi Pico (RP2040 microcontroller)
  • MicroSD card module (with 3.3 V support)
  • MicroSD card (FAT32 formatted)
  • Breadboard + jumper wires
  • USB cable (for power and programming)

Wiring Diagram

Wiring Diagram

📀 Preparing Your SD Card

Before using the card:

  • Remove existing partitions.
  • Create one primary partition.
  • Format as FAT32 (use Rufus or GUIFormat if needed).Larger than 32 GB cards often default to exFAT and won’t work without reformatting.

⚠️ If the card isn’t FAT32, initialisation will fail, and the Pico will report SD init FAILED.

🧠 Software — Interactive SD Card Menu

The provided Arduino sketch uses the standard SPI and SD libraries to:

  • Initialise the SD card
  • Create a file
  • Write text
  • Read from a file
  • Delete a file

Here’s a high-level look at the core idea:

#include <SPI.h>
#include <SD.h>

const uint8_t CSPIN = 17; // SD chip select
const char *FILENAME = "demo.txt";

void setup() {
Serial.begin(115200);
SD.begin(CSPIN, SPI);
printMenu();
}

#include <SPI.h>
#include <SD.h>

const uint8_t CSPIN = 17; // SD chip select
const char *FILENAME = "demo.txt";

void setup() {
Serial.begin(115200);
SD.begin(CSPIN, SPI);
printMenu();
}

The loop waits for Serial input (1–4) and triggers the corresponding file operation.

👉 File operations include:

  • Create & write default text
  • Write custom text from Serial
  • Read every character
  • Delete the file

🧪 Live Demo — What Happens

Once your Pico is wired and programmed:

  • The Serial Monitor shows an easy menu.
  • Choose an option by typing a number.
  • The Pico performs the file action immediately.
  • Results appear in real time.

This responsiveness makes it great for debugging and learning how file I/O works on a microcontroller

Schematics, diagrams and documents

Schematic Diagram

Code

GitHub Repository

Credits

Leave your feedback...