Using a SD-Card with an ESP32-S3-DEVKITC-1 on HSPI

Good day all,

I am trying to access an SD card with an ESP32-S3-DEVKITC-1 via HSPI.

With the following code, I can not mount the SD card.

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

#define HSPI_MISO 12
#define HSPI_MOSI 13
#define HSPI_SCLK 14
#define HSPI_CS   5
static const int spiClk = 240000000; // 1 MHz
SPIClass SPISD(HSPI);

void setup() {
  Serial.begin(115200);
  SPISD.begin();
  SPISD.begin(HSPI_SCLK, HSPI_MISO, HSPI_MOSI, HSPI_CS); //SCLK, MISO, MOSI, SS
  pinMode(HSPI_CS, OUTPUT); //HSPI SS

if (!SD.begin(HSPI_CS, SPISD))
  {
    Serial.println("Card Mount Failed");
    return;
  }
  
  uint8_t cardType = SD.cardType();

  if (cardType == CARD_NONE)
  {
    Serial.println("No SD card attached");
    return;
  }

  Serial.print("SD Card Type: ");

  if (cardType == CARD_MMC)
  {
    Serial.println("MMC");
  }
  else if (cardType == CARD_SD)
  {
    Serial.println("SDSC");
  }
  else if (cardType == CARD_SDHC)
  {
    Serial.println("SDHC");
  }
  else
  {
    Serial.println("UNKNOWN");
  }

  uint64_t cardSize = SD.cardSize() / (1024 * 1024);
  Serial.printf("SD Card Size: %lluMB\n", cardSize);
  Serial.printf("Total space: %lluMB\n", SD.totalBytes() / (1024 * 1024));
  Serial.printf("Used space: %lluMB\n", SD.usedBytes() / (1024 * 1024));
}

void loop()
{
  delay(1000);
}

Many greetings.

Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best from this from this Forum before you proceed any further.

My bad, sorry.

Does the project have any cables, any connections, that can be shown in schematics?

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