Interfacing Arduino with SH1107 OLED Display in SPI Mode

This Arduino project demonstrates how to easily interface an Arduino board with an SH1107 OLED display module featuring a 1.5-inch screen and a 128×128 pixel resolution.
The project illustrates how to display text and draw basic shapes, such as circles and rectangles, on the SH1107 OLED, which is configured to operate in SPI 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.

5V SH1107 OLED display module with Arduino board in SPI mode hardware circuit

Overview of the SH1107 OLED Display Module:
The SH1107 is a CMOS OLED/PLED driver and controller commonly used in small to medium-sized dot-matrix display systems based on organic or polymer light-emitting diodes.
It supports a maximum resolution of 128×128 pixels and is specifically designed to drive monochrome OLED panels.

Thanks to its compact size, low power consumption, and built-in controller functionality, the SH1107 is widely used in embedded systems, IoT devices, and consumer electronics.

The SH1107 OLED display module is a compact monochrome graphic display that uses the SH1107 driver chip. These modules typically come with resolutions of 128×64 or 128×128 pixels and are commonly available with either I2C or SPI communication interfaces.

Thanks to their high contrast, wide viewing angles, low power consumption, and small form factor, SH1107 displays are ideal for space-constrained and battery-powered applications. They are frequently used in projects involving microcontrollers such as Arduino, ESP32, Raspberry Pi, and Microchip PIC/dsPIC, among others.

Properties of the SH1107 OLED Display Module:

  • Resolution: Typically 128×64 or 128×128 pixels; smaller resolutions may also be available.
  • Display Type: Monochrome — displays a single color (commonly white, blue, or yellow) on a black background.
  • Interface: Supports I2C and/or SPI communication protocols. I2C is the most commonly used interface.
  • Operating Voltage: Typically 3.3V or 5V, depending on the specific module design.
  • Power Consumption: Very low, as the OLED display does not require a backlight, making it ideal for battery-powered and energy-efficient applications.

The image below shows an example of an SH1107 OLED display module configured to operate in SPI mode:

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

The SH1107 OLED display shown above is configured to operate using the SPI interface protocol. 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:

  • GND: Ground pin, connected to circuit common ground.
  • VCC: Power supply pin — typically 3.3V or 5V, depending on the module specs.
  • SCL: Serial Clock line of the SPI bus.
  • SDA: Serial Data line of the SPI bus.
  • RES: Active-low reset pin. Used to reset the display. If used, it is connected to any general purpose output pin of the microcontroller.
  • DC: Data/Command selection pin. Connected to a digital output pin on the microcontroller. It determines whether the data on the bus is a command or actual pixel data with logic low for Command and high for Data.
  • CS: Chip Select pin (active low). Connected to a digital pin on the microcontroller. Used to enable or disable the communication with the SSD1331 OLED display.

Arduino MEGA Interface with SH1107 OLED Display in SPI mode:
The image below shows the circuit schematic for interfacing an Arduino MEGA board with an SH1107 OLED display module operating in SPI mode.

The SH1107 display module used in this project has 7 pins, arranged from left to right as follows:
GND (Ground), VCC, SCL (Serial Clock), SDA (Serial Data), RES (Reset), DC (Data/Command), and CS (Chip Select).

Interfacing Arduino with SH1107 OLED display in SPI mode

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 (7-pin version, 1.5-inch screen, 128×128 pixel resolution)
  • 5 x 2k ohm resistor
  • 5 x 1k ohm resistor
  • Breadboard
  • Jumper wires

Since the SH1107 OLED display operates at a 3.3V logic level and the Arduino MEGA uses 5V logic, a resistive voltage divider was used to reduce the Arduino’s 5V output signals to approximately 3.3V.
While a resistive divider is one of the simplest and most cost-effective methods for logic level shifting, more reliable and efficient solutions—such as logic level shifter modules—can also be used, especially for high-speed communication lines.

Since there are five data lines between the Arduino board and the SH1107 OLED display, five resistive voltage dividers are used, each implemented with a 1 kΩ and 2 kΩ resistor.

Connecting a 5V microcontroller directly to the SH1107 OLED display violates the electrical characteristics specified in the display’s datasheet and may damage the display’s controller circuitry. Using voltage dividers (or proper level shifters) ensures safe and reliable operation.

The SH1107 display module is powered with 3.3V from the Arduino board:

  • The GND pin of the SH1107 display is connected to the GND pin of the Arduino.
  • The VCC pin of the display is connected to the 3.3V pin on the Arduino.

The remaining signal pins are connected through voltage dividers to protect the logic circuitry of the display. The connections are as follows:

  • SCL is connected to digital pin 52 of the Arduino.
  • SDA is connected to digital pin 51 of the Arduino.
  • RES is connected to digital pin 27 of the Arduino.
  • DC is connected to digital pin 25 of the Arduino.
  • CS is connected to digital pin 23 of the Arduino.

Note: On the Arduino MEGA (and other boards using the ATmega2560), digital pins 52 and 51 are the hardware SPI pins, corresponding to SCK (Serial Clock) and MOSI (Master-Out Slave-In), respectively.

Arduino MEGA Interface with SH1107 OLED Display in SPI 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 dependencies such as Adafruit BusIO. Make sure to accept and install all required dependencies.

Tested Library Versions:
The following library versions were used to develop and successfully test this project:

  • 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 SPI clock frequency of 8 MHz:

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

Note: The Arduino code provided below is adapted from an example sketch included with the Adafruit SH1107 library.
Minor modifications have been made to suit this project setup (Arduino MEGA + SH1107 in SPI mode).

Full Arduino code:

Interfacing Arduino Board with SH1107 OLED Display in SPI Mode – Video:
The video below demonstrates the interfacing of an Arduino MEGA board with an SH1107 OLED display using I2C communication.
The display visual output in SPI mode is identical to that of I2C mode; however, SPI offers significantly faster data transfer, making it a better choice for applications that require higher display refresh rates or more responsive graphics.

Related Projects:
Interfacing Arduino Board with SH1107 OLED Display in I2C Mode


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