Interfacing Arduino Board with SH1107 OLED Display in I2C Mode

This Arduino tutorial demonstrates how to interface an Arduino board with an SH1107 OLED display module featuring a 1.5-inch screen and a resolution of 128×128 pixels.
The project shows how to display text and draw basic shapes (such as circles and rectangles) on the SH1107 OLED, which is configured to operate in I2C mode.

Abbreviations:
OLED: Organic light Emitting Diode.
PLED: Polymer OLED.
TFT: Thin Film Transistor.
I2C: Inter-Integrated Circuit.
SPI: Serial Peripheral Interface.
IoT: Internet of things.

Overview of the SH1107 OLED Display Module:
The SH1107 chip is a CMOS OLED/PLED driver with controller commonly used in small to medium-sized Organic/Polymer light-emitting diode dot-matrix display systems.
The SH1107 chip supports a maximum display resolution of 128×128 pixel and it is designed to drive monochrome OLED panels and is widely used in embedded systems, IoT devices, and consumer electronics.

The SH1107 OLED display module is a compact monochrome graphic display module that uses the SH1107 driver chip. These display modules are typically 128×64 or 128×128 pixels and are commonly available in I2C or SPI communication interfaces. These displays are commonly found in small, low-power devices as they have high contrast, wide viewing angles, and compact size. They are often used in projects involving microcontrollers like Arduino, ESP32, Raspberry Pi, and others.

Properties of the SH1107 OLED Display Module:

  • Resolution: Usually 128×64 or 128×128 pixels, smaller resolutions may be also available.
  • Display Type: Monochrome (one color only that usually white, blue, or yellow pixels on a black background).
  • Interface: Usually supports I2C and/or SPI communication with the I2C be the most common interface.
  • Operating Voltage: Usually 3.3V or 5V, depending on the module.
  • Power Consumption: Very low power usage as the display does not require backlight, making it ideal for battery-powered devices.

The image below shows an example of an SH1107 OLED display module that operates in I2C mode only:

SH1107 OLED display module I2C interface 128x128 pixel

The SH1107 OLED display shown above operates using the I2C interface protocol only. Below is the pinout of the display module, which is essential for connecting it to a microcontroller such as an Arduino, ESP32, Raspberry Pi, or Microchip PIC/dsPIC:

  • VCC: Power supply pin — typically 3.3V or 5V, depending on the module. Refer to your display’s datasheet to confirm the supported voltage. (Note: Some modules are 3.3V only.)
  • GND: Ground pin, connected to circuit common ground.
  • SCL: Serial Clock line of the I2C bus.
  • SDA: Serial Data line of the I2C bus.

Arduino MEGA board with SH1107 OLED display hardware circuit I2C mode

The default I2C address of this module is 0x3C, but it can be changed to 0x3D by shorting resistor R31, or by removing resistor R30 (10k) and placing it on R31 (see the image below).
Additionally, if you are using the same SH1107 display module shown above, it is better to replace resistors R26 and R27 (originally 1k each) with lower-value resistors not exceeding 100 Ohms —for example, use 33 Ohms.

SH1107 OLED change I2C address recommended actions PCB

Some SH1107 display modules support both I2C and SPI interface modes (one mode at a time), allowing users to switch between the two protocols with minor modifications to the module’s PCB.
The image below shows a module that supports both modes, where resistors R3 and R4 are used to select the desired protocol with SPI being the default.
To use the module in I2C mode, simply remove the 4.7 kΩ resistor from R3 and place it on R4.

SH1107 OLED display module SPI and I2C interface protocol 128x128 pixel

In the module shown above, the I2C address is determined by the connection of the DC pin:

  • If DC pin is connected to GND, the address is 0x3C.
  • If DC pin is connected to VCC, the address is 0x3D.

To operate the module in I2C mode:

  • The RES (Reset) pin must either be connected to a digital I/O pin (if reset control is needed) or directly to VCC for a constant active state.
  • The CS (Chip Select) pin must be connected to GND to properly enable I2C communication.

