esp8266 驱动oled

130 阅读1分钟

接线图 网上资料

image.png

image.png

我的接线图

b4d243e07fde5bd643b89bf7e875c25.jpg

d2656b2aec7a87cde17f7e2ade8f47c.jpg

代码

#include <SoftwareSerial.h>
#include <U8g2lib.h>

#define BLINKER_PRINT Serial
#define BLINKER_WIFI
#define OLED_ADDRESS 0x3C


U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE);   // All Boards without Reset of the Display

void setup() {
      Serial.print(SCL);
      Serial.print(SDA);
  // put your setup code here, to run once:
  u8g2.begin();
  u8g2.enableUTF8Print();
}

void loop() {
  // put your main code here, to run repeatedly:
 u8g2.clearBuffer();
 
  // 设置显示文本
  u8g2.setFont(u8g2_font_6x12_tf);
  u8g2.setCursor(0, 10);
  u8g2.print("Hello, OLED222!");
 
  // 发送显示数据到显示屏
  u8g2.sendBuffer();
}

效果

e87868550fb62c85f16872c1b53f889.jpg