Skip to content

Instantly share code, notes, and snippets.

@helgibbons
Last active July 22, 2026 14:52
Show Gist options
  • Select an option

  • Save helgibbons/6b7561eb1f1e7f434b09a8cd15aeb201 to your computer and use it in GitHub Desktop.

Select an option

Save helgibbons/6b7561eb1f1e7f434b09a8cd15aeb201 to your computer and use it in GitHub Desktop.
OLED SPI on Raspberry Pi 5 / Trixie

Update:

sudo apt update && sudo apt upgrade

Enable SPI:

sudo raspi-config > Interface options

Set permissions:

sudo usermod -a -G i2c,spi,gpio pi(substituting your username for pi)

Install example pre-requisites:

sudo apt install python3-dev python3-pip python3-numpy libfreetype6-dev libjpeg-dev build-essential

sudo apt install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev libportmidi-dev

Download the examples:

git clone https://github.com/rm-hull/luma.examples.git

Create virtual environment:

python3 -m venv ~/luma-env --system-site-packages

Install the library into the virtual environment:

~/luma-env/bin/python -m pip install --upgrade luma.oled

Navigate to the examples directory:

cd ~/luma.examples/examples/

Run an example:

~/luma-env/bin/python bounce.py --display sh1106 --height 128 --rotate 2 --interface spi --gpio-data-command 9 --spi-device 0

(or --spi-device 1 for the front slot)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment