SH1106 1.3 inch OLED

The 1.3 inch 128x64 OLED module. Aliases: 1.3 inch OLED, SH1106G.

It looks like a bigger SSD1306 and sits on the same two wires at the same address, 0x3C, and it is a different controller. An SSD1306 sketch on it shows a picture two pixels out of place with a stripe of noise down one side, or all its pixels piled into the top eight rows, and that is what this part shows too, because it is the difference people need to see.

Pins

Pin What it does
GND Ground.
VCC Supply, 3.3 V or 5 V.
SCL Open-drain clock; the module has its own pull-up.
SDA Open-drain data; the module has its own pull-up.

Properties

address: the I2C address, 0x3C by default.

What is different from the SSD1306

132 columns of RAM for 128 of glass. The glass is wired to columns 2 to 129, so a driver has to start every page at column 2. One that starts at 0 draws its first two columns where nobody can see them and never writes the last two, which keep whatever was there.

Page addressing only. There is no horizontal addressing mode and no column or page window: 0x20, 0x21 and 0x22 are not SH1106 commands, and the bytes that follow them are read as commands of their own. The column counter walks along one page and the page never moves on by itself, so the SSD1306 habit of sending all 1024 bytes in one run puts every one of them in the top page.

No 0x8D charge pump. The SH1106's DC-DC converter is 0xAD 0x8B (on) or 0xAD 0x8A (off), and it starts on, so the glass lights without it.

Everything else is the SSD1306's: the 0x00/0x40 control bytes, contrast, inverse, display on and off, and the 0xA1/0xC8 pair that turns the picture upright.

What it does not model

The same as the SSD1306: no clock stretching, no read transfers, no bus errors, and the multiplex, offset, clock, pre-charge, COM pin and VCOM commands are taken and change nothing. The read-modify-write mode (0xE0, 0xEE) is accepted and does nothing, since nothing reads the RAM back. Contrast reaches the picture as sixteen steps.

Code

#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>

Adafruit_SH1106G display(128, 64, &Wire, -1);

void setup() {
  display.begin(0x3C, true);
  display.clearDisplay();
  display.setTextColor(SH110X_WHITE);
  display.setCursor(0, 0);
  display.println("SH1106, from column 2");
  display.drawRect(0, 16, 128, 48, SH110X_WHITE);
  display.display();
}

void loop() {}

Adafruit_SH110X.h is Mokxi's own, with the same calls as upstream's Adafruit_SH1106G; its display() sends each changed page from column 2. U8g2's SH1106 constructors are not here; use this header instead.

Common mistakes

Using Adafruit_SSD1306 because the module looks like one: the picture is shifted and mostly missing. Starting pages at column 0 in a hand-written driver.

See it in action

Three small screens at /templates starts an SH1106, a 128x32 SSD1306 and a Nokia 5110 by hand, side by side. Or put an sh1106 in the place of the OLED in OLED dice, leave the sketch alone, and see what an SSD1306 driver does to it.