1.3寸 OLED SH1106 I2C版

元器件
显示屏
库存 600

介绍

1.3英寸OLED显示模块,驱动IC SH1106,128×64分辨率,I2C接口,白色/蓝色显示,比0.96寸更大可视区域,适合嵌入式信息显示、智能家居面板、仪表盘

规格参数

参数
GRAM132×64(比SSD1306多4列)
供电3.3V-5V
功耗~25mA
尺寸1.3英寸
接口I2C (0x3C/0x3D)
驱动ICSH1106
分辨率128×64
像素间距0.21×0.21mm
可视角度全视角>160°
外形尺寸35.5mm×33.5mm
工作温度-40°C~85°C
显示颜色白/蓝

代码例程

1.3寸OLED SH1106 多平台代码例程.md

# 1.3寸OLED SH1106 多平台代码例程

---

## Arduino (U8g2)

```cpp
#include <U8g2lib.h>
// SH1106 128x64, I2C, 页缓冲模式
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);

void setup() {
  u8g2.begin();
  u8g2.setFont(u8g2_font_6x10_tf);
}

void loop() {
  u8g2.clearBuffer();
  u8g2.drawStr(0, 10, "SH1106 1.3 OLED");
  u8g2.drawFrame(0, 16, 128, 48);
  u8g2.setCursor(4, 28);
  u8g2.print("Vibe Electronics");
  u8g2.setCursor(4, 42);
  u8g2.print(millis());
  u8g2.sendBuffer();
}
```

---

## ESP32 (Adafruit_SH1106)

```cpp
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH1106.h>

Adafruit_SH1106 display(21, 22); // SDA, SCL

void setup() {
  display.begin(SH1106_SWITCHCAPVCC, 0x3C);
  display.clearDisplay();
  display.setTextSize(1);
  display.setTextColor(SH1106_WHITE);
  display.setCursor(0, 0);
  display.println("ESP32 SH1106");
  display.display();
}

void loop() {
  display.clearDisplay();
  display.setCursor(0, 0);
  display.printf("RSSI: %d dBm", WiFi.RSSI());
  display.drawCircle(64, 48, 10, SH1106_WHITE);
  display.display();
  delay(1000);
}
```

---

## STM32 HAL + U8g2

```c
#include "u8g2.h"
#include "i2c.h"

uint8_t u8x8_byte_hw_i2c(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
    static uint8_t buffer[32]; static uint8_t idx;
    switch(msg) {
        case U8X8_MSG_BYTE_SEND:
            while(arg_int--) buffer[idx++] = ((uint8_t *)arg_ptr)[arg_int];
            HAL_I2C_Master_Transmit(&hi2c1, 0x78, buffer, idx, 100);
            idx = 0; break;
        case U8X8_MSG_BYTE_START_TRANSFER: idx = 0; break;
    }
    return 1;
}

uint8_t u8x8_delay(u8x8_t *u8x8, uint8_t msg, uint8_t arg_int, void *arg_ptr) {
    if(msg == U8X8_MSG_DELAY_MILLI) HAL_Delay(arg_int);
    return 1;
}

u8g2_t u8g2;
void sh1106_init(void) {
    u8g2_Setup_sh1106_i2c_128x64_noname_f(&u8g2, U8G2_R0, u8x8_byte_hw_i2c, u8x8_delay);
    u8g2_InitDisplay(&u8g2);
    u8g2_SetPowerSave(&u8g2, 0);
}
```

---

## MicroPython (Raspberry Pi Pico)

```python
from machine import Pin, I2C
import sh1106  # micropython-sh1106
import time

i2c = I2C(0, scl=Pin(17), sda=Pin(16), freq=400000)
display = sh1106.SH1106_I2C(128, 64, i2c, addr=0x3c, rotate=0)

display.fill(0)
display.text('Pico + SH1106', 0, 0, 1)
display.hline(0, 12, 128, 1)
display.text('1.3 OLED', 0, 20, 1)
display.text('I2C OK', 0, 40, 1)
display.show()
```

参考资料

暂无参考文献