Arduino

How to Interface 128×64 OLED Display With Arduino Uno

Interfacing the display module with Arduino in a project gives a better understanding of the inputs and outputs of the Arduino program. There are a variety of displays that can be used in an Arduino project, but the selection of the module depends on the type and amount of data that is to be displayed. This write-up briefly explains the interfacing of a 128×64 OLED display with Arduino.

128×64 OLED display

The full form of OLED is Organic Light Emitting Diode and can be used as an alternative to traditional 16×2 LCD displays for better and detailed output. It is a 0.96-inch display module which has 4 pins and has a resolution of 128×64. This module is a low power consumption module having a high ratio of contrast. Similarly, this module supports both SPI and I2C communication and consumes very low power.

The operating voltage range for this monochromatic display is from 3.3 volts to 5 volts.

The 128×64 OLED display pin configuration is mentioned in the table below:

Pin Description
1(VDD) To supply voltage to the OLED display
2(GND) For grounding the OLED display
3(SCK) The clock input for the OLED display
4(SDA) To send and receiving the data

How to interface 128×64 OLED with Arduino Uno

The OLED display is connected to the Arduino by connecting its clock pin to the analog pin 5 and the  analog pin 4 of the Arduino is connected to its data pin. The schematic of the interfacing of the OLED 128×64 is given as:

How to install the library for 128×64 OLED

To interface the OLED display with Arduino the first step is to install its respective library in the Arduino IDE.

To install the library first you have to open the library manager by clicking on the fourth icon in the list on the extreme left of the Arduino IDE.

Once you have opened the library manager type the keyword u8glib in the gray search space. next you have to find the u8glib by oliver and as you move the cursor down an install icon will appear click on it to install the library.  We have also provided an image illustration below to give an easy understanding for installing the library for the OLED display.

After installing the basic library there is a library for the graphics that is also needed so we can download the library  by writing the keyword gfx in the search space of the library manager.

Next you have to find the  library Adafruit DotStarMatrix by Adafruit and click on the install icon.

Click on the install all icon to install the gfx library:

Hardware Assembly for interfacing 128×64 OLED with Arduino Uno 

After installing the required library for the OLED we have  interfaced the OLED with Arduino by placing the display module on the breadboard. With the help of connecting wire we have connected the pins of OLED to the pins of Arduino Uno. the connections for interacting the OLED with Arduino are made further understandable  form the image posted below:

Arduino Code to interface 128×64 OLED with Arduino Uno

The Arduino code compiled for interfacing the OLED display:

#include "U8glib.h"//library for the OLED
//initializing the OLED Display
U8GLIB_SSD1306_128X64 u8g(U8G_I2C_OPT_NONE|U8G_I2C_OPT_DEV_0);  
void display(void) {
  u8g.setFont(u8g_font_unifont);// setting the font of the data
    u8g.drawStr( 30, 10, "Welcome ");/* displaying the data as well as setting place for the data on OLED*/
  u8g.drawStr( 50, 35, "To");/* displaying the data as well as setting place for the data on OLED*/
  u8g.drawStr( 30, 56, "Linuxhint"); /* displaying the data as well as setting place for the data on OLED*/
}
void setup() {

}
void loop(void) {

}

In the Arduino code first, the library is defined for the display that is “U8glib.h” and after that OLED 128×64 is initialized.

To display the data in the OLED a function named display is created in which the data to be displayed is given. Similarly, the position of the data is also specified for each data line at which it will be displayed.

To set the font of the displayed data the function u8g.setFont() is used and for setting the place for each data and the data which is to be displayed is printed on the OLED is done by the u8g.drawStr() function.

Hardware demonstration for the interfacing 128×64 OLED with Arduino Uno

The output if the Arduino program  compiled for interfacing the OLED 128×64 display with Arduino uno is given as:

Conclusion

The 128×64 OLED is a monochromatic display which can be used for the parameters of the Arduino program. These display modules consume very small amounts of power and have a high brightness and high contrast ratio. The process of interfacing of the 128×64 OLED display is explained in this article. Detailed schematic, hardware configuration and code is also provided.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.