I2C OLED For Raspberry Pi

From Wiki
Jump to: navigation, search


As015 7.png
Just 1/4th the size of an RPi, the SunFounder 0.9" OLED is an extension to make your projects easier. White-on-blue OLED display is made of 128x32 individual white OLED pixels, each of which is turned on or off by the controller chip - SSD1306 IC. A great way to display debug information and to visualize data without the need of a serial terminal.

The driver chip SSD1306 communicates via I2C, so only 6 pins are required to communicate with Raspberry Pi and you can insert the chip into in all versions of RPis. To make things super interesting, because the display makes its own light, you will not require any backlight. This reduces the power required to run the OLED and is why the display has such a high contrast.

Please note that OLED displays are made of hundreds of...OLEDs! That means each pixel is a little organic LED, and if it's kept on for over 1000 hours it'll start to dim. If you want to keep the display uniformly bright, please turn off the display (set the pixels off) when it isn't needed to keep them from dimming.


  • Size: 0.9 inch
  • Resolution: 128 x32
  • Type: OLED
  • Color: Single white
  • Communication Interface: I2C

Package Including

  • 1 x 0.9 OLED Display

Hardware operation

Connect the module to the Raspberry Pi, plug it to the left
As015 1.jpg
Plug and play without any driver. The screen can display cpu using rate, cpu temperature, internal storage, disk using rate, RPi ip etc.

Software Operation

Firstly, you need to switch on the i2c function RPi.

  1. sudo apt-get install -y python-smbus
  2. sudo apt-get install -y i2c-tools
  3. sudo raspi-config

As015 2.png
As015 2.png
As015 2.png
As015 2.png
As015 2.png
Restart the RPi.

  1. sudo reboot

Install Adafruit-SSD1306 library.
Finish your installation as indicated in the command.

  1. sudo python -m pip install --upgrade pip setuptools wheel

Note: In this step, if there is an error prompt "TypeError: unsupported operand type(s) for -=: ‘Retry’ and ‘int’", you can try to reinstall pip to solve this problem.

  1. sudo apt-get remove python-pip python3-pip
  2. sudo apt-get install python-pip python3-pip

Install the PIL library and some image processing programs use this.

  1. sudo apt-get install python-pil python3-pil

Use pip to install adafruit-ssd1306 library.

  1. sudo pip install Adafruit-SSD1306

Save for downloading a code library containing examples.

  1. cd ~
  2. git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git

In the sample directory, you can see that there is some ready code, after the screen is connected, you can run directly to see the effect.

  1. cd ~/Adafruit_Python_SSD1306/examples/

Final Effect

As015 7.png