SSD1306 OLED Displays

For many Arduino projects, there is a need to display information graphically or display more text than what fits on a 16×2 LCD. For that need, consider using SSD1306 OLED Displays.

SSD1306 refers to the controller or driver chip for the display. OLED or  Organic Light Emitting Diodes refers to the dot-matrix graphic display system. These displays attach using SPI or I2C thus using less connecting pins versus an LCD.

Here is how to hook-up a I2C SSD1306 OLED display to an Arduino UNO:

SSD1306 OLED Displays (attached to an Arduino UNO)

The Fritzing diagram source is here. The OLED fritzing part is here.

To write Arduino code for SSD1306 OLED displays, we need to find the I2C address. The MiniPirate sketch I wrote about here can be used to find it. Also there is an I2C scanner sketch here. There are also two libraries needed to control the OLED display:

Adafruit SSD1306 Library   Adafruit GFX Library

Once those libraries are added and you have the I2C address, try the following sketch:

The I2C address for my OLED Display is 0x3C so the display.begin code is:

   display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

You will need to change the 0x3C to the address of your display. Also, the library does not detect the resolution of the display. The sample sketches that come with the SSD1306 library mention how to change the library to match the resolution of your display. Basically, look at the code in Adafruit_SSD1306.h and find the lines which define the resolution. Uncomment the one you need and comment the rest. Here is what that code looks like for the OLED display I have:

Here is what the OLED Display looks like when displaying text:

OLED Display attached to an Arduino NanoOLED Display attached to an Arduino Nano

Leave a Reply

Your email address will not be published.