Pi Pico SD card?

Please install / have a look to this package:
In the library area is some information about SD / SDfat.
And you need the courage to do a few experiments.

Hello RudolfAtRTC, Thank you I'm looking into it now. And i will do a update.


Hello RudolfAtRTC, I have already installed the pico board manger i can program the pico but i have no clue on the SD card. This is the Sd card module i have. But sense they are using GP/GPIO pins i can not tell which pins are for spi? I'm looking online but only one i found i have tried and and sense they use some GP/GPIO pin mapping when i try to do GP13 or a GPIO13 i get this pin is not in the scope. So I'm unsure what pins goes to where and how to put it what sc pin goes to where.


If you have an SPI card, you can take the pin assignment from the attached sketch. It works for me. It is an adapted example from the SD library.

  Listfiles: This example prints out the files in a directory on a SD card

  The circuit for card at RPi Pico:
   SD card attached to SPI bus as follows:
   ** MISO - GP16 (pin 21)
   ** MOSI - GP19 (pin 25)
   ** CS   - GP17 (pin 22)
   ** SCK  - GP18 (pin 24)

  created  Nov 2010 by David A. Mellis
  modified 9 Apr 2012 by Tom Igoe
  modified 2 Feb 2014 by Scott Fitzgerald

  This example code is in the public domain.
	Datei: listfiles.ino
	Autor: Rudolf Schenke
	Stand: 19.06.2021

#include <FileProperties.h>
FileProperties Sketch(__FILE__,__DATE__);	// Constructor mit Dateinamen

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

File root;
char stDate[20];	// Buffer für aufbereitetes Datum

