oled-i2c.ino
Adafruit libraries compile as-is on the STM32F1 core: the SSD1306 plugs into PB6/PB7 (Wire1 mapped as default Wire) and the animated gauge proves the bus runs.
Hardware required
A GD32F103C8T6 development board (Cortex-M3 at 108 MHz, Blue Pill pin-to-pin compatible), powered at 3.3 V/5 V, with an ST-Link or serial adapter. 1 I2C SSD1306 128×64 OLED.
Wiring
SDA on PB7, SCL on PB6 (the core's default Wire wiring), VCC 3.3 V, GND. Address 0x3C.
How it works
Wire drives the GD32 hardware I2C; Adafruit_SSD1306 keeps the framebuffer and copies it on display(). The begin() test fails cleanly on a wrong address. With Arduino: install the « STM32F1 » core (Roger Clark, board manager) and pick the « GD32F103C » board; the user LED is PC13 (active LOW). In C: GD32F10x firmware library + ST-Link.
Going further
Show the potentiometer voltage as a gauge, or scan the bus to list every Grove/I2C module.
oled-i2c.ino
// OLED SSD1306 128x64 sur Wire (PB6/PB7 par defaut du core).
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define ADRESSE 0x3C
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
unsigned long precedent = 0;
void setup() {
Serial.begin(115200);
Wire.begin();
if (!oled.begin(SSD1306_SWITCHCAPVCC, ADRESSE)) {
Serial.println("OLED absent (0x3C ?)"); for (;;);
}
oled.clearDisplay();
oled.setTextColor(SSD1306_WHITE);
}
void loop() {
if (millis() - precedent < 200) return;
precedent = millis();
oled.clearDisplay();
oled.setTextSize(1);
oled.setCursor(0, 0);
oled.printf("GD32F103\n%lu ms\n", millis());
oled.drawLine(0, 40, 127, 40, SSD1306_WHITE);
int jauge = (millis() / 50) % 128;
oled.fillRect(0, 48, jauge, 10, SSD1306_WHITE);
oled.display();
}