Fix OLED showing random noise / garbage pixels (1.3″ SH1106)
A 1.3″ OLED is usually an SH1106, not an SSD1306. With the SSD1306 library it shows edge noise or a shifted image. Use Adafruit_SH110X or U8g2’s SH1106 driver.
Community draft — report a mistake
What you see
I2C scanner: found device at 0x3C
SSD1306 begin OK
Display: text appears shifted 2 px right, columns 0-1 and the right edge
filled with random flickering pixelsI2C scanner: found device at 0x3C
SSD1306 begin OK
Display: text appears shifted 2 px right, columns 0-1 and the right edge
filled with random flickering pixels
Indian shops sell 0.96″ and 1.3″ OLEDs side by side, with the same four pins and the same 0x3C address — but different controller chips. The 1.3″ SH1106 accepts SSD1306 commands well enough to light up, then shows a shifted image with a stripe of random pixels. The right driver fixes it completely.
#include <Adafruit_SH110X.h>
Adafruit_SH1106G display(128, 64, &Wire, -1);
void setup() {
Wire.begin(21, 22);
display.begin(0x3C, true);
display.clearDisplay();
display.setTextColor(SH110X_WHITE);
display.println("Hello");
display.display();
}Quick fix — try in order
- 1
Check the controller of your module
0.96″ modules are almost always SSD1306. 1.3″ modules are almost always SH1106 (sometimes SH1107 or SSD1309). The listing or the chip under the glass tells you.
- 2
Use an SH1106 driver
Adafruit: install Adafruit SH110X, use
Adafruit_SH1106G display(128, 64, &Wire, -1);anddisplay.begin(0x3C, true);. U8g2:U8G2_SH1106_128X64_NONAME_F_HW_I2C. - 3
Clear before first use
Call
clearDisplay()anddisplay()right after begin(). The controller’s RAM powers up with random content — which looks like noise until something overwrites it. - 4
Noise on any controller? Check the bus
Flickering random pixels that change while running point to I2C errors: long wires, missing pull-ups, a 5 V module on a 3.3 V board. Shorten wires and use 100 kHz.
Diagnostic sketch
// 1.3" OLED (SH1106) on an ESP32 — the driver that removes the "random noise" stripe you get
// when this display is driven with the SSD1306 library. SDA -> GPIO21, SCL -> GPIO22, VCC -> 3V3.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
Adafruit_SH1106G display(128, 64, &Wire, -1); // -1: no reset pin on 4-pin modules
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!display.begin(0x3C, true)) { // try 0x3D if your scanner shows that
Serial.println("SH1106 not found at 0x3C - run the I2C scanner");
for (;;) delay(1000);
}
display.clearDisplay(); // wipe the controller RAM: power-on contents look like noise
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println("SH1106 OK");
display.println("No noise at the edges");
display.drawRect(0, 20, 128, 44, SH110X_WHITE); // frame shows the full 128 x 64 area
display.display();
Serial.println("Display initialised");
}
void loop() {}// 1.3" OLED (SH1106) on an ESP32 — the driver that removes the "random noise" stripe you get
// when this display is driven with the SSD1306 library. SDA -> GPIO21, SCL -> GPIO22, VCC -> 3V3.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
Adafruit_SH1106G display(128, 64, &Wire, -1); // -1: no reset pin on 4-pin modules
void setup() {
Serial.begin(115200);
Wire.begin(21, 22);
if (!display.begin(0x3C, true)) { // try 0x3D if your scanner shows that
Serial.println("SH1106 not found at 0x3C - run the I2C scanner");
for (;;) delay(1000);
}
display.clearDisplay(); // wipe the controller RAM: power-on contents look like noise
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(0, 0);
display.println("SH1106 OK");
display.println("No noise at the edges");
display.drawRect(0, 20, 128, 44, SH110X_WHITE); // frame shows the full 128 x 64 area
display.display();
Serial.println("Display initialised");
}
void loop() {}Why it happens
Why does the SSD1306 library almost work on an SH1106?
The two controllers share most commands. But the SH1106 has 132 columns of RAM (the panel shows the middle 128) and no horizontal addressing mode, so SSD1306 code writes to the wrong columns and leaves 2–4 columns uninitialised.
Image is mirrored or upside down
Use the driver’s rotation (setRotation(2) / U8G2_R2) rather than switching drivers.
Only the top half shows
A 128×64 panel set up as 128×32 (or the reverse). Fix the height in the constructor.
Board-specific notes
ESP32: SDA 21, SCL 22, VCC 3V3. Tested SH1106 sketch below; SSD1306 version: SSD1306 with ESP32.
Arduino Uno: The SH1106G buffer also needs 1 KB of RAM. If begin() fails, see allocation failed.
Parts: SSD1306 OLED — sizes and controllers.
Did this fix it?
Thanks — that helps us keep this page right.