void setup() {

  while(not Serial) delay(10);
	Sketch.printProps();      // Ausgabe "Sketch = ..."

	Serial.print("Pin SS = ");	// Identify SPI pin group
  Serial.print("Initializing SD card...");
  if (not SD.begin(SS)) {
    Serial.println("initialization failed!");
  Serial.println("initialization done.");

  root = SD.open("/");

  printDirectory(root, 0);


void loop() {


void printDirectory(File dir, int numTabs) {

  while (true) 
    File entry =  dir.openNextFile();
    if (not entry) 
      break;	// no more files

    for (uint8_t i = 0; i < numTabs; i++) 
      Serial.print("  ");
    int iLength = strlen(entry.name());
    if (entry.isDirectory()) 
      printDirectory(entry, numTabs + 1);
      // files have sizes, directories do not
      int iLen = 23 - iLength - 2 * numTabs;
      char stForm[8];
      sprintf(stForm,"%%%dd ",iLen);  
      time_t cr = entry.getCreationTime();
      time_t lw = entry.getLastWrite();
      Serial.printf(" Created: %s ", formatDate(cr));
      Serial.printf("  Last write: %s\n", formatDate(lw));

char* formatDate(time_t tVal) {

	struct tm * tmstruct = localtime(&tVal);
	int iYear = ((tmstruct->tm_year) + 1900) % 1000;
	int iMon = tmstruct->tm_mon;
	int iDay = tmstruct->tm_mday;
	int iHour = tmstruct->tm_hour;
	int iMin = tmstruct->tm_min;
	sprintf(stDate,"%02d.%02d.%02d %02d:%02d",iDay,iMon,iYear,iHour,iMin);
	return ((char*)&stDate);
1 Like

hello RudolfAtRTC, Thank you i could not find that pinout anyplace. I saw other pinouts but not for SPI. Is that in one of the examples?

The one i found in the examples of SD(ro2040) in the examples folder was

  The circuit:
   analog sensors on analog ins 0, 1, and 2
   SD card attached to SPI bus as follows (Raspberry Pi Pico):
   ** MISO - pin 0
   ** MOSI - pin 3
   ** CS   - pin 1
   ** SCK  - pin 2


You can use my new RP2040_SD library which supports both RP2040 Arduino-mbed or arduino-pico core.

Check RP2040 libraries post #39

Hello khoih-prog. Thank you I'm trying it out now. I hope the SD card module works. I haven't used it in 2 or 3 years. LOL


Hello khoih-prog, I have tired the SD card library and for some strange reason it said it failed and can not see the address card. I’m going to try again later today when I get back.


Be sure to connect SD card to RPI-pico as follows:

SD card attached to SPI bus as follows:
   // Arduino-pico core
   ** MISO - pin 16
   ** MOSI - pin 19
   ** CS   - pin 17
   ** SCK  - pin 18
   // Arduino-mbed core
   ** MISO - pin 4
   ** MOSI - pin 3
   ** CS   - pin 5
   ** SCK  - pin 2

If you use the SD-card, with badly-designed MISO, follows the hardware fix as in topic Unable to access 2 SD cards with Arduino Mega 2560 Rev3


This is how I have wired it up.

CS to GP17
SCK to GP18
Mosi to GP19
Moso to GP16 << There is no MISO. It's labaled as MOSO. Which I'm guessing it is MISO.


That's the wiring for Earle Philhower's arduino-pico core. If you use ArduinoCore-mbed core, the wiring is

// Arduino-mbed core
** MISO - pin 4
** MOSI - pin 3
** CS   - pin 5
** SCK  - pin 2

Also connect SD-card's VCC to 5VDC, not 3.3VDC.

I'm using the pi pico which has 3.3v I'm using not a arduino board.


Also connect SD-card's VCC to 5VDC, not 3.3VDC.

You have to connect either SD-card's VCC to 5VDC (as the card has AMS1117 5v->3.3V regulator) or connect 3.3V to 3.3V OUT pin of AMS1117 of SD-card to test.

Connect 3.3VDC to SD-cards VCC, expecting 5VDC, won't work.

With HW background, you can measure the OUT pin of AMS1117 to verify how bad the voltage is dropped.

Ohhh i totally forgot. Let me try that. I forgot about the LDO. Thank you let me try that. I'm going to have to remove that ldo later on.


Hello Khoih-prog, That was the problem. Thank you. The SD card works perfectly. Thank you so much.


That's good news. But if you'd like to use SD-card with Ethernet or another board sharing the same SPI-bus, remember to fix the bad MISO of your SD-card.

Also for completeness, you can also use the MBED core to verify the SD-card is working OK.

Yeah It shouldn't be a problem. I'm working in a data logger with ethernet on the pico. ToTake time and date as well as temperature over time in the SD card. Just normal stuff. And then Just display it over The ethernet. When i saw the Wiznet 5500 550io being ported to the pico. I was like YES because that is the only Ethernet modules i have. So now I'm on my way an to tackle the Next part of this project.

Thank you once again you are my newest online Friend :slight_smile: LOL


I am using the default SPI pins to read-communicate with an SD card and I have run into a couple of issues. I am trying to create an Arduino program for the Pico Pi that reads 565 RGB video frames from an SD card and displays them on an LCD screen. Not rocket science I know. I am using Bodmer's TFT_eSPI library (converted to use SPI_1) and have gotten it running on both the Philhower core and the Mbed core... sort of. Painfully slow for the SD (SPI_0) reads. Also I am doing my best to convert to Mbed because the same screen frame writes on the Philower core are ~3X slower (Mbed: 46.5fps, Philhower: 17.5fps.) . But adding the SD reads drops the frame rate to 0.64 fps on the Mbed core. Ugh.
I don't know if this is the right place to ask these but here goes:

  1. I have noticed that the SD library for the Mbed Arduino core requires a "8.3" file naming format whereas the Philhower version did not. Took me a while to figure out why I was getting a file-not-found error for longer named files.
  2. There is some sort of problem with longer SD reads on Mbed. With the Philhower core I could read an entire frame (153600 bytes) in one SD.read. In the Mbed core I need to break the SD file read into 4 SD.read calls to read in the data correctly and completely. Why?
  3. Is there anything that can be done to increase the SPI clock for the SD reads on the Mbed? For instance, I am running the LCD SPI clock at 62.5 MHz (on SPI_1) but I don't seem to have the option to change the SD SPI (SPI_0) clock. Is there a way to do that?
    Thanks very much for your time. Any insights would be appreciated.

yeah I found this too. The pinout on that is wrong it should be:

The circuit for card at RPi Pico:
SD card attached to SPI bus as follows:
** MISO - GP16 (pin 21)
** MOSI - GP19 (pin 25)
** CS - GP17 (pin 22)
** SCK - GP18 (pin 24)

Very annoying, it was trial and error for me to find this.

Thank you very much. I haven't tried it yet because I have 3 other projects still working on then the SD card one.