An example showing simple use of a small monochrome OLED display based on the widely-used SSD1309 controller via the SPI interface. It should also work on compatible displays such as those based on the SSD1306.
Such displays typically support either I2C or SPI. For this example you will need one configured for SPI.
The interface uses one of the Pico’s onboard SPI peripherals and two extra GPIO pins. The code simply initialises the display and shows some text in a basic font: it aims to be easy-to-follow rather than a full-featured driver.
For details of the commands supported by the SSD1309 controller and its addressing modes see the manufacturer’s datasheet: https://www.hpinfotech.ro/SSD1309.pdf.
Note that the SPI interface for the SSD1309 is transmit-only.
Wiring up the device requires seven jumpers as follows:
-
Display CS (chip select) → Pico GP17 (SPI0 CSn), pin 22
-
Display DC (data/command) → Pico GP20, pin 26
-
Display RES (reset) → Pico GP21, pin 27
-
Display SDA (MOSI) → Pico GP19 (SPI0 TX), pin 25
-
Display SCLK (SPI clock) → Pico GP18 (SPI0 SCK), pin 24
-
Display VDD (3.3v) → Pico 3V3_OUT, pin 36
-
Display VSS (0v, gnd) → Pico GND, pin 23
The example uses SPI device 0 and powers the display from the Pico 3.3v output. If you power the display from an external supply then ensure that the Pico’s logic pins are not exposed to any voltage higher than 3.3v.
|
Note
|
The pins on your board may be labelled slightly differently to the list above. Check the documentation for your display. You can change the code to use different pins if you like, but the ones for CSn, TX and SCK must match your SPI device: see the GPIO Function Select Table in the datasheet. |
- CMakeLists.txt
-
A file to configure the CMake build system for the example.
- ssd1309_spi.c
-
The example code.
- ssd1309_font.h
-
A basic 8x8 bit font table used by the example.
Item |
Quantity |
Details |
Breadboard |
1 |
generic part |
Raspberry Pi Pico or Pico 2 |
1 |
|
SSD1309-based OLED display panel with SPI interface |
1 |
generic part |
M/F Jumper wires (assorted colours) |
7 |
generic part |
