Rp2040: can't get SD card reader to initialize

Hi,

I'm trying to get my SD card module initialized, but no matter what I try, I just can't get it to work.

I've written a simple code:

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

// Definition der Pins
const int chipSelect = 1; // GP1 (CSn)

void setup() {
  Serial.begin(9600);
  while (!Serial) {
  }

  SPI.setRX(0); // GP0 als MISO
  SPI.setTX(3); // GP3 als MOSI
  SPI.setSCK(2); // GP2 als SCK
  SPI.begin();

  Serial.print("InitializeSD-Card...");
  if (!SD.begin(chipSelect)) {
    Serial.println("SD-card couldn't be initialized.");
    return;
  }
  Serial.println("succesfull");
}

void loop() {
}

I am using a Pimoroni tiny rp2040, here is a photo of the pinout

I can't figure out what I'm doing wrong.
I appreciate any help I can get on this.

Thanks in advance!
Luca

if I run your code on a Raspberry Pi Pico RP2040 it works OK - serial monitor displays

InitializeSD-Card...succesfull

EDIT: if I run File>Examples>SD>CardInfo with the SPI pin definitions

const int _MISO = 0;  // AKA SPI RX
const int _MOSI = 3;  // AKA SPI TX
const int _CS = 1;
const int _SCK = 2;

serial monitor displays

Initializing SD card...
Wiring is correct and a card is present.

Card type:         Unknown
Cluster size:          16384
Blocks x Cluster:  32
Blocks size:  512
Total Blocks:      247616

Total Cluster:      7738

Volume type is:    FAT16
Volume size (Kb):  126779
Volume size (Mb):  123
Volume size (Gb):  0.12
Card size:  126779.39
Total bytes: 126779392
Used bytes: 147456
System Volume Information/
	IndexerVolumeGuid		76	CREATION: 2023-08-13 16:43:42	LAST WRITE: 2023-08-13 16:43:44
data.txt		486	CREATION: 2021-01-01 00:00:04	LAST WRITE: 2021-01-01 00:00:20
test.txt		77824	CREATION: 1980-01-01 00:00:00	LAST WRITE: 1980-01-01 00:00:00
foo.txt		13	CREATION: 1980-01-01 00:00:00	LAST WRITE: 1980-01-01 00:00:00

Oh thanks for testing it out! I now soldered the contacts directly on to an SD-Micro SD Adapter and this worked! So it must have something to do with my micro SD module.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.