Obtaining SPI pin designations for a ESP32 S3

I don't see this listed in the past....
I have need an ESP32 with lots of GPIO pins.
The best I see is this one:-
In theory there are 38 I/O pins. There are some restrictions on some of the pins. For example if you have certain external memory configurations 4 of the pins are reserved etc.
https://docs.espressif.com/projects/esp-idf/en/stable/esp32s3/hw-reference/esp32s3/user-guide-devkitc-1.html

The problem is the is no pinout diagram. In the Arduino IDE/ESP32 however it does seem to emulate a "ESP32 S3 DevKit.

I wish to add an SD card. You would think it would be simple, but I cannot figure out what GPIO pins (total 4) I should use for the SPI interface.
Some similar ESP32 S3 modules (with documentation) have
GPIO13=MISO
GPIO12=SCK
GPIO11=MOSI
and "SS" which i assume is CS=10.

The default Arduino compile code does not work.
If I use:-
#define PIN_MOSI 13
#define PIN_MISO 12
#define PIN_SCK 14
#define PIN_CS 11
and within the code...

void setup(){
Serial.begin(115200);

pinMode(11,OUTPUT);
SPI.begin(PIN_SCK, PIN_MISO, PIN_MOSI);
if(!SD.begin(11)){
Serial.println("Card Mount Failed");
return;
}
The card fails!

I guess my question is what is the correct procedure to initialize an ESP32 S3 to a defined set of SPI pins. Also, can I skip the CS pin and just hold it low.
Thanks in advance for help.
John

Mine (XIAO ESP32-S3) is working with the code below:

SPI.begin(PIN_SCK, PIN_MISO, PIN_MOSI, PIN_CS);

P.S. You had better to use code tag (```c++ 〜 ```) when you post your codes.

I use something like this:

  #include <SPI.h>
  #include <SD.h>
  #define SD_CS           32   // SD Chip Select (SS)
  #define SD_CLK          33   // SD Clock (SCK)
  #define SD_MOSI         25   // SD Master Out Slave In (MOSI)
  #define SD_MISO         26   // SD Master In Slave Out (MISO)
  SPIClass hspi = SPIClass(HSPI);

// blablabla loop code

  pinMode(SD_CS, OUTPUT);               // SD SS.
  hspi.begin(SD_CLK, SD_MISO, SD_MOSI, SD_CS);  // Test hspi or vspi.
  SD.begin(SD_CS, hspi, SPEED)

SPEED is something between 4.000.000 and 18.000.000.

Also, you might need to retry the SD begin. Or add a pull up resistor as recommended
https://onlinedocs.microchip.com/pr/GUID-F9FE1ABC-D4DD-4988-87CE-2AFD74DEA334-en-US-3/index.html?GUID-48879CB2-9C60-4279-8B98-E17C499B12AF

Perhaps post a picture of the SD card adapter you are using and how you have it wired ?

thanks for the suggestion maikarg and others.
I tried the following code:-

#include "FS.h"
#include "SD.h"
#include "SPI.h"

#define SD_MOSI 13
#define SD_MISO 12
#define SD_SCK 14
#define SD_CS 11

SPIClass hspi = SPIClass(HSPI);

void setup(){
  Serial.begin(115200);
  Serial.println("In Setup");
  
  pinMode(SD_CS,OUTPUT);
  hspi.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);  
  
  SD.begin(SD_CS, hspi, 4000000);
  
   uint8_t cardType = SD.cardType();

  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");
  }
}

but I get "UNKNOWN" card type
What am I doing wrong?

Forgot to add there is a

void loop() {
}

below setup()

Answer my own question
If I use SD_CS = 15
it works, why?

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