SH1106 OLED Arduino: Fix the 1.3 Inch Snow Screen, U8g2 and Code
SH1106 OLED Arduino guide: why a 1.3 inch OLED shows snow and a shift, U8g2 and Adafruit SH110X, I2C and SPI wiring, 0x3C/0x3D address, ESP32 and Pico code.
Behind almost every SH1106 OLED Arduino search there's the same story: you buy a 1.3 inch OLED, upload the SSD1306 code that works on your 0.96 inch screen, and get a snowy TV picture, text shifted to the right or a few lines of random pixels. The display isn't broken; most 1.3 inch modules don't use the SSD1306 but the SH1106, a very similar driver chip with a different memory layout. With the right library the same screen works perfectly.
In this guide you'll learn the difference between the SH1106 and the SSD1306 and exactly why the snow and the 2-pixel shift happen. Then we'll run the display on an Arduino Uno with the U8g2 and Adafruit SH110X libraries and go through I2C and SPI wiring, choosing between 0x3C and 0x3D, and a common pin order mistake. Finally we'll write ESP32 code and a short MicroPython driver for the Raspberry Pi Pico that needs no library.

What is the SH1106 and how does it differ from the SSD1306?
The SH1106 is a 132 × 64 pixel monochrome OLED driver from Sino Wealth. Most of its commands match the SSD1306: display on/off, contrast, flipping and page selection are identical. Two important differences cause the trouble. The first is memory width: the SH1106 has 132 columns of memory while the panel shows 128 pixels, so the picture usually starts at column 2. The second is addressing: in "horizontal addressing" mode the SSD1306 accepts all 1024 bytes in one go and wraps the lines itself; the SH1106 doesn't know this mode and only supports page addressing, so each of the 8 pages must be selected separately and sent 128 bytes at a time.
| Feature | SSD1306 | SH1106 |
|---|---|---|
| Internal memory | 128 × 64 (1024 bytes) | 132 × 64 (1056 bytes) |
| Start of visible area | Column 0 | Usually column 2 (centred 128 pixels) |
| Addressing modes | Page, horizontal, vertical | Page only |
| Hardware scroll commands | Yes (horizontal and diagonal scrolling) | No |
| Internal charge pump command | 0x8D, 0x14 | 0xAD, 0x8B (DC-DC) |
| I2C speed | Up to 400 kHz | Up to 400 kHz |
| Typical module size | 0.91 and 0.96 inch | 1.3 inch |
| Arduino library | Adafruit SSD1306, U8g2 | Adafruit SH110X, U8g2 (SH1106 constructor) |
0.96 inch vs 1.3 inch OLED compared
| Feature | 0.96 inch OLED | 1.3 inch OLED |
|---|---|---|
| Resolution | 128 × 64 | 128 × 64 |
| Active area | About 21.7 × 10.9 mm | About 29.4 × 14.7 mm |
| Pixel pitch | About 0.17 mm | About 0.23 mm |
| Usual driver | SSD1306 | SH1106 (SSD1306 on some models) |
| Colour options | White, blue, yellow-blue | White, blue |
| Interface | 4-pin I2C or 7-pin SPI | 4-pin I2C or 7-pin SPI |
| When to choose it | Small enclosures, wearables | Text read from a distance, big digits, menus |
Since the resolution is the same, a 1.3 inch screen doesn't fit more information; the same text simply looks about 35% bigger. That makes the digits of a thermometer or clock easier to read from a metre away. To find out which driver your module uses, check the seller's page, the print on the back of the module or, most practically, run a test: if the picture is snowy and shifted with SSD1306 code, the driver is an SH1106. Large 2.42 inch modules usually carry an SSD1309, which is largely compatible with SSD1306 commands. For a general comparison of display types, see the Arduino display types article.
Why does the SSD1306 driver cause snow and a shift?
When you call display(), the Adafruit SSD1306 library assumes the screen is in horizontal addressing mode and sends the 1024 bytes in one stream. The SH1106 doesn't recognise that mode command; when its column counter reaches 131 it doesn't move to the next page but wraps around on the same page. As a result most of the data is written over the first page, and the other pages keep showing the random memory content from power-up, the "snow". Even if a library writes page by page, starting the column at 0 shifts the picture 2 pixels to the left and leaves a 2-column strip of garbage on the right edge. The right driver starts the column at 2 on every page and sends the 8 pages separately; all the code in this guide does exactly that.
Wiring: the I2C version
| OLED pin | Arduino Uno | ESP32 | Raspberry Pi Pico | Note |
|---|---|---|---|---|
| VCC (VDD) | 5V or 3.3V | 3V3 | 3V3(OUT), pin 36 | Most modules have a 3.3 V regulator |
| GND | GND | GND | GND | Common ground |
| SCL (SCK) | A5 | GPIO22 | GP5, pin 7 | I2C clock line |
| SDA | A4 | GPIO21 | GP4, pin 6 | I2C data line |
The I2C address is almost always 0x3C; if the small resistor on the back is soldered in the other position, it becomes 0x3D. Don't be confused if the back says 0x78 or 0x7A: those are the 8-bit write form of the same address (0x3C × 2 = 0x78). You pass the 7-bit address (0x3C) to the Adafruit SH110X library, but the 8-bit value (0x78 or 0x7A) to U8g2's setI2CAddress(). If you're unsure about the address, run an I2C scanner; you can see how the bus works in the what is I2C article and the board pins in the pinout tool. Modules usually have 4.7–10 kΩ pull-up resistors on board, so no extra resistors are needed.
SH1106 with U8g2 (Arduino Uno)
U8g2 bundles hundreds of monochrome displays into one library and lets you pick the display type by constructor name. For 1.3 inch modules the right name starts with U8G2_SH1106_128X64_NONAME; the letter after it sets the buffer type and the last part sets the interface. Search for "U8g2" in the Library Manager and install the library by oliver. The sketch below draws a frame along the very edges of the screen and shows some text, a seconds counter and a progress bar; if you can see all four edges of the frame, the driver is right.
1// 1,3 inç SH1106 OLED + Arduino Uno, U8g2 (I2C) / 1.3 inch SH1106 OLED + Arduino Uno, U8g2 (I2C)
2#include <Wire.h>
3#include <U8g2lib.h>
4
5// F = tam tampon, 1024 bayt RAM / full buffer, 1024 bytes of RAM
6U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
7
8void setup() {
9 // u8g2.setI2CAddress(0x3D * 2); // Adres 0x3D ise aç; U8g2 8 bitlik adres ister / enable if your address is 0x3D
10 u8g2.setBusClock(400000); // 400 kHz I2C, begin() öncesinde / before begin()
11 u8g2.begin();
12}
13
14void loop() {
15 u8g2.clearBuffer();
16 u8g2.drawFrame(0, 0, 128, 64); // Kenar çerçevesi: kayma varsa hemen görürsün / the border reveals any shift
17 u8g2.setFont(u8g2_font_ncenB10_tr);
18 u8g2.drawStr(8, 20, "SH1106 1.3\"");
19 u8g2.setFont(u8g2_font_6x10_tf);
20 u8g2.setCursor(8, 40);
21 u8g2.print("Sure / Time: ");
22 u8g2.print(millis() / 1000);
23 u8g2.print(" s");
24 int w = (millis() / 50) % 112; // İlerleme çubuğu / progress bar
25 u8g2.drawBox(8, 48, w, 8);
26 u8g2.sendBuffer(); // Tamponu ekrana gönder / send the buffer to the display
27 delay(50);
28}
29| Constructor (U8g2) | RAM use | When? |
|---|---|---|
| U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | 1024 bytes | Easiest use with a single display on the Uno (clearBuffer and sendBuffer) |
| U8G2_SH1106_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | 128 bytes | When RAM gets tight on the Uno; drawing happens inside a firstPage and nextPage loop |
| U8G2_SH1106_128X64_NONAME_2_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | 256 bytes | Middle ground, about twice as fast as the page buffer |
| U8G2_SH1106_128X64_NONAME_F_4W_HW_SPI u8g2(U8G2_R0, 10, 9, 8); | 1024 bytes | 7-pin SPI module; order is CS, DC, RESET |
| U8G2_SH1106_128X64_VCOMH0_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | 1024 bytes | Some modules that look dim or flicker with NONAME |
| U8G2_SH1106_128X64_WINSTAR_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE); | 1024 bytes | Winstar-brand panels |
SH1106 with the Adafruit SH110X library
If you've written code with Adafruit SSD1306 before, the easiest switch is the Adafruit SH110X library; all the Adafruit GFX drawing functions (drawLine, drawCircle, print, drawBitmap) work exactly as before. Install "Adafruit SH110X" from the Library Manager; Adafruit GFX and BusIO come along as dependencies. The library always drives the display with a 1024-byte buffer, so on the Uno half of the 2 KB of RAM goes to the screen.
1// 1,3 inç SH1106 OLED + Arduino Uno, Adafruit SH110X (I2C)
2#include <Wire.h>
3#include <Adafruit_GFX.h>
4#include <Adafruit_SH110X.h>
5
6Adafruit_SH1106G display(128, 64, &Wire, -1); // -1 = RESET pini yok / no RESET pin
7
8void setup() {
9 Serial.begin(115200);
10 delay(250); // Ekranın açılmasını bekle / let the display power up
11 if (!display.begin(0x3C, true)) { // 0x3D ise burayı değiştir / change here if 0x3D
12 Serial.println(F("SH1106 bulunamadi / not found"));
13 while (true) {}
14 }
15 display.clearDisplay();
16 display.setTextSize(1);
17 display.setTextColor(SH110X_WHITE); // SSD1306_WHITE yerine / instead of SSD1306_WHITE
18 display.setCursor(0, 0);
19 display.println(F("Adafruit SH110X"));
20 display.drawRect(0, 12, 128, 52, SH110X_WHITE);
21 display.drawCircle(32, 38, 18, SH110X_WHITE);
22 display.fillTriangle(70, 56, 90, 20, 110, 56, SH110X_WHITE);
23 display.display(); // Çizimi ekrana aktar / push the drawing to the display
24}
25
26void loop() {
27 display.invertDisplay(true); // Renkleri ters çevir / invert colours
28 delay(1000);
29 display.invertDisplay(false);
30 delay(1000);
31}
32- Library header: in the include line, replace Adafruit_SSD1306.h with Adafruit_SH110X.h.
- Object: change Adafruit_SSD1306 display(128, 64, &Wire, -1) to Adafruit_SH1106G display(128, 64, &Wire, -1).
- begin(): use display.begin(0x3C, true) instead of display.begin(SSD1306_SWITCHCAPVCC, 0x3C); the second parameter decides whether to reset the display at start-up.
- Colours: write SH110X_WHITE and SH110X_BLACK instead of SSD1306_WHITE and SSD1306_BLACK.
- Scrolling: hardware scroll functions such as startscrollright() don't exist on the SH1106; you scroll yourself by changing the drawing coordinates.
SPI version: the 7-pin 1.3 inch OLED
7-pin SPI modules (GND, VCC, D0, D1, RES, DC, CS) refresh much faster than I2C: a full screen takes about 25 ms over I2C at 400 kHz, but only 1–2 ms with hardware SPI at 8 MHz. You'll notice the difference in games and fast animations. The logic of SPI is explained in the what is SPI article. The Uno uses 5 V logic and some modules' inputs tolerate it without trouble, but the chip itself runs at 3.3 V; for safe long-term use, the healthiest choice is a logic level converter between the Uno and the SPI lines. Some SPI modules can also be converted to I2C by moving two resistors on the back.
| OLED pin | Arduino Uno | ESP32 | Raspberry Pi Pico | Function |
|---|---|---|---|---|
| D0 (CLK, SCK) | D13 | GPIO18 | GP18 | SPI clock |
| D1 (MOSI, SDA) | D11 | GPIO23 | GP19 | SPI data |
| RES (RST) | D8 | GPIO17 | GP20 | Display reset |
| DC (A0) | D9 | GPIO16 | GP21 | Command or data select |
| CS | D10 | GPIO5 | GP17 | Chip select |
| Adafruit constructor (Uno) | Adafruit_SH1106G display(128, 64, &SPI, 9, 8, 10); | - | - | Order: DC, RESET, CS |
SH1106 with the ESP32

