A small OLED is the quickest way to give an S2 Mini project a face. The default I2C pins — GPIO33 for SDA, GPIO35 for SCL — are where D1 mini shields put I2C, so most OLED shields fit directly.
Power the display from 3V3. The sketch shows uptime and free PSRAM once a second.
Wiring
| LOLIN S2 Mini | SSD1306 OLED 0.96″ (128×64, I2C) | Wire | Notes |
|---|---|---|---|
| GND | GND | black | |
| 3V3 | VCC | red | |
| 35 | SCL | yellow | D1 mini “D1” position. |
| 33 | SDA | blue | D1 mini “D2” position. |
3.3–5 V (on-board regulator) part, 3.3 V board. Most modules have a regulator and run from 3.3 V or 5 V. Their I2C pull-ups go to VCC, so on ESP32 and Pico power the OLED from 3.3 V to keep SDA/SCL at a safe level.
Board quirks
- GPIO33 (SDA) and GPIO35 (SCL) are on the outer row where a D1 mini has D2 and D1, so D1 mini OLED shields plug straight on.
- GPIO33–40 have no ADC on the S2, which makes them ideal for digital buses like I2C and keeps the ADC1 pins (GPIO1–10) free.
- The display shows free PSRAM. The S2FN4R2 chip has 2 MB of PSRAM in the package; it reads 0 if PSRAM is disabled in Tools.
Code
// SSD1306 128x64 I2C OLED on a LOLIN S2 Mini.
// GND → GND, VCC → 3V3, SDA → GPIO33, SCL → GPIO35 (the S2 Mini's default Wire pins,
// in the same place as D2/D1 on a D1 mini). Address 0x3C.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
Wire.begin(33, 35); // SDA, SCL
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 not found at 0x3C - try 0x3D, and check the GND/VCC order on your module");
while (true) delay(1000);
}
display.setTextColor(SSD1306_WHITE);
Serial.println("OLED ready");
}
void loop() {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 0);
display.print("S2 Mini");
display.setTextSize(1);
display.setCursor(0, 28);
display.printf("Uptime: %lu s", millis() / 1000);
display.setCursor(0, 44);
display.printf("PSRAM free: %u KB", ESP.getFreePsram() / 1024);
display.display();
delay(1000);
}// SSD1306 128x64 I2C OLED on a LOLIN S2 Mini.
// GND → GND, VCC → 3V3, SDA → GPIO33, SCL → GPIO35 (the S2 Mini's default Wire pins,
// in the same place as D2/D1 on a D1 mini). Address 0x3C.
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 display(128, 64, &Wire, -1);
void setup() {
Serial.begin(115200);
uint32_t t0 = millis();
while (!Serial && millis() - t0 < 3000) {}
Wire.begin(33, 35); // SDA, SCL
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println("SSD1306 not found at 0x3C - try 0x3D, and check the GND/VCC order on your module");
while (true) delay(1000);
}
display.setTextColor(SSD1306_WHITE);
Serial.println("OLED ready");
}
void loop() {
display.clearDisplay();
display.setTextSize(2);
display.setCursor(0, 0);
display.print("S2 Mini");
display.setTextSize(1);
display.setCursor(0, 28);
display.printf("Uptime: %lu s", millis() / 1000);
display.setCursor(0, 44);
display.printf("PSRAM free: %u KB", ESP.getFreePsram() / 1024);
display.display();
delay(1000);
}Library: Adafruit SSD1306 (Adafruit (also install Adafruit GFX Library)) — compiled with Adafruit SSD1306 2.5.17.
Expected serial output
OLED readyOLED ready
Common errors
“SSD1306 not found at 0x3C”
Try 0x3D; check that SDA is on 33 and SCL on 35. Full fix.
COM port disappears after upload
The S2 re-enumerates its USB after reset; reselect the port. Port troubleshooting.