User avatar
raspberrypiguy1
Posts: 379
Joined: Sun Sep 02, 2012 7:01 pm

Raspberry Pi - OLED Displays

Mon Dec 30, 2013 10:05 am

Hello all,

I have recently made a tutorial for Adafruit's fantastic small OLED Displays... You can check it out here: http://www.youtube.com/watch?v=BeBfpJnN ... z0nLaGygPw

This forum post is simply a write up of the commands that I use in the video, so if you want to give it a go then it will all make more sense if you watch the tutorial! :D

1) After you have wired up your display boot up your Raspberry Pi and log in. You do not need to start up the desktop! We will only be using the terminal.

2) The first thing that we will need to do is to make sure that we have git-core installed. This will allow us to download all of the necessary libraries later. You can do this with this command:

Code: Select all

sudo apt-get install git-core
3) Once that has installed we will need to unblock the Pi's SPI pins... If we don't then we will not be able to communicate with our OLED! Do this by typing in:

Code: Select all

sudo nano /etc/modprobe.d/raspi-blacklist.conf
You should see a file with 3 lines of text in it... We are going to edit one of them! Edit the line that looks like this:

Code: Select all

blacklist spi-bcm2708
AND change it to this

Code: Select all

# blacklist spi-bcm2708
4) In order for those additions to take effect we will need to reboot and you can do that with the command:

Code: Select all

sudo reboot
5) So now that your Pi has rebooted the next thing we are going to do is grab the all-in-one installation script that I talk about in the video. Do this with the command:

Code: Select all

git clone https://github.com/the-raspberry-pi-guy/OLED
That should take a few seconds...

6) Now change in to your new OLED directory with the command:

Code: Select all

cd OLED
7) Now before we can use anything we will need to run the installation script... You can do that with this command here:

Code: Select all

sh OLEDinstall.sh
That will take around 7 minutes!

8) Now that we have everything installed we can use the Python examples that I have provided. Change into the python-examples directory with the command:

Code: Select all

cd python-examples
9) I have included 4 Python examples in this tutorial! I will just explain what they do:

OLEDtext.py is the most basic and it displays text in various forms on to your OLED display. This illustrates font size and positioning.

OLEDip.py finds your internal IP address and prints it to the display. Perfect for all those SSHing people out there!

OLEDclock.py displays the date and clock... It does so by vertically scrolling every second

OLEDimage.py takes any image and converts it into a usable format. It then displays it on the OLED display!

10) You use these programs by typing:

Code: Select all

sudo python OLEDtext.py
< for the text program

Code: Select all

sudo python OLEDip.py
< for the IP program

Code: Select all

sudo python OLEDclock.py
< for the clock program

Code: Select all

sudo python OLEDimage.py <nameofimage>
< for the image program

I have included some pictures of penguins as an example of the OLEDimage.py program... Use it with this command:

Code: Select all

sudo python OLEDimage.py penguins900x600.jpg


And that is it! I hope that you enjoy the tutorial and if you have any problems/issues please address them where I will see them at: theraspberrypiguy@gmail.com

Thanks for watching!

The Raspberry Pi Guy
Matt, The Raspberry Pi Guy YouTube channel, author of Learn Robotics with Raspberry Pi, available now: http://mybook.to/raspirobots, Computer Science & Electronics Undergraduate at The University of Edinburgh

chorlton2080
Posts: 129
Joined: Sun Dec 23, 2012 9:44 pm

Re: Raspberry Pi - OLED Displays

Fri Jan 03, 2014 11:54 am

Superb tutorial. I've just placed an order.

Do you know (or can you measure) the power consumption when displaying full screen text or graphics?

mypifi
Posts: 131
Joined: Sun Oct 21, 2012 1:28 pm
Location: oxford
Contact: Website

Re: Raspberry Pi - OLED Displays

Sun Jan 05, 2014 2:09 pm

many thanks mine is now working and blogged. :)

Return to “Graphics, sound and multimedia”