AS3935 Franklin Lightning Sensor + TTGO Wemos ESP32 OLED
A lightning detector based on the AS3935 sensor (WCMCU-3935 module) and ESP32 microcontroller with built-in OLED display. Detects lightning activity, estimates distance to storm front, and displays real-time data on a 128x64 OLED screen.
- ⚡ Lightning detection up to 40 km radius
- 📏 Distance estimation in 15 steps (1–40 km)
- 🔋 Ultra-low sensor power consumption (~80 µA in listening mode)
- 🖥️ Real-time OLED display with adaptive info line
- 📊 Distinguishes between Lightning, Disturber, and Noise
- 🔢 Disturber counter per session
- 📶 Noise level indicator (0–7 scale)
- ⏱️ Auto-reset to Quiet: 10 sec after lightning, 5 sec after disturber
- 🔇 Optional WiFi/BT disable to reduce EMI interference
- 🔌 No external AS3935 library — direct register access via Wire
| Component | Details |
|---|---|
| Microcontroller | TTGO Wemos ESP32 OLED (ESP-WROOM-32) |
| Lightning Sensor | WCMCU-3935 (AS3935, analog to CJMCU-3935) |
| Display | Built-in OLED 0.96" 128x64, SSD1306, I2C |
| Power | 5V USB or 3.7V LiPo |
Only 5 wires from ESP32 to sensor:
| Wire | ESP32 | WCMCU-3935 | Color |
|---|---|---|---|
| Power | 3.3V | VCC + SI + A0 + A1 + EN_V | Red |
| Ground | GND | GND + CS | Black |
| I2C Data | GPIO5 | MOSI | Blue |
| I2C Clock | GPIO4 | SCL | Green |
| Interrupt | GPIO13 | IRQ | Yellow |
⚠️ Important: Tie SI, A0, A1, EN_V together to 3.3V. Tie CS together with GND.
| Signal | GPIO | Note |
|---|---|---|
| OLED SDA | GPIO5 | Reversed from ESP32 standard! |
| OLED SCL | GPIO4 | Reversed from ESP32 standard! |
| OLED RST | GPIO16 | Required — OLED won't start without it |
| AS3935 IRQ | GPIO13 | Interrupt input |
| Device | Address |
|---|---|
| OLED SSD1306 | 0x3C |
| AS3935 | 0x03 (A0=1, A1=1) |
┌──────────────────────────┐
│ Lightning Detector │ ← header
├──────────────────────────┤
│ Dist: 27 km │ ← distance (size 2)
├──────────────────────────┤
│ Energy: 48321 │ ← adaptive info line
│ Status: Lightning! │ ← status
└──────────────────────────┘
| Status | Info Line Shows |
|---|---|
| Quiet | Energy: 0 |
| Lightning! | Energy: 48321 |
| Noise! | Noise lvl: 4/7 |
| Disturber | Disturb: 7x |
Install via Arduino IDE Library Manager:
- Adafruit SSD1306 — OLED display driver
- Adafruit GFX Library — installed automatically with SSD1306
AS3935 uses direct Wire register access — no external library needed.
-
Add ESP32 board URL in File → Preferences:
https://dl.espressif.com/dl/package_esp32_index.json -
Install esp32 by Espressif Systems via Board Manager
-
Select board settings:
Parameter Value Board ESP32 Dev Module Upload Speed 921600 CPU Frequency 240MHz Flash Mode DIO Flash Size 4MB -
If upload fails — hold BOOT, press RST, release BOOT, then upload
After upload (115200 baud):
Lightning Detector 2.4 starting...
AS3935 initialized OK
REG0x00: 0x24 // Indoor mode, active
REG0x01: 0x22 // NF_LEV=2, WDTH=2
REG0x02: 0x82 // SREJ=2, MIN_LIGH=1
REG0x08: 0x00 // DISP_SRCO=0
Ready. Waiting for lightning...
The AS3935 is sensitive to electromagnetic interference. The ESP32 itself generates noise that the sensor may detect as Disturber or Noise events.
Solutions (in order of effectiveness):
- Physically separate the sensor from ESP32 by 50–100 cm (most effective)
- Disable WiFi/BT — uncomment in
setup():WiFi.mode(WIFI_OFF); btStop();
- Shield ESP32 in a metal enclosure
- Use twisted pair for I2C wires
lightning-detector/
├── README.md
├── CHANGELOG.md
├── WIRING.md
└── lightning_detector_v24/
└── lightning_detector_v24.ino
| Version | Changes |
|---|---|
| 1.0 | OLED interface with random test data |
| 2.0 | Real AS3935 sensor, direct Wire register access |
| 2.1 | Quiet timeout (10 sec) |
| 2.2 | Two separate timers: lightning (10s) and disturber (5s) |
| 2.3 | Fixed init sequence based on PWFusion library analysis |
| 2.4 | Adaptive info line, disturber counter, WiFi/BT disable option |
MIT License — feel free to use, modify and share.
