Mini OLED Displays

This page is basically a distillation of the instructions from an Adafruit page on setting up ssd1306 controller displays with the non Raspberry Pi stuff and out of date stripped out – link to original Adafruit page . I have only tested this with the current Rasbian software [ as or Sept 2016 ] but do have it successfully running on a Pi3 and early B.

This assumes you are using the I2C OLED display, for SPI versions work through the original Adafruit instructions rather than these

Firstly make sure the I2C interface is enabled in Rasp-Configuration

Next  install the Python Imaging Library and smbus library by executing:

sudo apt-get install python-imaging python-smbus

Now to download and install the Adafruit SSD1306 python library code and examples

git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
cd Adafruit_Python_SSD1306
sudo python setup.py install

Is is worth checking the I2C interface is working ok at this point with

sudo i2cdetect -y 1 

You should see 3c in the matrix displayed, on a realy old pi you need to change the 1 to a zero.

To check the display go to the example directory

cd Adafruit_Python_SSD1306/examples

open the file image.py, with nano or your editor of choice

This is a general example with code for a range of OLED displays so you need make sure the correct bits are commented out for your display. I tend to use a 64 x 132 I2C display, for this you need to make sure all the SPI config bits are commented out and the

disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST)

line is active [ the default version of the program as installed is configured for a 128 * 32 display].

Once edited save and run ‘python image.py’ and you should see a happy smiling cat.

There aren’t really and instructions I could find on how to actually use the library, but it is relatively easy to work out what to do by looking at the image.py and shapes.py examples. You can pick up the rest looking at the library source on github

Advertisements