#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
// I2C pins for ESP32-C3 SuperMini
#define I2C_SDA 6
#define I2C_SCL 7
// SH1107 128x128 OLED
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 128
#define OLED_RESET -1 // Reset pin not used
#define I2C_ADDRESS 0x3C // Typical SH1107 I2C address
Adafruit_SH1107 display(SCREEN_HEIGHT, SCREEN_WIDTH, &Wire, OLED_RESET);
void setup() {
Wire.begin(I2C_SDA, I2C_SCL);
Serial.begin(115200);
Serial.println("ESP32-C3 SuperMini + SH1107 OLED Demo");
if (!display.begin(I2C_ADDRESS, true)) {
Serial.println("SH1107 allocation failed");
for (;;);
}
display.clearDisplay();
display.display();
// Welcome text
display.setTextSize(1);
display.setTextColor(SH110X_WHITE);
display.setCursor(10, 10);
display.println("Hello ESP32-C3!");
display.setCursor(10, 25);
display.println("SH1107 OLED Demo");
display.display();
delay(2000);
}
void loop() {
// Clear screen
display.clearDisplay();
// Draw shapes
display.drawRect(5, 5, 40, 40, SH110X_WHITE);
display.fillCircle(80, 25, 20, SH110X_WHITE);
display.drawTriangle(20, 80, 60, 60, 100, 100, SH110X_WHITE);
// Text overlay
display.setTextSize(1);
display.setCursor(10, 110);
display.println("Shapes + Text");
display.display();
delay(2000);
// Invert demo
display.invertDisplay(true);
delay(1000);
display.invertDisplay(false);
// Simple smiley face demo
display.clearDisplay();
display.fillCircle(64, 64, 30, SH110X_WHITE); // Face outline
display.fillCircle(54, 54, 4, SH110X_BLACK); // Left eye
display.fillCircle(74, 54, 4, SH110X_BLACK); // Right eye
// Approximate smile arc using pixels
for (int angle = 200; angle < 340; angle += 5) {
float rad = angle * 3.14159 / 180;
int x = 64 + cos(rad) * 15;
int y = 70 + sin(rad) * 15;
display.drawPixel(x, y, SH110X_BLACK);
}
display.display();
delay(2000);
}
Loading
xiao-esp32-c3
xiao-esp32-c3
Loading
grove-oled-sh1107
grove-oled-sh1107