A self-organizing, fault-tolerant WiFi mesh network for coordinated emergency LED signaling using ESP32-C3 microcontrollers.
This system creates an autonomous mesh network where multiple ESP32-C3 devices discover each other, self-organize, and execute synchronized LED sequences. Perfect for emergency signaling, visual status indicators, or distributed lighting displays.
- π Zero-configuration deployment - Flash and forget
- π Automatic leader election - Self-organizing with master failover
- π‘ UDP-based broadcasting - Lightweight mesh communication
- π Hot-plug support - Devices can join/leave dynamically
- β‘ Power-efficient - Runs at 80MHz for extended battery life
- π― Scalable - Supports unlimited devices (tested with 4)
| Component | Specification | Notes |
|---|---|---|
| MCU | ESP32-C3 | Any variant with WiFi |
| MCU External LED | GPIO 5 | Main signaling |
| MCU Internal LED | GPIO 8 | May variates |
| Power | Battery | 2x 3.7V 18650 Battery |
| Additional | MOSFET | IRLZ44N |
| Additional | Converter | Step down converter to 3.3V |
| Additional | Resistors | 5Ξ© 5W / 1kΞ© / 100kΞ© |
| Additional | 2x LED | RED LED 3W (Forw. Voltage 2-2.2V) (Forw. current 700mA) |
- β Self-organizing mesh - Devices automatically discover peers via WiFi scanning
- β Dynamic master election - Lowest MAC address becomes coordinator
- β Fault tolerance - System recovers from device failures automatically
- β Real-time discovery - New devices join sequence within 1 second
- β Dual-mode operation - Each device acts as both AP and Station
- β Synchronized sequencing - All devices maintain perfect timing
- β Cascading blink pattern - Sequential activation across network
- β Configurable timing - Adjustable blink duration and intervals
- β Visual feedback - Both external and internal LED support
SSID: ERMG_MESH
Password: emergency123
UDP Port: 4210
Discovery Interval: 1000ms
CPU Frequency: 80MHzBlink Duration: 200ms
All-Off Duration: 2000ms
WiFi Scan Timeout: 5000msThe system creates a cascading wave pattern where LEDs illuminate sequentially:
STEP β ESP1 β ESP2 β ESP3 β ESP4 β ... β Description
ββββββΌβββββββΌβββββββΌβββββββΌβββββββββΌβββββββΌβββββββββββββββββ
1 β π΄ β β« β β« β β« β ... β First device ON
2 β β« β π΄ β β« β β« β ... β Second device ON
3 β β« β β« β π΄ β β« β ... β Third device ON
4 β β« β β« β β« β π΄ β ... β Fourth device ON
n β β« β β« β β« β β« β ... β Nth device ON
n+1 β β« β β« β β« β β« β ... β All OFF (pause)
1 β π΄ β β« β β« β β« β ... β Cycle restarts
Note: Internal LED has inverted logic (HIGH = ON)
Note: Sequence dynamically adjusts as devices join/leave
- Install Arduino IDE with ESP32 board support
- Add correct ESP32 board manager
- Clone this repo
- Open ERMG_LED.ino in Arduino IDE
- Select: Tools β Board β ESP32C3 Dev Module [or your variant]
- Select: Tools β Port β [your COM Port]
- Flash code to multiple ESP32-C3 devices
- Power them on simultaneously or sequentially
- Devices auto-discover and organize within ~2 seconds
- Watch the synchronized LED sequence begin!
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β Device A ββββββΆβ Device B ββββββΆβ Device C β
β (Master) βββββββ (Slave) βββββββ (Slave) β
βββββββββββββββ βββββββββββββββ βββββββββββββββ
β β β
βββββββββββββββββββββ΄ββββββββββββββββββββ
UDP Broadcast Network
| Message Type | Format | Purpose |
|---|---|---|
ANNOUNCE: |
ANNOUNCE:[MAC] |
Device presence announcement |
DEVICES: |
DEVICES:[MAC1],[MAC2],... |
Master broadcasts device list |
BLINK: |
BLINK:[STEP] |
Master triggers sequence step |
[Power On] β [Scan WiFi] β [Found SSID?]
β
ββββββββββββββ΄βββββββββββββ
YES NO
β β
[Connect] β [Slave] [Create AP] β [Master]
β β
βββββββββ[Join Mesh]βββββββ
β
[Sync & Sequence]
#define MESH_SSID "YOUR_SSID"
#define MESH_PASSWORD "YOUR_PASSWORD"#define LED_EXTERNAL 5 // Change to your pin
#define LED_INTERNAL 8 // Change to your pin (if your ESP32 has an internal pin)#define BLINK_DURATION 200 // 200ms ON time
#define ALL_OFF_DURATION 2000 // 2s pause between cycles- Flash one device β Currently constant ON
- Flash 2+ devices β Should see cascading pattern
- Power off master β New master elected automatically
- Add new device β Joins sequence
| Issue | Possible Cause | Solution |
|---|---|---|
| Desynchronized | Network congestion | Reduce discovery interval |
| LED always ON | Inverted logic | Swap HIGH/LOW in code |
- Protocol: UDP broadcast
- WiFi Mode: AP + STA (dual mode)
- Discovery: Active scanning + periodic announcements
- Coordination: Master-slave with automatic failover
- Timing Precision: Β±100ms synchronization
- Network Capacity: 4 ESP's tested
- π¨ Emergency evacuation signaling
- ποΈ Construction site safety indicators
- Add patterns?
This project is open-source. Feel free to modify and use for any purpose.
Made with β€οΈ for emergency preparedness and distributed systems

