Page 1 of 1

SPI Pinout for ESP32-WROOM-32D

Posted: Wed Nov 08, 2023 11:14 am
by HEckardt
Dear Forum,

I`m a beginner with the ESP32. I want to use in a ESP32-WROOM-32D one of the SPI peripherals as Master. As I could find in the "Exampels", there are different pre-definitiones for the different ESP32 types, in terms of pin-function and SPI-module (HSPI_HOST or SPI2_HOST):

Code: Select all

#ifdef CONFIG_IDF_TARGET_ESP32
#define LCD_HOST    HSPI_HOST

#define PIN_NUM_MISO 25
#define PIN_NUM_MOSI 23
#define PIN_NUM_CLK  19
#define PIN_NUM_CS   22

#define PIN_NUM_DC   21
#define PIN_NUM_RST  18
#define PIN_NUM_BCKL 5
#elif defined CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#define LCD_HOST    SPI2_HOST

#define PIN_NUM_MISO 37
#define PIN_NUM_MOSI 35
#define PIN_NUM_CLK  36
#define PIN_NUM_CS   45

#define PIN_NUM_DC   4
#define PIN_NUM_RST  5
#define PIN_NUM_BCKL 6
#elif defined CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C6
#define LCD_HOST    SPI2_HOST

#define PIN_NUM_MISO 2
#define PIN_NUM_MOSI 7
#define PIN_NUM_CLK  6
#define PIN_NUM_CS   10

#define PIN_NUM_DC   9
#define PIN_NUM_RST  4
#define PIN_NUM_BCKL 5

#elif defined CONFIG_IDF_TARGET_ESP32H2
#define LCD_HOST    SPI2_HOST

#define PIN_NUM_MISO 0
#define PIN_NUM_MOSI 5
#define PIN_NUM_CLK  4
#define PIN_NUM_CS   1

#define PIN_NUM_DC   10
#define PIN_NUM_RST  11
#define PIN_NUM_BCKL 12
#endif
But when I compare these definitiones with the PinTable in the Datasheet, I could not find a match. So I have no idea, which pins should be connected to my external SPI equipment. Additional I`m a little bit confused about the contents of the

- Datasheet
- Technical Refernce Manual

From my point of view, it is quit difficult to learn, how to configure the I/O pins through the MUX/Matrix. Furthermore, for the idf.py I`m able to select the ESP32 sub-type.

So my questions:
- which pin should I select for the which pin function?
- for the idf.py should I simply select the "ESP32" as target device?

Thank you for your comments.

Greetings
Henry

Re: SPI Pinout for ESP32-WROOM-32D

Posted: Thu Nov 09, 2023 12:08 pm
by MicroController
But when I compare these definitiones with the PinTable in the Datasheet, I could not find a match
That's a common "problem". On the ESPs almost any pin can be configured to perform almost any function. That's why you often won't find a) a definitive documentation as to the function of individual pins and b) any consistency between projects as to which pins are used for what.
From my point of view, it is quit difficult to learn, how to configure the I/O pins through the MUX/Matrix.
Indeed, datasheet and TRM aren't "how-tos". On the ESPs however, you don't handle that low-level stuff yourself; you use the "drivers" which are provided in the ESP-IDF to set up the hardware, like for SPI spi_bus_initialize(...) which lets you specify a configuration defining which pins you want to be used and then sets up everything for you.
Furthermore, for the idf.py I`m able to select the ESP32 sub-type.
Here you need to select the chip/SoC you have, which basically defines the CPU, irrespective of the module, board or devkit it's mounted on.
So ESP32 is indeed what you need for an ESP32-WROOM module. The different ESP32 SoC variants (ESP32, ESP32-S3, ESP32-C3,...) are pretty different hardware (CPUs), and you'll know when you bought e.g. an ESP32-S3, and the modules directly reflect the SoC in their names.

Re: SPI Pinout for ESP32-WROOM-32D

Posted: Thu Nov 09, 2023 12:44 pm
by HEckardt
Hello MicroController,

thanks for the answer. In the meantime I intensed my study and now it is for me much clearer, how it works. I found out, how to edit the "example" scripts for an adaptation to my specific needs. Thanks also for the link to the API´s and the short introduction to the ESP32 types.

So I think, I´m happy now and it is possible for me to continue my project.

Greetings Henry