Quick and visually compelling projects don’t come easy ? Naaah, just like last time – let’s get on a very nice and easy project – attaching display onto Raspberry Pi. As we were chating on the Malinowe Pi Group, Hubert Wu pointed me to a OLED 128×64 display, monochrome. With a quite decent resolution of 128×64 and based on OLED technology this is a nice 0.96 inch display. Well, my first computer was running at Hi-Res of 640×400 and monochrome too. Priced at $3-$5 pops-up as: ”0.96″ I2C IIC Serial 128X64” in popular stores and is clearly based on original Adafruit SSD1306 – which would be my first choice!
What will you need?
- git, python-devel, python-pip (installable under Raspbian on RPi)
- Library with examples from Adafruit: Adafruit_Python_SSD1306
- Raspberry Pi – 1B, 1A, 2B, 3B – any will do with installed Raspbian (mini Raspbian is OK)
- Adafriud OLED SSD 1306 or compatible
This external display connected to RPi (and which is independent from HDMI or Composite video outputs), is very useful for small projects – and for me – when need to know what the IP address is 🙂
First let’s connect power – VCC and GND to 3,3 and GND on RPi, then SDA and SCL to GPIO0 (GPIO 2 @ RPi B+, 2 i 3) and GPIO1 (GPIO 3 @ RPi B+, 2 i 3):
The wiring is quite simple and all pins are adjacent (well we omit GPIO4!). During first wiring attempt i mixed up VCC and GND! RPi greeted me with low light on it’s green LED, but all was fine after proper wiring. This is the view from the display:
On the software side we are going to turn on the I2C (GPIOO or GPIO2 and GPIO1 or GPIO3) in our RPi, by means of running raspi-config, then – (Advanced Options->I2C).
After reboot – we should install the software, but first – let’s update the system:
sudo apt-get update && sudo apt-get upgrade
Next the software:
sudo apt-get install build-essential python-dev python-pip python-imaging python-smbus git
Then the RPi.GPIO:
sudo pip install RPi.GPIO
Now – let’s get via git the Adafruit library with examples:
git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
sudo python setup.py install
Let’s find out if this works…
Now edit the shapes.py and find the line that tells it to use the I2C version of the display:
disp = Adafruit_SSD1306.SSD1306_128_64(rst=RST, i2c_bus=1)
This is correct, add “#’ at the begging of the other lines that define the ‘disp‘ variable
sudo python shapes.py
Wow, it works! There’re more examples – a very nice – animate.py and image.py, just don’t forget to edit them to use the proper definition of the ‘disp’.
As bonus – we can use our own fonts (TTF format) – i.e.: 16pix height:
The image.py allows you to display monochrome picture in PPM – use GIMP to save and use dithering to get acceptable results:
Well, as you see – the input characteristics of the image matters, but at leas you can see the logo
Now all that is left is to use python or bash to display IP address of you RPi!