How to connect a OLED display with a Raspberry Pi

Problem:

You would like to use a OLED display with a I2C interface with a Raspberry pi using a SH1106 controller , 

Solution:

That type of OLE Display have 4 connections, just follow the next wire schema to connect it to the Raspberry.

Connect the wires directly between the oled display and the Raspberry:

OLED pins >> Raspberry Pi

VDD >> 5V

GND >> GND

SCK >> SCL  ( more information )

SDA >> SDA  ( more information)

*Check the panel in your OLED display to ensure the correct pin definition in the oled panel 

Setup the software:

Activate the I2C Interface option in system configuration, use the command raspi-config and go to interface settings, there you will fine the I2C option.

Install libraries:

Just use the following command: 

sudo apt-get install -y python-smbus 
sudo apt-get install -y i2c-tools
sudo apt-get reinstall build-essential
sudo apt-get install i2c-tools
$ sudo apt-get update
$ sudo apt-get install python3 python3-pip python3-pil libjpeg-dev zlib1g-dev libfreetype6-dev liblcms2-dev libopenjp2-7 libtiff5 -y
$ sudo -H pip3 install luma.oled

Check if the system detect it:

You can check it if you find signal in this interface map, use the
command: sudo i2cdetect -y 1

If it works, you will see something like this:



Working with the Oled and Python:
1.- Clonning the exmaple repository:
$ git clone https://github.com/rm-hull/luma.examples.git
$ cd luma.examples

2.- install libraries
sudo -H pip install -e .

3.- run examples
cd examples
sudo python3 3d_box.py

Hardware: