Working with an SSD1306 0.96″ OLED display on the Raspberry Pi

I’m always on the lookout for cheap electronics on eBay and AliExpress. Following on from my previous tutorial on HD44780 screens, this time, I found a small OLED display.

I bought one of these from eBay for less than £5 plus postage. It is a 0.96″, 128×64 pixel OLED display. These things are really tiny, but useful if you’re after something to display status information. They run from the I2C bus, this one using address 0x3C. This means that all the other addresses are available for you to use to get I2C sensor readings from or to drive other displays. You can even change the address on these displays to allow you to use multiple of the same device.

I did a quick Google to find out how to use it with the Raspberry Pi. I used some of the instructions on this page but found them to be out of date, so I ended up doing things slightly differently.

First of all, make sure your Pi has some essential packages. Most are pre-installed, but you’ll get updates this way:

sudo apt-get install build-essential python-dev python-pip python-imaging python-smbus git

Then, grab the Adafruit library from GitHub:

git clone

Install the library for python3:

cd Adafruit_Python_SSD1306
sudo python3 install

Now take a look at the examples:

cd examples

In the examples, I changed the “disp =” statement to use the line with a 128×64 display running on I2C.

The example scripts provided by Adafruit are:

  • Animated text rolling across the screen.
  • Representation of some buttons (which is weird because it’s not a touch screen!).
  • A PPM image translated onto the screen.
  • Some geometric shapes.
  • Some stats from the Pi – the IP address, disk & memory usage and CPU load.

You can see how these scripts work in the video below. Pardon the shaky cam work, I’ve lost my little tripod!

All the scripts are pretty easy to understand and modify.

I’ve seen these used to display the time, Pi information such as that in the example screen and even as a status display for different robot modes, so they are really versatile.

Addendum: Also worth a look is this other Python library called luma-oled. Thanks to Brian Welsby for that!

Getting an HD44780 16×2 LCD working on the Raspberry Pi – a tutorial

This post is all about HD44780 LCD screens and how to use them in your projects.

I’ve recently been thinking about what my next project will be. I’ve previously experimented with handheld enclosures such as these ones:

and I wanted to do another handheld device. So, I took a look around and found these ones on the Rapid Electronics website:

I thought to myself: that gap in the sloped part looks about the right size for a 16×2 LCD display. These LCDs are quite inexpensive, so I had a look on eBay and found these ones for about £5 which are HD44780-type. In particular, they offer an option with an I2C backpack driven by a PCF8574 chip. I like I2C – it allows you to use many devices on a single ‘bus’ which, in I2C’s case, amounts to 4 wires – one for power, one for ground and two for SDA and SCL, which of course the Raspberry Pi has as you can see in this diagram on Here’s a picture of the reverse of the LCD with the I2C backpack showing:

I attached the LCD to the Pi using jumper cables, making sure to get SDA and SCL connected the correct way round (SDA to SDA, SCL to SCL). To start with, I connected the power line to 3v3 but this had the effect of making text come out in black on a blue background. Fortunately, I realised and swapped it over to the 5V line which resulted in the text displaying nice and bright in white (see the picture at the top of the screen).

I then looked around for the software to drive the LCD. I knew that previously I’d used an Adafruit library (and before that, I used the smbus library, which is even more complicated). Fortunately, I came across a library written by Danilo Bargen called RPLCD.

Using this library is very easy. You can see the library source code on the GitHub repository and read all about how to use it at ReadTheDocs.

To install it, do the following to get RPLCD and also install the I2C base library. You will also need to go into Preferences->Raspberry Pi Configuration and make sure I2C is turned on (and reboot).

sudo pip3 install RPLCD
sudo apt-get install python-smbus

Next, run the following command to find out the I2C address of the LCD (mine was 0x3F, which comes in useful later).

i2cdetect -y 1

For me, the pip install placed a test file in the home folder. However, if it doesn’t do this, run the following command:

wget > /home/pi/

Then run the test script by specifying all the required options. These may be different for you, depending on which I2C or other controller you have working for you.

cd ~
python3 i2c testsuite expander=PCF8574 cols=16 rows=2 addr=0x3f

For a test script with all the parameters set in the Python file itself, and with the LCD initialised, clone my repository:

git clone

and run the script:


This test script does a few things:

  1. Import the necessary libraries.
  2. Initialise the LCD.
  3. Print Hello World to the screen.
  4. Wait 5 seconds.
  5. Clear the screen and power off the backlight.

These are great, cheap screens if all you want to do is display some data or text to the user. I used it on my Picorder way back when and, in my new project (which, yes, is probably going to be another Picorder, but new-and-improved) it will be displaying data from sensors once again.

