Skip to content

afoni95/ERMG_LED

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🚨 Emergency LED Mesh Network System

A self-organizing, fault-tolerant WiFi mesh network for coordinated emergency LED signaling using ESP32-C3 microcontrollers.


πŸ“‹ Overview

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.

Example showcase of 4 ESP32-C3

Image


✨ Key Highlights

  • πŸ”„ 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)

πŸ› οΈ Hardware Requirements

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)

πŸ“ Wiring Diagram

Image


🎯 Features

Network Capabilities

  • βœ… 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

LED Control

  • βœ… 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

βš™οΈ Configuration

Network Settings

SSID:               ERMG_MESH
Password:           emergency123
UDP Port:           4210
Discovery Interval: 1000ms
CPU Frequency:      80MHz

Timing Parameters

Blink Duration:     200ms
All-Off Duration:   2000ms
WiFi Scan Timeout:  5000ms

πŸ“Š LED Sequence Behavior

The 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


πŸš€ Getting Started

1️⃣ Installation

  • Install Arduino IDE with ESP32 board support
  • Add correct ESP32 board manager
  • Clone this repo

2️⃣ Upload

  • Open ERMG_LED.ino in Arduino IDE
  • Select: Tools β†’ Board β†’ ESP32C3 Dev Module [or your variant]
  • Select: Tools β†’ Port β†’ [your COM Port]

3️⃣ Deploy

  • 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!

πŸ”§ How It Works

Network Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Device A  │────▢│   Device B  │────▢│   Device C  β”‚
β”‚  (Master)   │◀────│  (Slave)    │◀────│  (Slave)    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚                   β”‚                   β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              UDP Broadcast Network

Communication Protocol

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

State Machine

[Power On] β†’ [Scan WiFi] β†’ [Found SSID?]
                                 β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   YES                       NO
                    β”‚                         β”‚
              [Connect] β†’ [Slave]      [Create AP] β†’ [Master]
                    β”‚                         β”‚
                    └────────[Join Mesh]β”€β”€β”€β”€β”€β”€β”˜
                                 β”‚
                         [Sync & Sequence]

🎨 Customization

Change Network Credentials

#define MESH_SSID "YOUR_SSID"
#define MESH_PASSWORD "YOUR_PASSWORD"

Adjust LED Pins

#define LED_EXTERNAL 5  // Change to your pin
#define LED_INTERNAL 8  // Change to your pin (if your ESP32 has an internal pin)

Modify Timing

#define BLINK_DURATION 200      // 200ms ON time
#define ALL_OFF_DURATION 2000   // 2s pause between cycles

πŸ§ͺ Testing

Single Device Test

  • Flash one device β†’ Currently constant ON

Multi-Device Test

  • Flash 2+ devices β†’ Should see cascading pattern
  • Power off master β†’ New master elected automatically
  • Add new device β†’ Joins sequence

πŸ› Troubleshooting

Issue Possible Cause Solution
Desynchronized Network congestion Reduce discovery interval
LED always ON Inverted logic Swap HIGH/LOW in code

πŸ“š Technical Specifications

  • 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

πŸŽ“ Use Cases

  • 🚨 Emergency evacuation signaling
  • πŸ—οΈ Construction site safety indicators

Roadmap

  • Add patterns?

πŸ“„ License

This project is open-source. Feel free to modify and use for any purpose.


Made with ❀️ for emergency preparedness and distributed systems

About

A self-organizing, fault-tolerant WiFi mesh network for coordinated emergency LED signaling using ESP32-C3 microcontrollers

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages