Thursday, July 23, 2015

128x64 OLED display for Arduino

LEVEL: BEGINNER

It's cuter than in the pictures. It finally arrived today. It's a very simple 128x64 pixels display, a little bit smaller than 1 inch (0.96" to be exact). It's very bright and with resolution being what it is, you can clearly see the pixels. But that doesn't really distract from the fact that the display is very nice, and I can hardly wait to think of a project to put it into.
It is compatible with Adafruit library so it was not very complicated to get it to work. There was, however a little confusing part, but I'll explain when we get to that.

Libraries

So, first, you have to download Adafruit libraries. You will need two, both can be found on GitHub.

  1. Adafruit SSD1306 library
  2. Adafruit GFX library

There is a button "Download ZIP" in the lower right corner. Once the libraries are downloaded, you have to import them in Arduino IDE. That is done simply by opening Arduino IDE, then clicking on:
Sketch -> Include Library -> Add .ZIP Library...
That will open a dialog and you just navigate to downloaded files and select one library at the time (you can select either .zip file or folder).

Once both libraries are installed, look in the File -> Examples and you should have "Adafruit SSD1306" with 4 examples. In my case, the 3rd example - 128x64 i2c was the right one.

Connection

Connection couldn't be simpler:

SCL and SDA location on Uno
    OLED    Arduino UNO
     VCC ---- 5V
    GND ---- GND
     SCL ---- SCL
    SDA ---- SDA








Address

There was just one weird thing. The bottom of my display indicates that the address should be 0x78. In the line 61 of the example, there is a following piece of code:

display.begin(SSD1306_SWITCHCAPVCC, 0x3D);  // initialize with the I2C addr 0x3D (for the 128x64)

Substituting 0x3D with 0x78 didn't work. Looking on the net, I found out that putting 0x3C instead does. I tried that and....voila!!!

Front and back side of the display

No comments:

Post a Comment