# esp32-sh1106-example

> SH1106 OLED Text Portal with captive portal on ESP32 Dev Board

- Author: Mikrobot.pl
- Platform: ESP32
- Board: ESP32 Dev Module (`esp32:esp32:esp32`)
- SDK version: 3.3.2
- Tags: #esp32, #example, #captive portal, #sh1106
- Created: 2025-12-03
- Updated: 2025-12-03
- Favorites: 1, forks: 0
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/jCw4F8QOw1YNmfYTJO5GP
- Download all sources (zip): https://flashesp.com/api/public-projects/jCw4F8QOw1YNmfYTJO5GP/download-sources/

## Source files

- [libraries_lock.json (241 B)](https://flashesp.com/explore/jCw4F8QOw1YNmfYTJO5GP/files/6UWIrOlFfYwW9oOM6VPh3.md)
- [main.ino (5.4 KB)](https://flashesp.com/explore/jCw4F8QOw1YNmfYTJO5GP/files/YJ8OFqfqbI10IgwoPIIuM.md)
- readme.md (1.8 KB)

## README

# ESP32 SH1106 OLED Text Portal  
### Wireless text sender with captive portal on ESP32 Dev Board

This project turns an **ESP32 Dev Board** plus a **128×64 SH1106 I2C OLED display** into a small wireless text terminal.

After power-up, the ESP32:

- creates an **open WiFi Access Point**,
- runs a **captive portal** (browser login page),
- shows a web form where you can enter any text,
- displays that text on the SH1106 OLED.

Default text on boot: **`mikrobot.pl`**

---

## ⭐ Features

- **Open WiFi Access Point** (no password)
  - SSID: `ESP32-OLED`
  - IP address: `192.168.4.1`
- **Captive portal**
  - Any domain (e.g. `google.com`) is redirected to the ESP32
  - Common OS captive checks handled:
    - Android `/generate_204`
    - iOS/macOS `/hotspot-detect.html`
    - Windows `/ncsi.txt`
- **Web interface**
  - Shows current text on the display
  - Simple form to send new text to the OLED
- **OLED rendering**
  - Automatic word-wrap
  - Clear 128×64 monochrome display

---

## 📦 Hardware requirements

- **ESP32 Dev Board** (e.g. ESP32-DevKitC)
- **128×64 SH1106 I2C OLED display module**

### 🔌 SH1106 → ESP32 wiring

On your SH1106 I2C module the clock pin is labeled **SCK** instead of **SCL**.  
That is normal – it is still the I²C clock line.

Typical pins on the SH1106 module:

- `VCC`
- `GND`
- `SCK`  (I²C clock, sometimes labeled SCL or CLK)
- `SDA`  (I²C data)

Connect them to the ESP32 as follows:

| SH1106 Pin | ESP32 Pin | Description                    |
|-----------:|-----------|--------------------------------|
| VCC        | 3V3       | 3.3 V Power                    |
| GND        | GND       | Ground                         |
| SCK        | GPIO22    | I²C Clock (SCK on your module) |
| SDA        | GPIO21    | I²C Data (SDA)                 |

In the code, I²C is initialized as:

```cpp
Wire.begin(21, 22); // SDA, SCK (clock)