On the ESP32 the default I2C pins are GPIO21 (SDA) and GPIO22 (SCL). U8g2's hardware I2C constructor takes two extra parameters on the ESP32: the clock (SCL) and data (SDA) pins, so you can use any two pins you like. Power the display from the 3V3 pin; since the ESP32 already runs at 3.3 V, no level converter is needed. The sketch below shows free RAM, uptime and a scrolling sine wave that shows off how smooth the full buffer is. To bring the screen to life with cute robot eyes, have a look at the ESP32 OLED robot eyes project.
1// ESP32 + 1,3 inç SH1106 OLED, U8g2 (I2C: SDA 21, SCL 22)
2#include <Wire.h>
3#include <U8g2lib.h>
4
5// ESP32'de pinler kurucuda verilir: saat (SCL), veri (SDA) / on ESP32 pins go in the constructor: clock, data
6U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE, 22, 21);
7
8void setup() {
9 u8g2.setBusClock(400000);
10 u8g2.begin();
11}
12
13void loop() {
14 u8g2.clearBuffer();
15 u8g2.setFont(u8g2_font_6x10_tf);
16 u8g2.setCursor(0, 10);
17 u8g2.print("ESP32 + SH1106");
18 u8g2.setCursor(0, 22);
19 u8g2.print("Bos RAM / Free: ");
20 u8g2.print(ESP.getFreeHeap() / 1024);
21 u8g2.print(" KB");
22 u8g2.setCursor(0, 34);
23 u8g2.print("Sure / Time: ");
24 u8g2.print(millis() / 1000);
25 u8g2.print(" s");
26
27 // Kayan sinüs dalgası: tam tampon sayesinde akıcı / scrolling sine wave, smooth thanks to the full buffer
28 float phase = millis() / 300.0;
29 for (int x = 0; x < 128; x++) {
30 int y = 52 + (int)(10 * sin(x / 10.0 + phase));
31 u8g2.drawPixel(x, y);
32 }
33 u8g2.sendBuffer();
34}
35SH1106 with the Raspberry Pi Pico (MicroPython)
MicroPython ships with a ready-made driver for the SSD1306, but not for the SH1106. The good news is that thanks to the framebuf module the driver is only a few lines, and writing it teaches you how the SH1106 works. The class below inherits from framebuf.FrameBuffer, so drawing functions such as text(), line(), rect() and fill_rect() come for free. For each of the 8 pages, show() first sends the page number, then the column offset of 2, and then writes that page's 128 bytes. Connect the display to the Pico's 3V3(OUT) pin, SDA to GP4 and SCL to GP5. The code also prints the address with an I2C scan at start-up.
1# Raspberry Pi Pico: kütüphanesiz SH1106 sürücüsü (MicroPython) / library-free SH1106 driver
2from machine import Pin, I2C
3import framebuf
4import time
5
6
7class SH1106(framebuf.FrameBuffer):
8 def __init__(self, i2c, addr=0x3C, offset=2):
9 self.i2c, self.addr, self.offset = i2c, addr, offset
10 self.buf = bytearray(128 * 64 // 8) # 1024 bayt, 8 sayfa / 1024 bytes, 8 pages
11 super().__init__(self.buf, 128, 64, framebuf.MONO_VLSB)
12 # Kapat, saat, çoklama, ofset, başlangıç satırı, DC-DC açık (0xAD 0x8B), yön, kontrast, aç
13 # Off, clock, multiplex, offset, start line, DC-DC on (0xAD 0x8B), orientation, contrast, on
14 for c in (0xAE, 0xD5, 0x80, 0xA8, 0x3F, 0xD3, 0x00, 0x40, 0xAD, 0x8B,
15 0xA1, 0xC8, 0xDA, 0x12, 0x81, 0x80, 0xD9, 0x22, 0xDB, 0x35,
16 0xA4, 0xA6, 0xAF):
17 self.cmd(c)
18
19 def cmd(self, c):
20 self.i2c.writeto(self.addr, bytes((0x00, c))) # 0x00 = komut / command
21
22 def show(self):
23 mv = memoryview(self.buf)
24 for page in range(8): # SH1106 yalnız sayfa adreslemesi bilir / page addressing only
25 self.cmd(0xB0 | page) # Sayfa seç / select page
26 self.cmd(0x00 | (self.offset & 0x0F)) # Sütun alt 4 bit / column low nibble
27 self.cmd(0x10 | (self.offset >> 4)) # Sütun üst 4 bit / column high nibble
28 self.i2c.writevto(self.addr, (b"\x40", mv[page * 128:(page + 1) * 128])) # 0x40 = veri / data
29
30
31i2c = I2C(0, sda=Pin(4), scl=Pin(5), freq=400_000)
32print("I2C:", [hex(a) for a in i2c.scan()]) # 0x3c ya da 0x3d görmelisin / expect 0x3c or 0x3d
33
34oled = SH1106(i2c, addr=0x3C) # Görüntü 2 piksel kaymışsa offset=0 dene / try offset=0 if shifted
35n = 0
36while True:
37 oled.fill(0)
38 oled.rect(0, 0, 128, 64, 1)
39 oled.text("SH1106 + Pico", 8, 8, 1)
40 oled.text("Sayac: {}".format(n), 8, 28, 1)
41 oled.fill_rect(8, 46, n % 112, 8, 1)
42 oled.show()
43 n += 1
44 time.sleep_ms(100)
45Project ideas with a 1.3 inch OLED
- Big-digit thermometer: show the room temperature large enough to read from across the room (BME280 and BMP280 sensor).
- Weather panel: display weather data from the internet with icons (ESP32 weather API).
- Pico W weather display: build the same idea with a Raspberry Pi Pico W (Pico W weather display).
- Mini games: play classics such as Pong or the dinosaur runner with buttons (Arduino game projects).
- Device with menus: build settings menus you navigate with a rotary encoder (rotary encoder).
Common mistakes and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Most of the screen is snow, a few garbled lines at the top | SSD1306 library on an SH1106 display | Use Adafruit SH110X or the U8g2 SH1106 constructor |
| Picture shifted 2 pixels, garbage strip on the right edge | Column offset 0 is being used | Switch to an SH1106 driver; in your own driver set offset=2 |
| Screen stays completely black | Wrong address, reversed supply, or SDA and SCL swapped | Find the address with an I2C scanner and check the pin order printed on the module |
| Code uploads on the Uno but nothing happens, random resets | Not enough RAM: full buffer plus other libraries exceed 2 KB | Switch to a U8g2 constructor with a _1_ or _2_ page buffer |
| Picture looks dim or flickers | Panel variant doesn't match the NONAME settings | Try the VCOMH0 constructor in U8g2 and adjust brightness with setContrast() |
| Picture is upside down or mirrored | Different mounting orientation | Use U8G2_R2 in U8g2 or setRotation(2) in Adafruit |
| Screen goes dark when the ESP32's Wi-Fi starts | Supply voltage dips for a moment | Use a good USB cable and put a 10 µF capacitor between 3V3 and GND |
Once your 1.3 inch screen runs with the right driver, it's time to use it in a project. The BlueGrays app walks you through projects such as SSD1306 Pong, the OLED T-Rex runner, the ESP32 weather station with OLED and an RFID door lock with a wiring diagram and ready-made code; if you use a 1.3 inch SH1106, you only need to change the library line and the constructor as shown in this guide.
Frequently asked questions
Is a 1.3 inch OLED an SSD1306 or an SH1106?
Most 1.3 inch modules come with the SH1106 driver, while some models use an SSD1306. The easiest test is to run SSD1306 code and see whether the picture is snowy and shifted; if so, the display is an SH1106.
Why does my SH1106 display show snow?
SSD1306 libraries put the display into horizontal addressing mode and send 1024 bytes at once. The SH1106 doesn't know that mode, so the data is written over the first page and the other pages show random memory content. With a driver made for the SH1106 the problem disappears completely.
Which Arduino library should I use for the SH1106?
The two most common options are U8g2 and Adafruit SH110X. In U8g2 you use the U8G2_SH1106_128X64_NONAME constructor, in Adafruit the Adafruit_SH1106G class. To port code written for Adafruit SSD1306, Adafruit SH110X is the easier choice.
What is the I2C address of the SH1106?
The default address is 0x3C; if the resistor on the back of the module is in the other position, it's 0x3D. If the back says 0x78 or 0x7A, those are the 8-bit forms of the same addresses. U8g2's setI2CAddress() expects the 8-bit value.
Does the SH1106 OLED work with 5 V?
Most modules have a 3.3 V regulator, so you can connect VCC to the Arduino Uno's 5 V pin. The chip still runs at 3.3 V, so a logic level converter is recommended for long-term use, especially with SPI modules. On the ESP32 and Pico, use 3.3 V.
How do I use an SH1106 with a Raspberry Pi Pico?
MicroPython has no built-in SH1106 module, but you can write a driver of a few lines with framebuf or copy a ready-made sh1106.py file to the Pico. Connect the display to GP4 (SDA) and GP5 (SCL) and start I2C(0) at 400 kHz.
Projects to build after reading this
See all projects
Paddle Ball Game - SSD1306
A ball, two paddles and you: you play table tennis, one of the very first video games, on a small OLED screen.

OLED T-Rex Run: Arduino Dinosaur Game
The dinosaur game that pops up when your internet goes down, now on your desk: the dinosaur runs across the small OLED screen, cacti come at you, and you jump with a single button.

ESP32 HTTPClient + Weather API (with SSD1306 OLED Display)
In this project the ESP32 makes a REST API call over the internet to a weather API (wttr.in) using HTTPClient.h. Unlike the I2C LCD version, it uses an SSD1306 OLED (128×64) display, with large text and vector icons for a richer look. Seven weather icons (sunny, rainy, snowy and more) are drawn on the fly, with no bitmap files.

ESP32 Deep Sleep — Battery Saving (OLED + RTC RAM Counter)
The ESP32's Deep Sleep mode shuts down the CPU and most peripherals, cutting current draw to about 10µA, which is vital for battery-powered IoT devices. This project uses three wake-up sources: a timer (15 s), an external pin (EXT0, the button on GPIO 33) and a touch pin (T0/GPIO 4). Counters marked with RTC_DATA_ATTR survive deep sleep.

ESP32 Prayer Rakat Counter (HC-SR04 + SSD1306 OLED + 2 Buttons)
Do you sometimes lose track of which rakat you are on during prayer? This project is a rakat counter that sits next to your prayer mat and counts your prostrations when you bring your hand close. The HC-SR04 ultrasonic distance sensor detects your hand, the SSD1306 OLED display shows the count, and two buttons let you choose 2, 3 or 4 rakats and reset. A 2.5-second debounce and a "hand-away" check make sure no prostration is counted twice.

ESP32 RFID Door Lock (RC522 + Servo + OLED + Buzzer + LED)
We build a smart door lock with an ESP32, an RC522 RFID module, an SG90 servo, an SSD1306 OLED display, an active buzzer and 2 LEDs. When a card is scanned, its UID is checked against the authorized cards defined in the code; if it matches, the servo unlocks (green LED + 2 short beeps) and locks again after 5 seconds. An unknown card lights the red LED, gives 3 quick beeps and shows its UID on the OLED.

ESP32 Color Mixer Light (3 Potentiometers + RGB LED + OLED)
A smart color-mixer lamp: turn 3 potentiometers on the ESP32 and mix any color you like! As you turn the red, green and blue potentiometers, the common-cathode RGB LED changes color instantly. The SSD1306 OLED display shows each channel's 0-255 value, fill bars and the HEX web color code (like #FF8040) live.

ESP32 Smart Lighting (PIR + LDR + Relay + OLED)
With an ESP32, a PIR motion sensor, an LDR light sensor and a relay module, we turn your hallway, bathroom or pantry into smart lighting. If the room is already bright, the light stays off even when there is motion, so it never wastes energy during the day. The light stays on for 30 seconds, and the time extends automatically while motion continues.
More articles
BlueGrays app
Build this circuit step by step on your phone
Wiring diagram, code and parts list on one screen. 500+ Arduino, ESP32, ESP8266, Pico, mBot and micro:bit projects ready to build.
Scan with your phone
Point your camera at the code and your phone's app store opens.
or open the store

