# wemos-sh1106-example

> SH1106 OLED Text Portal with captive portal on LOLIN(WEMOS) D1 R2 & mini

- Author: Mikrobot.pl
- Platform: ESP8266
- Board: LOLIN(WEMOS) D1 R2 & mini (`esp8266:esp8266:d1_mini`)
- SDK version: 3.1.2
- Tags: #esp8266, #example, #captive portal, #wifi, #sh1106, #d1 r2, #mini, #wemos
- Created: 2026-09-22
- Updated: 2026-09-22
- Favorites: 0, forks: 0
- Project page (view, flash from the browser, fork): https://flashesp.com/explore/9QTCpz8NE0Cr8TdSQVBBg
- Download all sources (zip): https://flashesp.com/api/public-projects/9QTCpz8NE0Cr8TdSQVBBg/download-sources/

## Source files

- [libraries_lock.json (243 B)](https://flashesp.com/explore/9QTCpz8NE0Cr8TdSQVBBg/files/FHLfIFDwa7yCrLtVw3prX.md)
- [main.ino (5.6 KB)](https://flashesp.com/explore/9QTCpz8NE0Cr8TdSQVBBg/files/IHH8NiX0v6ciCK1FYm0fO.md)
- readme.md (4.4 KB)

## README

<p align="center">
  <img src="https://i.imgur.com/L6B5BM5.jpeg" alt="Wemos D1 SH1106 OLED Text Portal" width="320" style="display:inline-block; vertical-align:top; margin:0 8px;">
  <img src="https://i.imgur.com/GG2B5Cf_d.webp?maxwidth=760&fidelity=grand" alt="Wemos D1 SH1106 OLED Text Portal" width="280" style="display:inline-block; vertical-align:top; margin:0 8px;">
</p>

# Wemos D1 SH1106 OLED Text Portal  
### Wireless text sender with captive portal on Wemos D1 mini / D1 R2 (ESP8266)

This project turns a **Wemos D1 mini** or **Wemos D1 R2** (ESP8266) plus a **128×64 SH1106 I2C OLED display** into a small wireless text terminal.

After power-up, the Wemos:

- 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`**  
On boot, the display also shows the network name and IP address at the bottom.

---

## ⭐ Features

- **Open WiFi Access Point** (no password)
  - SSID: `WEMOS-OLED`
  - IP address: `192.168.4.1`
- **Captive portal**
  - Any domain (e.g. `google.com`) is redirected to the Wemos
  - 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 (up to 128 characters)
- **OLED rendering**
  - Automatic word-wrap
  - Clear 128×64 monochrome display

---

## 📦 Hardware requirements

- **Wemos D1 mini** or **Wemos D1 R2** (ESP8266, CH340 USB chip)
- **128×64 SH1106 I2C OLED display module** (typically the 1.3" version)

> This project uses the **SH1106** driver. Modules with the **SSD1306** controller (usually the 0.96" version) need a different driver.

### 🔌 SH1106 → Wemos 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 Wemos as follows:

| SH1106 Pin | Wemos D1 mini | Wemos D1 R2 | Description                    |
|-----------:|---------------|-------------|--------------------------------|
| VCC        | 3V3           | 3V3         | 3.3 V Power                    |
| GND        | G             | GND         | Ground                         |
| SCK        | D1 (GPIO5)    | SCL         | I²C Clock (SCK on your module) |
| SDA        | D2 (GPIO4)    | SDA         | I²C Data (SDA)                 |

On the **D1 R2**, use the header pins labeled **SCL** and **SDA**. Some D1 R2 clones also print other numbers next to them (e.g. D15/D14) – the SCL/SDA label is what matters.

In the code, I²C is initialized as:

```cpp
#define OLED_SDA D2   // GPIO4
#define OLED_SCL D1   // GPIO5

Wire.begin(OLED_SDA, OLED_SCL); // SDA, SCK (clock)
```

---

## 🧩 Board selection

Select the board **`LOLIN(WEMOS) D1 R2 & mini`** – the same setting works for both the D1 mini and the D1 R2.

The Wemos boards use the **CH340** USB-to-serial chip. If the board does not show up when connecting, install the CH340 driver and make sure you are using a USB data cable (some cables are charge-only).

---

## 🚀 How to use

1. Flash the project and power the Wemos via USB.
2. On your phone or laptop, connect to the WiFi network **`WEMOS-OLED`**.
3. The captive portal page should open automatically.  
   If it does not, open **`http://192.168.4.1`** in your browser.
4. Enter your text and press **Send to OLED**.
5. The text appears on the display. After a reboot, the display returns to **`mikrobot.pl`**.

---

## 🛠 Troubleshooting

- **Display stays black** – check the wiring (SCK → D1, SDA → D2), power from 3V3, and the I²C address. Most modules use `0x3C`, some use `0x3D`.
- **Portal does not open automatically** – open `http://192.168.4.1` manually. Your phone may warn that the network has no internet access; choose to stay connected.
- **Redirect does not work for some websites** – only plain `http://` addresses are redirected. Sites opened via `https://` will show an error; use `http://192.168.4.1` instead.
- **Letters with diacritics (e.g. ą, ę, ł, ö) look wrong** – the built-in display font supports basic characters only.
- **Serial monitor** – at **9600 baud** it prints the network name and IP address after boot.

> The WiFi network is open, so anyone nearby can connect and change the text on the display.
