Core Concepts
Mesh-NOW is a protocol library that turns any ESP32 into a mesh node. ESP-NOW is the transport; Mesh-NOW adds discovery, routing, groups, and optional encryption on top of it. Every node runs the same firmware, so you never designate a router or coordinator.
Architecture
flowchart TB
subgraph App["Application Layer"]
A[Your Code]
end
subgraph Lib["Mesh-NOW Library"]
B[mesh_now API]
C[Peer Manager]
D[Message Router]
E[Retransmit Engine]
F[Beacon Task]
end
subgraph Transport["ESP-NOW Layer"]
G[esp_now_send / esp_now_recv]
end
A --> B
B --> C
B --> D
B --> E
B --> F
C --> G
D --> G
E --> G
F --> G
Node Roles
There are no special roles. Every node can:
- Discover peers via periodic beacon broadcasts
- Send messages (broadcast, direct, or group)
- Route messages for other nodes (multi-hop relay)
- Acknowledge messages and retransmit on failure
Message Flow
- Application calls
mesh_now_send_broadcast()ormesh_now_send_direct() - Library assigns a unique message ID, sets the hop limit, stamps the timestamp
- Library encrypts the payload if an encryption key is set
- Library sends via
esp_now_send()to the broadcast MAC - Receiving nodes check for duplicates, decrypt if needed, invoke the callback
- Relay nodes drop when the hop count hits the limit, otherwise re-broadcast
- Direct messages trigger an ACK, which propagates back to the sender
FreeRTOS Tasks
Mesh-NOW creates two tasks, both pinned to core 0:
| Task | Stack | Priority | Purpose |
|---|---|---|---|
beacon_task |
8192 bytes | 5 | Broadcasts discovery beacons every 5 seconds |
retransmit_task |
8192 bytes | 5 | Retransmits pending messages every 500ms |
Core Affinity
Both tasks run on core 0. If your application leans hard on core 0, bump the priorities or change the affinity in mesh_now_tasks.c.
Memory Footprint
| Component | RAM |
|---|---|
| Peer table (20 peers) | ~640 bytes |
| Pending messages (16 slots) | ~4.6 KB |
| Seen message IDs (128 entries) | ~512 bytes |
| Beacon task stack | 8192 bytes |
| Retransmit task stack | 8192 bytes |
| Total library overhead | ~14 KB |