- Install
- Basic operation
- Basics of programming for electronic work
- Basics of programming for Excel
- Machine learning with scikit-learn
- Visualizing data with matplotlib
- Web programming
- RPA programming
- Miscellaneous programming
- Reference
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.
| Microcontroller | MISO pin | MOSI pin | SCK pin | Pin location |
|---|---|---|---|---|
| ESP32 (unbranded) | GPIO19 | GPIO23 | GPIO18 | See this diagram |
| Raspberry Pi | GPIO9 | GPIO10 | GPIO11 | See this diagram |
| Raspberry Pi Pico (non-W) | GP16 | GP19 | GP18 | See 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:
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: