SPI is faster than I2C because it runs at a higher frequency and has less protocol overhead. It requires six or seven pins depending on your module. If your application needs fast display refresh rates — for animations or real-time data — SPI is the better choice over I2C.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/rm-hull/luma.oled/llms.txt
Use this file to discover all available pages before exploring further.
Pin connections
The GPIO pins used for SPI are the same across all Raspberry Pi versions. Connect the display to the P1 header as follows:| Device Pin | Name | Remarks | RPi Pin | RPi Function |
|---|---|---|---|---|
| 1 | VCC | +3.3V Power | P01-17 | 3V3 |
| 2 | GND | Ground | P01-20 | GND |
| 3 | D0 | Clock | P01-23 | GPIO 11 (SCLK) |
| 4 | D1 | MOSI | P01-19 | GPIO 10 (MOSI) |
| 5 | RST | Reset | P01-22 | GPIO 25 |
| 6 | DC | Data/Command | P01-18 | GPIO 24 |
| 7 | CS | Chip Select | P01-24 | GPIO 8 (CE0) |
Enable SPI on Raspberry Pi OS
If
raspi-config is not available, the SPI port can be enabled manually by editing the device tree configuration.
Verify SPI is enabled
Check that the SPI device files exist:Add user to spi and gpio groups
Notes on alternate GPIO pins and ports
If the default GPIO 24 (DC) or GPIO 25 (RST) pins are already in use, you can choose different pins and pass
gpio_DC and/or gpio_RST arguments with the new BCM pin numbers when creating the serial interface. This applies to PCD8544, ST7567, and ST7735 controllers.Because CS is connected to CE0, the display is available on SPI port 0 by default. Connect CS to CE1 to use port 1 instead, then pass
port=1 in your interface call.4-wire vs 3-wire SPI
The terms “4-wire” and “3-wire” SPI can be confusing in this context. In standard SPI documentation they refer to whether MOSI and MISO are separate or combined. For OLED controllers, the meaning is different:- 4-wire SPI: MOSI carries data, and the Data/Command signal is sent out-of-band on a separate GPIO pin (DC). This is the mode supported by luma.oled.
- 3-wire SPI: The Data/Command signal is sent as an extra bit over MOSI, requiring no separate DC pin.