If your screen isn’t working you should start at the beginning of this tutorial and work through it. Please see the Change Raspberry Pi I2C Bus Speed post. If you are displaying multiple images per second it is worth increasing the bus speed of the interface as it can improve performance. The library can handle both just make sure you use the correct filename and extension in your scripts. It also means your Python script doesn’t need to convert them. I prefer creating “pbm” files as they are black and white and much smaller files. If you don’t have a colour screen you can switch to pbm or png. Adafruit use ppm as the library also supports their colour OLED modules. The Adafruit example image is a “ppm” file because it is colour although it is converted to monochrome at the point it is displayed on the screen.
Now we are ready to test some examples scripts. Navigate into the “examples” directory : cd examples This process will give you ability to include the library within your own Python scripts.
Once that completes navigate to the library’s directory : cd Adafruit_Python_SSD1306Īnd install the library for Python 2 : sudo python setup.py installĪnd/or Python 3 : sudo python3 setup.py install Then clone the repository using the following command : git clone Ensure git is installed by running : sudo apt install -y git To install the library we will clone the Adafruit git repository. It should work with all SSD1306 based displays including their own 128×32 and 128×64 devices. In order to display text, shapes and images you can use the Adafruit Python library. If you’ve got an original Model B Rev 1 Pi then type the following command instead : i2cdetect -y 0 Install OLED Python Library
I’ve got no idea why the device PCB suggests the address is “0x78” when it is clearly “0x3c”. This is the default hex address for this type of device. This was good news as it showed the device had been detected with an address of “0x3c”. With the I2C libraries installed I used the i2cdetect command to find the module on the I2C bus. Finding the OLED Display Module’s Address I would recommend using Python 3 unless you have a really good reason for using Python 2. If you are using Python 2 then use these commands instead : sudo apt install -y python-dev
Sudo apt install -y python-smbus i2c-tools The following libraries may already be installed but run these commands anyway to make sure : sudo apt install -y python3-dev
You can do this within the raspi-config tool on the command line by running : sudo raspi-configįor additional details on this step please see my how to Enable the I2C Interface on the Raspberry Pi post. The I2C interface is disabled by default so you need to enable it. ** You can connect the Gnd pin to either Pin 6, 9, 14, 20, 25, 30, 34 or 39 as they all provide Ground. * You can connect the Vcc pin to either Pin 1 or 17 as they both provide 3.3V. I connected them directly to the Raspberry Pi’s GPIO header using the following scheme : OLED Pin