Arduino Oled i2c Display 128×64 with examples, Wiring, and Libraries issues solved

(Last Updated On: February 5, 2022)


Arduino Oled i2c Display

Arduino Oled i2c Display– In this tutorial, you will learn how to use the SSD1306 or SH1106 0.96 inch Oled i2c 128×64 Display module with Arduino. In this tutorial, I will cover the extreme basics like for example

  1. Oled i2c Display Interfacing with Arduino
  2. How to fix some common issues?
  3. How to select a proper library for the 128×64 Oled display Module?
  4. How to use the basic Oled functions?
  5. How to print text messages and Numbers on the Oled i2c Display?
  6. How to draw different shapes? And finally
  7. How to make a Weather station using DHT11 Sensor and display the temperature and humidity values on the Oled display.

Without any further delay let’s get started!!!

Note: For step by step explanation and practical demonstration, watch the video given at the end of this article. 

Amazon Links:

12v Adaptor:

Arduino Uno

Arduino Nano

SSD1306 128×64 Oled i2c display Module

DHT11 Temperature and Humidity Module:

Other Tools and Components:

Top Arduino Sensors:

Super Starter kit for Beginners

Digital Oscilloscopes

Variable Supply

Digital Multimeter

Soldering iron kits

PCB small portable drill machines

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!

Oled Technology:

organic light-emitting diodes or Oleds. These were developed during the 20th century the very first commercial device to use old LEDs was a Kodak camera in 2003 in 2013 Samsung became the first company to release OLED televisions and they’re now the biggest manufacturer in the world of OLED television screens now, the Oled we’re going to be using is not as big as TV

screen, but very small one as you can see in the picture below.


Arduino Oled i2c Display

The Oled displays are the kinds of devices you’ll see on items like mp3 radios and smart watches and they’re very nice These things have a lot of excellent properties to use with an Arduino as a display, they are very easy to read, they take a very small current and you can read them from different angles.

About the Oled i2c Display:

Arduino Oled i2c Display

This is a monocolor, 0.96-inch with 128×64 pixels Oled i2c display module. OLED stands for Organic light emitting diode. There are two different models of the same Oled display module which are SSD1306 and SH1106. Only by looking at the Oled display it’s really hard to tell whether this is SSD1306 or SH1106 model. Which I will tell you in a minute how to find this.

Unlike the 16×2 liquid crystal display module, the Oled display does not require backlight, which results in a very nice contrast and moreover the Oled display consumes less power when compared with other displays.

Arduino Oled i2c Display

There are other types of the Oled display modules, which are available in different shapes and sizes, some are using i2c communication protocol, there are also other Oled displays that support the SPI communication. But in this tutorial I will only focus on the Oled display modules that support i2c communication.

This Oled display module can be powered up using 3.3 to 5 volts due to which it can be easily used with 3.3 volts supported controller boards like Nodemcu ESP8266, ESP32, etc and 5 volts supported controller boards like Arduino Uno, Arduino Mega, Arduino Nano and so on.

Oled Display Module Pinout:

Arduino Oled i2c Display

This display Module has a total of 4 male headers which are clearly labeled as VCC, GND, SCL, and SDA.

Arduino Oled i2c Display

This small resistor is the i2c address selector. Currently, the i2c address is the 0x78. But if you remove this resistor and solder it on the other side then the i2c address will become 0x7A. But there are situations when both the i2c addresses are not working, so when you end up in a situation like this, then you will need to use the i2c scanner, which I will explain in the programming section.  So, now let’s have a look at the circuit diagram.

Oled i2c Display Interfacing with Arduino Uno Circuit Diagram:

Arduino Oled i2c Display

As you can see the circuit diagram is really simple. The VCC and GND pins of the 128×64 Oled display module are connected with the Arduino’s 5 volts and ground. While the SCL and SDA pins of the Oled display are connected with the Arduino’s Analog pins A5 and A4 which are the i2c pins. If you are using Arduino Mega then connect these pins with 20 and 21. 20 is the SDA while 21 is the SCL.

I interfaced my 128×64 i2c Oled display with the Arduino as per the circuit diagram already explained.

Arduino Oled i2c Display

Arduino Oled Libraries:

Download: Adafruit_SSD1306.h 

Download: Adafruit_SH1106.h 

Download: Adafruit_GFX.h 

Download: Adafruit_Sensor

To control this Oled display we will need to install the correct libraries. First I am going to start with the Adafruit_SSD1306.h and the Adafruit_GFX.h libraries. And let’s see if I can control this Oled display module using these libraries. Follow the same exact steps as given below:

Open the Arduino IDE and click on the Sketch Menu > Include Library > Manage Libraries or simply press the Ctrl+Shift+I,

Arduino Oled i2c Display

This will open the Library Manager.

Type Adafruit SSD1306 in the search box

Arduino Oled i2c Display

As you can see I have already installed this library.

Now write Adafruit GFX library in the search box and press the install button. As you can see in the picture below, I have already installed this library.

Arduino Oled i2c Display

The libraries which we installed comes with example codes which we can use to test our Oled display module.

Click on the File Menu > Examples > Adafruit SSD1306 > ssd1306_128x64_i2c


Arduino Oled i2c Display

This will open the following program. which is a long program. write now I will not explain the program, because at this point all I need is just to run my Oled display Module. You will need to make some changes in the program given below, change the i2c address, the i2c address of my Oled display module is 0x78.

