SPI Connection

日本語のページ

Some modules are connected via SPI.
Because it offers faster communication speeds than I2C, it is often used for modules (such as displays) that send and receive large amounts of data.
This page explains how to connect via SPI.

Pins Used for SPI Connections

Depending on the microcontroller, the pins used for SPI connection (MISO/MOSI/SCK) may be fixed, or you may be able to freely configure the pin assignments.

Microcontrollers with Fixed Pins

The MISO/MOSI/SCK pins are fixed on the following microcontrollers.

MicrocontrollerMISO pinMOSI pinSCK pinPin location
ESP32 (unbranded)GPIO19GPIO23GPIO18See this diagram
Raspberry PiGPIO9GPIO10GPIO11See this diagram
Raspberry Pi Pico (non-W)GP16GP19GP18See this diagram

If you are using a microcontroller with fixed MISO/MOSI/SCK pins and an SPI-connected module, use a block that does not specify MISO/MOSI/SCK pin numbers during initialization.
For example, for an OLED display, use the following block:

Initializing an SPI-connected OLED display

Microcontrollers with flexible pin assignments

The following microcontrollers allow you to freely change the pin assignments for MISO, MOSI, and SCK.

  • ESP32-S3
  • ESP32-C3
  • ESP32-C5
  • ESP32-C6
  • Raspberry Pi Pico W
  • Raspberry Pi Pico 2W

When using SPI-connected modules with these microcontrollers, use a block that specifies the pin number during initialization.

For example, for an OLED display, use the following block:

Initialize an SPI-connected OLED display by specifying the pin number