oled-i2c.ino
The SSD1306 OLED is the universal I2C display: two wires, no proprietary library. The sketch writes a framebuffer then pushes it with a single display() — the right discipline against flicker.
Hardware required
An ESP32-S3 board (dual-core Xtensa with vector instructions, Wi-Fi + BLE 5, native USB) such as a DevKitC-1, XIAO or T-Display-S3, powered over USB. 1 I2C SSD1306 128×64 OLED module (4 pins).
Wiring
VCC 3.3 V, GND, SDA/SCL on the SoC default I2C pins (often GPIO21/22; check your board). Address 0x3C (sometimes 0x78 → jumper).
How it works
Wire drives the bus; Adafruit_SSD1306 keeps a RAM framebuffer and copies it in one shot on display(). begin() detects a missing chip and the serial monitor does the debugging. In the Arduino IDE (esp32 package), select « ESP32S3 Dev Module », enable « USB CDC On Boot », then Upload. Many boards put a WS2812 on GPIO48.
Going further
Add the DHT22 readings from the previous sketch, or scroll a message when the buffer exceeds 64 pixels of height.
oled-i2c.ino
// OLED SSD1306 128x64 en I2C (0x3C) — Adafruit SSD1306 + GFX.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define ADRESSE 0x3C
#define RAZ -1
Adafruit_SSD1306 oled(128, 64, &Wire, RAZ);
void setup() {
Serial.begin(115200);
Wire.begin(); // SDA/SCL par defaut du SoC
if (!oled.begin(SSD1306_SWITCHCAPVCC, ADRESSE)) {
Serial.println("OLED absent : scanner 0x3C ?");
for (;;);
}
oled.clearDisplay();
oled.setTextColor(SSD1306_WHITE);
oled.setTextSize(1);
}
void loop() {
oled.clearDisplay();
oled.setCursor(0, 0);
oled.println(F("Carte "));
oled.setTextSize(2);
oled.printf("%lu ms\n", millis());
oled.setTextSize(1);
oled.printf("Heap : %u o\n", ESP.getFreeHeap());
oled.printf("Rssi : %d dBm\n", WiFi.Rssi());
oled.display(); // envoie le framebuffer
delay(250);
}