System Diagrams
Visual representations of the ESL MQTT API system architecture
Diagram Overview
These diagrams provide visual representations of the ESL MQTT API system architecture, including network topology, message flows, timing sequences, and queue structures.
Sleep/Wake Protocol Architecture
This diagram illustrates the complete sleep/wake protocol system, showing how messages flow from the server through gateways to sleeping ESL devices.
MQTT Broker] CLOUD[Cloud Services
Web Dashboard] end subgraph "Store Network" ROUTER[Store Router
Internet Gateway] subgraph "WiFi ESL Devices" WIFI1[WiFi ESL 001
ESP32-S3] WIFI2[WiFi ESL 002
ESP32-S3] WIFI3[WiFi ESL 003
ESP32-S3] end subgraph "Gateway Network" MGW[Main Gateway
ESP32-S3] MESH1[Mesh Gateway 1
ESP32-C3] MESH2[Mesh Gateway 2
ESP32-C3] end subgraph "BLE ESL Devices" BLE1[BLE ESL 001
nRF52832] BLE2[BLE ESL 002
nRF52832] BLE3[BLE ESL 003
nRF52832] BLE4[BLE ESL 004
nRF52832] BLE5[BLE ESL 005
nRF52832] BLE6[BLE ESL 006
nRF52832] end end CLOUD --> SERVER SERVER --> ROUTER ROUTER --> MGW SERVER -.->|Direct WiFi| WIFI1 SERVER -.->|Direct WiFi| WIFI2 SERVER -.->|Direct WiFi| WIFI3 MGW -->|WiFi Mesh| MESH1 MGW -->|WiFi Mesh| MESH2 MGW -.->|BLE 5.0| BLE1 MGW -.->|BLE 5.0| BLE2 MESH1 -.->|BLE 5.0| BLE3 MESH1 -.->|BLE 5.0| BLE4 MESH2 -.->|BLE 5.0| BLE5 MESH2 -.->|BLE 5.0| BLE6 classDef serverClass fill:#667eea,stroke:#764ba2,stroke-width:2px,color:#fff classDef gatewayClass fill:#f093fb,stroke:#c084fc,stroke-width:2px,color:#000 classDef wifiClass fill:#10b981,stroke:#059669,stroke-width:2px,color:#fff classDef bleClass fill:#f59e0b,stroke:#d97706,stroke-width:2px,color:#fff class SERVER,CLOUD serverClass class MGW,MESH1,MESH2 gatewayClass class WIFI1,WIFI2,WIFI3 wifiClass class BLE1,BLE2,BLE3,BLE4,BLE5,BLE6 bleClass
Architecture Components
๐ฅ๏ธ Central Server
MQTT broker with global scheduling and queue management for all ESL devices
๐ Main Gateway
ESP32-S3 powered coordination hub with load balancing and mesh network management
๐ก Mesh Gateways
ESP32-C3 zone controllers with local BLE management and wake scheduling
๐ฑ ESL Devices
nRF52832 ultra-low power devices with 4+ year battery life and scheduled wake cycles
Sleep/Wake Protocol Flow
1๏ธโฃ Schedule Coordination
Central server calculates optimal wake times and distributes schedules to all gateways
2๏ธโฃ Message Queuing
Messages are queued per device with priority handling and distributed to zone gateways
3๏ธโฃ Zone Management
Each mesh gateway manages 4 ESL devices with staggered wake slots to prevent collisions
4๏ธโฃ Device Wake Cycle
ESL devices wake on schedule, check for messages, update if needed, then return to deep sleep
Power Management Benefits
- Ultra-Low Power: ESL devices consume <1ยตA in sleep mode
- Coordinated Wakes: Staggered timing prevents network congestion
- Message Buffering: Gateways queue messages during sleep periods
- Scalable Architecture: Support for hundreds of devices per gateway
Sleep/Wake Protocol Flow
This detailed flowchart shows the complete step-by-step process of the sleep/wake protocol from message initiation to device sleep.
~1ยตA Power] DeepSleep --> RTC[RTC Timer Active
Check every second] RTC --> CheckTime CheckTime -->|Yes| WakeUp[Wake Up Sequence
~5mA Power] WakeUp --> InitRadio[Initialize BLE Radio
~12mA Power] InitRadio --> ScanGW[Scan for Gateway
Advertising] ScanGW --> GWFound{Gateway Found?} GWFound -->|No| Timeout1{Timeout
30 seconds?} Timeout1 -->|No| ScanGW Timeout1 -->|Yes| EmergencySleep[Emergency Sleep
Try next cycle] EmergencySleep --> DeepSleep GWFound -->|Yes| Connect[Establish BLE
Connection] Connect --> Auth[Device Authentication
Send Device ID] Auth --> AuthSuccess{Auth OK?} AuthSuccess -->|No| AuthRetry{Retry < 3?} AuthRetry -->|Yes| Auth AuthRetry -->|No| EmergencySleep AuthSuccess -->|Yes| CheckQueue[Request Queued
Messages] CheckQueue --> HasMessages{Messages
Available?} HasMessages -->|No| SendStatus[Send Status Update
Battery, Signal] SendStatus --> CalcNext[Calculate Next
Wake Time] CalcNext --> SendAck[Send ACK to Gateway] SendAck --> Disconnect[Disconnect BLE] Disconnect --> DeepSleep HasMessages -->|Yes| ReceiveMsg[Receive Messages
~15mA Power] ReceiveMsg --> ValidateMsg{Message
Valid?} ValidateMsg -->|No| SendNack[Send NACK
Request Retransmit] SendNack --> ReceiveMsg ValidateMsg -->|Yes| ParseMsg[Parse Message
Type & Priority] ParseMsg --> MsgType{Message Type?} MsgType -->|Display Update| UpdateDisplay[Update E-ink Display
~20mA Power, 2-5 sec] MsgType -->|Config Update| UpdateConfig[Update Device Config
Save to Flash] MsgType -->|Status Request| CollectStatus[Collect Device Status
Battery, Temperature] MsgType -->|Firmware Update| FWUpdate[Firmware Update Process
~25mA Power] UpdateDisplay --> SendSuccess[Send Success ACK] UpdateConfig --> SendSuccess CollectStatus --> SendStatus FWUpdate --> SendSuccess SendSuccess --> MoreMessages{More Messages
in Queue?} MoreMessages -->|Yes| ReceiveMsg MoreMessages -->|No| CalcNext classDef sleepState fill:#e8f5e8,stroke:#10b981,stroke-width:2px classDef activeState fill:#fef3c7,stroke:#f59e0b,stroke-width:2px classDef commsState fill:#e0e7ff,stroke:#667eea,stroke-width:2px classDef errorState fill:#fef2f2,stroke:#ef4444,stroke-width:2px classDef processState fill:#f3e8ff,stroke:#8b5cf6,stroke-width:2px class DeepSleep,RTC,EmergencySleep sleepState class WakeUp,InitRadio,ScanGW,Connect,Disconnect activeState class Auth,CheckQueue,ReceiveMsg,SendStatus,SendAck,SendNack,SendSuccess commsState class Timeout1,AuthRetry errorState class ParseMsg,UpdateDisplay,UpdateConfig,CollectStatus,FWUpdate,CalcNext processState
Protocol Phases
๐ Sleep Phase
Power: ~1ยตA
Duration: Hours to days
Activity: RTC timer monitoring, ultra-low power mode
โก Wake Phase
Power: ~5-12mA
Duration: 100-500ms
Activity: MCU startup, radio initialization, gateway scanning
๐ก Communication Phase
Power: ~15mA
Duration: 2-30 seconds
Activity: BLE connection, authentication, data exchange
๐ Processing Phase
Power: ~20-25mA
Duration: 2-10 seconds
Activity: Display updates, config changes, status collection
Error Handling & Recovery
Error Condition | Detection Method | Recovery Action | Retry Policy |
---|---|---|---|
Gateway Not Found | 30-second scan timeout | Emergency sleep, try next cycle | Progressive backoff: 1min, 5min, 15min |
Authentication Failed | Server rejection response | Retry with fresh credentials | 3 attempts, then emergency sleep |
Message Corruption | CRC/checksum validation | Send NACK, request retransmit | 5 attempts per message |
Display Update Failed | Display driver error | Log error, continue with other messages | 1 retry, then skip to next message |
Low Battery | Voltage monitoring (<3.0V) | Extend sleep cycles, minimal updates | Gradual degradation to preserve data |
Power Consumption Analysis
With a 2000mAh battery and optimized protocol:
- Sleep Mode (99.9% of time): 1ยตA ร 8760 hours = 8.76mAh/year
- Wake Cycles (4 times/day): 15mA ร 30sec ร 1460 cycles = 182.5mAh/year
- Display Updates (2 times/day): 20mA ร 5sec ร 730 cycles = 20.3mAh/year
- Total Annual Usage: ~211mAh/year โ 9.5 year battery life
Gateway Queue Structure
This diagram shows how messages are queued and prioritized at the gateway level for delivery to ESL devices.
Queue Management Features
Priority Level | Use Case | Delivery Time | Retry Policy |
---|---|---|---|
URGENT | Critical updates, emergencies | Immediate (trigger wake) | 5 attempts, 1 min interval |
HIGH | Price changes, important updates | Next wake cycle | 3 attempts, 5 min interval |
NORMAL | Regular updates, content refresh | Scheduled wake time | 3 attempts, standard |
LOW | Maintenance, logs, metrics | Best effort | 1 attempt only |
Wake Timing Sequence
This diagram illustrates the precise timing of device wake cycles and how they are staggered to prevent network congestion.
Timing Considerations
โฑ๏ธ Slot Duration
15 seconds per device allows for connection setup, data transfer, and acknowledgment
๐ Overlap Strategy
20% overlap between slots enables efficient use of gateway resources
๐ Load Distribution
Devices are distributed across gateways to balance network load
๐ฏ Synchronization
All devices sync to gateway time during check-in for accurate scheduling
Complete Network Flow
This comprehensive diagram shows all possible message routing paths in the ESL MQTT system with our specific hardware architecture.
Hardware Specifications
๐ฑ WiFi ESLs (ESP32-S3)
Direct server connection for real-time updates
- Dual-core Xtensa LX7 @ 240MHz
- 512KB SRAM + up to 8MB PSRAM
- 802.11 b/g/n WiFi
- TLS encryption support
๐ก Main Gateway (ESP32-S3)
Primary bridge with BLE coordination
- Dual-core Xtensa LX7 @ 240MHz
- 512KB SRAM + 8MB PSRAM
- WiFi mesh + BLE 5.0
- PoE+ power supply
๐ก Mesh Gateways (ESP32-C3)
Cost-optimized zone coverage
- Single-core RISC-V @ 160MHz
- 400KB SRAM
- WiFi mesh + BLE 5.0
- PoE power supply
๐ BLE ESLs (nRF52832)
Ultra-low power with 4+ year battery life
- ARM Cortex-M4F @ 64MHz
- 64KB RAM, 512KB Flash
- BLE 5.0 with extended advertising
- <1ยตA standby current
Connection Types
- Solid lines (โท): Always-on connections (Internet, WiFi)
- Dashed lines (- - โ): On-demand connections (BLE, scheduled wake-ups)
- Double arrows (โท): Bidirectional communication
- Direct paths: WiFi ESLs bypass gateways for real-time updates
Hardware Architecture Overview
This diagram shows the specific hardware components and their relationships in our ESL system.
Key Hardware Benefits
๐ ESP32-S3 Performance
Dual-core 240MHz processor with 8MB PSRAM enables complex applications and real-time processing
๐ฐ ESP32-C3 Cost Efficiency
RISC-V architecture provides excellent price-performance ratio for mesh gateways
๐ nRF52832 Power Efficiency
Advanced power management achieves 4+ year battery life with scheduled wake cycles
๐ Direct WiFi Architecture
ESP32-S3 WiFi ESLs bypass gateways for critical real-time updates and high reliability
ESL Device State Machine
This diagram shows the various states an ESL device can be in and the transitions between them.
State Descriptions
State | Description | Power Usage | Typical Duration |
---|---|---|---|
Deep Sleep | Ultra-low power mode, RTC active | ~10 ยตA | Hours |
Wake Transition | MCU startup, radio initialization | ~5 mA | 100-200 ms |
Connecting | BLE scanning and connection setup | ~12 mA | 1-3 seconds |
Connected | Active BLE connection | ~15 mA | Variable |
Receiving Data | Downloading messages/images | ~15 mA | 2-10 seconds |
Updating Display | E-ink display refresh | ~20 mA | 2-5 seconds |