Makers Unite at the Guild of Makers launch event – Friday, 16th March, Birmingham, UK

Dr Lucy Rogers, of Robot Wars fame and founder of the Guild of Makers, has been in touch. Next Friday (16th March), the Guild is holding their launch event at Autodesk in Birmingham. If any of you consider yourselves ‘Makers’, this is a great event to go to, and a great initiative to get involved with.

If you’d like to attend, you can get tickets from WebCollect. The good news is that due to donations and sponsorship, there are 5 tickets to the event available for free if you’re unable to afford it but wish to attend. To find out if any are still available, DM Dr Lucy Rogers on Twitter.

More about the Guild of Makers

If you’ve not heard of the Guild, or need a refresher, keep on reading! 🙂

The Guild has the following mission:

To promote growth of the Maker Industry by celebrating & encouraging excellence & by supporting professional Makers and those aspiring to be.

It’s aims are as follows:

  • Promote and celebrate excellence in Makers to industry and the public
  • Bring together skilled Makers who:
    • share ideas
    • share values
    • share ideals
    • are willing to help other by being open, supportive, positive and constructive at all time
    • are willing to learn from others

The Guild of Makers is a membership organisation and offers:

  • Networking face-to-face with people who share the same values and  aims of professionalism and excellence
  • Networking virtually with people who share the same values and aims of professionalism and excellence
  • Support and guidance from other Makers
  • Reduced charges for advice, services and/or goods from Maker-friendly companies
  • Personalised web pages within the Guild website for full commercial sponsors
  • Discount on Guild of Makers events as advised when events are publicised.
  • Opportunity to appear in Show and Tell sessions at events and within online elements of the Guild
  • Electronic newsletter with a focus on inspirational and innovative makers
  • Directory of Makers – a page per member:
    • Links to member’s websites and social media accounts
    • Sharing of members and Guild photographs and video
  • (tbc) Accreditation by peers, helping individuals to gain contracts in industry
  • (tbc) A brokerage to match individual Makers with industries with requirements
  • (tbc) A voice for the Maker Industry

More about the launch event

Speakers at the launch event will be as follows:

The event also sports workshops in the afternoon and you can find more info about those here.

So, once again, if you’d like to get tickets, visit WebCollect or DM Dr Lucy Rogers about those 5 free tickets.

Control your pi-topPULSE HAT using Sonic Pi 3

Robin Newman has recently been experimenting with Python OSC which, among other things, can be used to tie Python and Sonic Pi’s Ruby implementation together. This way, you can control a device driven by Python from inside Sonic Pi. Once such device is the pi-topPULSE HAT which features an audio amplifier, a speaker, a 7×7 LED matrix and a microphone. Robin has written up how to control the LED matrix from Sonic Pi over on his blog, so head over there to read more. You can see the programs and the PULSE in action below.

You can buy the pi-topPULSE directly from pi-top here or from The Pi Hut hereNote: You do not need a pi-top to use the PULSE HAT, it can be plugged directly onto the Raspberry Pi’s GPIO pins.

Young people! Show off your projects at Coolest Projects UK – 28th April, London

The Raspberry Pi Foundation and CoderDojo are holding a special event for young people (under 18s only) – it’s called Coolest Projects. From the website:

Coolest Projects is a world-leading annual showcase that empowers and inspires the next generation of digital creators, innovators, changemakers, and entrepreneurs. Young people across the whole Raspberry Pi community, from Dojos, Code Clubs, and Raspberry Jams come to the event to exhibit the cool ideas they have been working on throughout the year.

Coolest Projects will take place at Here East on the Olympic Park from 10am-6pm on Saturday 28th April 2018 and sports free entry all day for ticket holders.

So, if you have a project or a make you’ve been working on and would like to show it off, and you’re 17 or under, head over to Eventbrite to book your ticket or visit the Coolest Projects UK website to find out more.

Here are some highlights from the 2017 flagship event:

Create a starfield/particle river on RGB LED matrices with the Raspberry Pi

Instructables user ‘dearner’ has taken a Raspberry Pi, four 32×32 RGB LED matrix boards, an Adafruit RGB matrix HAT, a good extra power supply for the matrices and some smaller parts and created a long LED display. He’s then created some software to generate the starfield effect and put it on the Pi. The effect (which you can see below) is strangely beautiful. The whole thing is written up as a tutorial which you can see hereBeware: some of the inline Python code is not indented, so you might need to figure that out for yourself.

You can see the starfield in action below: