Arduino I2C OLED screen tutorial using U8Glib

arduino oled display ssd1306 u8glib


This tutorial covers how to connect an SSD1306 0.96 inch OLED screen to an Arduino Nano over I2C and display text on it using the U8Glib library.

Hardware Used

Hardware Connections

Arduino OLED
3.3V Vdd
Gnd Gnd
Analog 4 SDA
Analog 5 SCK

U8Glib Install

In this tutorial, I will be using the U8Glib graphics library for the screen. In this tutorial, I do the same but using Adafruits SSD1306 graphics library. 

Method 1:

Downaload the library:

In the Arduino IDE :

sketch > include library > Add .ZIP Library > select the  downloaded ZIP

Method 2:

Or go to sketch > include library > manage libraries > type u8glib in the search bar and click on install.


Here is the bare minimum code to make the display work. If you need more info about the library check out the documentation on GitHub. You can find more examples provided in the Arduino IDE: File > Examples > U8glib.
//Include the graphics library.
#include "U8glib.h" 

//Initialize display.
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE | U8G_I2C_OPT_DEV_0);

void setup(void)
    //Set font.

void loop(void)

    do {
    } while (u8g.nextPage());

    //Delay before repeating the loop.

void draw(void)

    //Write text. (x, y, text)
    u8g.drawStr(20, 40, "Hello World.");

Hello World!

Upload the above-provided code and you should have a  Hello World.

Leave a Reply

Your email address will not be published. Required fields are marked *

The following GDPR rules must be read and accepted:
This form collects your name, email and content so that we can keep track of the comments placed on the website. For more info check our privacy policy where you will get more info on where, how and why we store your data.

Advertisment ad adsense adlogger