

The SH1106 is a monochrome OLED display driver designed to control OLED panels with a resolution of 128x64 pixels. It is widely used in embedded systems for displaying text, graphics, and simple animations. The SH1106 supports both I2C and SPI communication interfaces, making it versatile and easy to integrate with a variety of microcontrollers, including Arduino, Raspberry Pi, and other development boards.








The SH1106 is a highly efficient display driver with the following key specifications:
| Parameter | Value |
|---|---|
| Display Resolution | 128x64 pixels |
| Communication Interface | I2C or SPI |
| Operating Voltage | 2.4V to 3.6V |
| Logic Voltage | 3.3V (compatible with 5V logic via level shifter) |
| Operating Temperature | -40°C to +85°C |
| Current Consumption | ~20mA (typical, depends on display usage) |
| Pixel Color | Monochrome (white, blue, or yellow depending on OLED panel) |
The SH1106 OLED module typically has the following pinout:
| Pin Name | Pin Number | Description |
|---|---|---|
| GND | 1 | Ground (0V reference) |
| VCC | 2 | Power supply (2.4V to 3.6V) |
| SCL | 3 | Serial Clock Line for I2C communication |
| SDA | 4 | Serial Data Line for I2C communication |
| Pin Name | Pin Number | Description |
|---|---|---|
| GND | 1 | Ground (0V reference) |
| VCC | 2 | Power supply (2.4V to 3.6V) |
| SCK | 3 | Serial Clock Line for SPI communication |
| MOSI | 4 | Master Out Slave In (data input) |
| RES | 5 | Reset pin |
| DC | 6 | Data/Command control pin |
| CS | 7 | Chip Select |
VCC pin to a 3.3V power source and the GND pin to ground.SCL and SDA to the corresponding pins on your microcontroller. For SPI, connect SCK, MOSI, RES, DC, and CS as required.SCL and SDA lines.#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>
// Define the I2C address for the SH1106 display
#define OLED_I2C_ADDRESS 0x3C
// Create an instance of the SH1106 display
Adafruit_SH1106 display(-1); // -1 indicates no reset pin is used
void setup() {
// Initialize the display
if (!display.begin(SH1106_I2C_ADDRESS, OLED_I2C_ADDRESS)) {
Serial.println(F("SH1106 initialization failed!"));
while (1); // Halt execution if initialization fails
}
// Clear the display buffer
display.clearDisplay();
// Display a welcome message
display.setTextSize(1); // Set text size to 1 (smallest)
display.setTextColor(WHITE); // Set text color to white
display.setCursor(0, 0); // Set cursor to top-left corner
display.println(F("Hello, SH1106!")); // Print message
display.display(); // Update the display with the buffer content
}
void loop() {
// Add your main code here
}
Display Not Turning On:
VCC and GND pins are properly connected.No Output on Display:
0x3C) matches the one in your code.Flickering or Artifacts:
Partial Display or Missing Pixels:
Q: Can the SH1106 work with 5V microcontrollers?
A: Yes, but you need to use a level shifter to convert 5V logic to 3.3V to avoid damaging the display.
Q: What is the maximum refresh rate of the SH1106?
A: The refresh rate depends on the communication speed and the size of the data being updated. Typically, it can achieve up to 60Hz with optimized code.
Q: Can I use the SH1106 with Raspberry Pi?
A: Yes, the SH1106 is compatible with Raspberry Pi via I2C or SPI. Use libraries like luma.oled for Python integration.
Q: How do I adjust the brightness of the display?
A: Brightness can be adjusted in software by modifying the contrast register using the appropriate library functions.
This concludes the SH1106 documentation.