After uploading the above program, my Oled display module was not showing anything. This may be due to two reasons.

  1. My Oled i2c address is wrong or
  2. Maybe I am using the wrong library which is Adafruit_SSD1306.h

To verify the i2c address, we can use the following i2c scanner. The following program can be used for finding the i2c address of any i2c supported device.

I2C Scanner Code:

After uploading the above program, it gave me 0x3C. which means the I2C address given on the Oled display was wrong. Now, again I updated the program.

Arduino Oled i2c Display

I uploaded the program. This time it turned on the Oled display and I was able to see some animations.

Arduino Oled i2c Display

At first I thought my Oled was damaged. But later I found that this was due to the wrong library. Then what I did, I simply installed another library Adafruit_SH1106.h the download link is given above. This library also comes with example codes.

Arduino Oled i2c Display

The following program will open.

I uploaded the above program and my Oled display module started working.

Arduino Oled i2c Display

Finally, I was able to see some cool animations and texts.

I am not going to explain the above program which is very lengthy, but I will explain the basic functions which I believe you should know.

Basic Oled functions:

Here are some functions that will help you handle the OLED display library to write text or draw simple graphics.

  • display.clearDisplay() – all pixels are off
  • display.drawPixel(x,y, color) – plot a pixel in the x,y coordinates
  • display.setTextSize(n) – set the font size, supports sizes from 1 to 8
  • display.setCursor(x,y) – set the coordinates to start writing text
  • display.print(“message”) – print the characters at location x,y
  • display.display() – call this method for the changes to make effect

So after knowing the basic functions, let’s start with the Hello World example.

Arduino Oled i2c Display Projects:

Arduino Oled i2c Display Hello World! Project

Arduino Oled i2c Display

After uploading the following program, you will see the Hello World! text message on the Oled display.

Now I am going to explain the above program.

I started off by adding the libraries.

#include <Wire.h>

#include <Adafruit_GFX.h>

#include <Adafruit_SH1106.h>

As the 128×64 Oled display the one I am using does not has the reset pin so that’s why I included -1

#define OLED_RESET -1

Adafruit_SH1106 display(OLED_RESET);

In the void setup function, I activated the serial communication and selected 9600 as the baud rate and used the SH1106_SWITCHCAPVCC and 0x3C and finally, I cleared the display using the display.clearDisplay().

void setup() {

  // put your setup code here, to run once:


  display.begin(SH1106_SWITCHCAPVCC, 0x3C);



void loop() {

 I cleared the LCD display.


I selected the font size.


then I selected the cursor position, where I want to print the Hello World! message.


display.print(“Hello World!”);

Finally, I added the following method for the changes to make effect



Drawing different shapes on the 128×64 Oled i2c Display.

Copy and paste the below program into the Arduino IDE. After you Upload this program you will see different shapes on the LCD.

Arduino Oled i2c Display Code explanation:

// Draw a single pixel in white

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display

Arduino Oled i2c Display based Weather Station using DHT11 Temperature and Humidity Module:

Now we will make weather station and display the Temperature and Humidity Values on the 128×64 Oled i2c Display Module using Arduino.

Arduino Oled i2c Display

Arduino Oled i2c display based Weather Station Circuit Diagram:

Arduino Oled i2c Display

The 128×64 Oled i2c display module connections with the Arduino Uno board remain the same. This time I added the DHT11 Temperature and Humidity Module with digital pin 2 of the Arduino. While the power supply pins of the DHT11 sensor are connected with the Arduino’s 5 volts and ground.

Arduino Oled i2c display based Weather Station Programming:

Watch Video Tutorial:


Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...


  1. Your video is pretty good and got things sorted out for me, one problem is your microphone is not very good it’s rather quiet and because I turned the volume up full ,the silly music blasted out……not needed, thank you.

  2. I get an error:
    Arduino:1.8.13 (Windows 8.1), Tarjeta:”NodeMCU 1.0 (ESP-12E Module), 80 MHz, Flash, Legacy (new can return nullptr), All SSL ciphers (most compatible), 4MB (FS:2MB OTA:~1019KB), 2, v2 Lower Memory, Disabled, None, Only Sketch, 115200″

    C:\Users\Daniel\Documents\Arduino\libraries\Adafruit_SH1106-master\Adafruit_SH1106.cpp:31:25: fatal error: util/delay.h: No such file or directory

    #include <util/delay.h>

    compilation terminated.

    exit status 1

    Error compilando para la tarjeta NodeMCU 1.0 (ESP-12E Module).

    Este informe podría contener más información con
    “Mostrar salida detallada durante la compilación”
    opción habilitada en Archivo -> Preferencias.

  3. Like many, I ran into this problem, and spent a lot of time trying to figure out what was wrong. the fact that the mfgr led me astray with the “address” shown on the board is irritating. Enter this solution. Bravo! Clearly written, plenty of code examples, and a USEFUL, step-by-step approach, instead of the “Here’s the solution, now go away!” pages I’ve run into so often. You are to be commended, sir, for spending your valuable time and energy on this project, especially, since you don’t reap any immediate benefit for sharing with us. Again, thank you!

  4. Quite good article. I was having some trouble getting things to work when I first tried it but after I CAREFULLY read your instructions, it was all good — Thanks for the excellent work.

Leave a Reply

%d bloggers like this: