ESP32 SPI Pins: VSPI, HSPI & Multiple Bus Guide
✍️ Devender Gupta · July 4, 2026
The ESP32 has 4 SPI controllers: SPI0, SPI1 (used internally for flash memory), SPI2 (HSPI), and SPI3 (VSPI). For most projects, you'll use VSPI (SPI3) and HSPI (SPI2) to communicate with displays, SD cards, sensors, and other SPI devices.
💡 Note: SPI0 and SPI1 are reserved for the ESP32's internal flash and PSRAM. They are not accessible for general use on ESP32-WROOM modules.
Default SPI Pin Assignments
| SPI Bus | MOSI | MISO | SCLK | CS (default) |
|---|---|---|---|---|
| VSPI (SPI3) | GPIO23 | GPIO19 | GPIO18 | GPIO5 |
| HSPI (SPI2) | GPIO13 | GPIO12 | GPIO14 | GPIO15 |
⚠️ HSPI Caution: HSPI uses GPIO12 (strapping pin for flash voltage) and GPIO15 (strapping pin for UART boot output). If using HSPI, ensure these pins are properly managed during boot.
Arduino VSPI Example (TFT Display)
// ESP32 VSPI with TFT Display
#include <SPI.h>
#include <TFT_eSPI.h>
TFT_eSPI tft;
void setup() {
SPI.begin(18, 19, 23, 5); // SCLK=18, MISO=19, MOSI=23, CS=5
tft.begin();
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE);
tft.drawString("ESP32 SPI Test", 10, 10);
}
void loop() {}
Using Both SPI Buses
// ESP32 Dual SPI Bus Example
#include <SPI.h>
SPIClass vspi(VSPI); // SPI3
SPIClass hspi(HSPI); // SPI2
void setup() {
vspi.begin(18, 19, 23, 5); // VSPI pins
hspi.begin(14, 12, 13, 15); // HSPI pins
// Communicate with device on VSPI
vspi.beginTransaction(SPISettings(4000000, MSBFIRST, SPI_MODE0));
digitalWrite(5, LOW);
vspi.transfer(0xAA);
digitalWrite(5, HIGH);
vspi.endTransaction();
}
SPI Speed and Configuration
| Parameter | Range |
|---|---|
| Maximum speed (VSPI) | Up to 80 MHz (with proper PCB design) |
| SPI modes | 0, 1, 2, 3 (all supported) |
| Bit order | MSB first or LSB first |
| Multiple CS pins | Any GPIO can be used as chip select |
Best Practices
- Use VSPI as your primary SPI bus — its pins have no strapping conflicts
- Keep SPI traces short (<10cm) for speeds above 10 MHz
- Add series resistors (22–47Ω) on MOSI/SCLK lines to reduce ringing
- Use separate CS pins for each SPI device on the same bus
- Level shift if connecting 5V SPI devices
🔧 Explore SPI Pin Assignments
Our interactive pinout shows SPI-capable pins and helps you avoid conflicts with other peripherals.
Open Interactive Pinout