Sunspot Home

Testing the small i2c OLED SSD1306 128x64 display on Raspberry Pi

- more notes for backup and a bad memory - -
These notes will be upgraded at random times
This first hack is WORKING but not yet tidy, , , ,

Objective - use the display to follow the execution of a long program
(this just needs a simple display of large text)

This is the i2c version (not my screen display - I just show big text across the top)

Many thanks to

I record below the key lines from this site in case it goes down
apt-get install i2c-tools
i2cdetect 1                -  the device has i2c address 0x3C

For the OLED with SSD1306
install this library

sudo apt-get install python-dev python-pip libfreetype6-dev libjpeg-dev build-essential
sudo -H pip install --upgrade luma.oled
if it fails do -
sudo pip install -U pip

git clone
cd codelectron_projects/Rpi/OLED
My code
Display "Start again" on the top line for 2 seconds

# python /home/pi/codelectron_projects/Rpi/OLED/
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306, ssd1325, ssd1331, sh1106
import time
from PIL import ImageFont, ImageDraw

serial = i2c(port=1, address=0x3C)
device = ssd1306(serial, rotate=0)

# Box and text rendered in portrait mode
with canvas(device) as draw:
    font = ImageFont.truetype('/home/pi/luma.examples/examples/fonts/Volter__28Goldfish_29.ttf',20)
    draw.text((0, 0), "Start again", font=font, fill=255)

At the start line in my big Blassic basic control program I include -
SHELL "python /home/pi/codelectron_projects/Rpi/OLED/"
Blassic runs
At other points in the program I have different displays of text to show where the control program has got to.

Another page gives similar help -

I loaded all the software on offer here and tested the examples
(There is loads of room on a Pi SD card - I may have used parts of SSD1306 code in some tests)

sudo apt install -y git
Then clone the repository using the following command :
git clone

Once that completes navigate to the library’s directory :
cd Adafruit_Python_SSD1306

and install the library for Python 2 :
sudo python install

and/or Python 3 :
sudo python3 install


The display is very small and with some fonts you need young eyes

A simple 16x2 display with i2c driver may be better for text output!
Less than £2 on eBay

Please email me if you want to swap notes