Connection of SH1107 OLED with Arduino hardware circuit I2C mode SPI-I2C module

Interfacing Arduino Board with SH1107 OLED Display in I2C Mode:
The images below show circuit schematic diagrams for interfacing an Arduino MEGA board with an SH1107 OLED display module.
The first schematic illustrates a display module that supports I2C mode only and cannot be used in SPI mode.

Arduino mega interface with SH1107 OLED display I2C mode

The SH1107 OLED display module used in the above schematic has four pins connected to the Arduino MEGA board as follows:
GND pin is connected to GND pin of the Arduino MEGA board.
VCC pin is connected to 3V3 pin of the Arduino MEGA board.
SDA (I2C serial data) is connected to digital pin 20 (SDA) on the Arduino MEGA.
SCL (I2C serial clock) is connected to digital pin 21 (SCL) on the Arduino MEGA.

  • Note: Pins 20 and 21 on the Arduino MEGA are the hardware I2C pins of the ATmega2560 microcontroller, corresponding to the SDA and SCL lines, respectively.

The second schematic shows an SH1107 OLED display module that supports both SPI and I2C protocols, but is configured to operate in I2C mode:

Arduino mega interface with SH1107 OLED display I2C mode SPI module

In this circuit schematic, the SH1107 OLED display module has seven pins connected to the Arduino MEGA board as follows:
GND pin is connected to GND pin of the Arduino MEGA board.
VCC pin is connected to 3V3 pin of the Arduino MEGA board.
SDA (I2C serial data) is connected to digital pin 20 (SDA) on the Arduino MEGA.
SCL (I2C serial clock) is connected to digital pin 21 (SCL) on the Arduino MEGA.
RES (Reset) pin is connected to VCC (3.3V).
DC (Data/Command) pin is connected to GND.
CS (Chip Select) is connected to GND.

Hardware Required:
This is a summary of the components needed to build this project:

  • Arduino MEGA board (based on the ATmega2560 microcontroller – datasheet)
  • SH1107 OLED display module (1.5-inch, 128×128 resolution)
  • Bread board
  • Jumper wires

Interfacing Arduino Board with SH1107 OLED Display in I2C Mode – Arduino Code:
To compile and run the Arduino code for this project, you’ll need to install two libraries from Adafruit Industries:

  1. Adafruit SH1107 OLED Display Library: This is the driver library for the SH1107 display. You can install it using the Arduino IDE Library Manager,
    Go to Sketch → Include Library → Manage Libraries…, search for “sh1107”, and install the version published by Adafruit.
  2. Adafruit GFX Library: This library provides graphics primitives (text, shapes, etc.) and is also available through the Library Manager. In the Arduino IDE Library Manager, Search for “Adafruit GFX” and install the library published by Adafruit.

Note: During the installation of the Adafruit SH1107 library, the Arduino IDE may prompt you to install additional dependency libraries (e.g., Adafruit BusIO)—make sure to accept and install them.

Tested Library Versions:
The following library versions were used to test and verify the project code:

  • Adafruit GFX Library: Version 1.12.1
  • Adafruit SH110X OLED Display Library: Version 2.1.13
  • Adafruit BusIO: Version 1.17.1

Programming Hints:
The required libraries are included in the Arduino code as follows:

The SH1107 display is initialized with a resolution of 128×128 pixels and an I2C clock frequency of 400 kHz:

Before using any display functions (e.g., print, drawLine, etc.), the SH1107 OLED display must be initialized. If the initialization fails, the screen will remain blank. Use the begin() function as shown below, specifying the appropriate I2C address:

Note: The Arduino code provided below is based on an example sketch from the Adafruit SH1107 library. Minor modifications were made to adapt it to this project setup.

Full Arduino code:

Interfacing Arduino Board with SH1107 OLED Display in I2C Mode – Video:
The video below demonstrates the interfacing of an Arduino MEGA board with an SH1107 OLED display using I2C communication.


Discover more from Simple Circuit

Subscribe to get the latest posts sent to your email.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top