Mesh-NOW

Serverless mesh networking for ESP32. Device-to-device communication over ESP-NOW with automatic peer discovery, multi-hop routing, and payload encryption.

ESP32
ESP-NOW
Mesh Network

Quick Start
GitHub
#include "mesh_now.h"

// Initialize the mesh
mesh_now_init();

// Set receive callback (before or after init)
mesh_now_set_receive_callback(on_message);

// Send a broadcast message
mesh_now_send_broadcast("Hello, mesh!");

// Enable encryption: the key must be exactly 16 bytes (AES-128)
uint8_t key[16] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
                   0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10};
mesh_now_set_encryption_key(key, sizeof(key));

Features

Serverless

Direct ESP32-to-ESP32 over ESP-NOW. No router, no internet, no infrastructure.

Auto Discovery

Nodes broadcast beacons every 5 seconds by default. Peers are discovered and tracked with no setup.

Multi-Hop Routing

Messages propagate through the mesh with a configurable hop limit (default 3).

Reliable Delivery

Direct messages get ACK-based retransmission: up to 3 retries on a 2-second timeout.

Encrypted Payloads

Optional AES-128-GCM payload encryption with a 16-byte key.

10 Message Types

Beacon, chat, direct, ACK, group, presence, typing, and the route discovery frames (request, reply, error).

Supported Targets

Target Architecture RAM Status
ESP32 Dual-core Xtensa 520KB Supported
ESP32-S2 Single-core Xtensa 320KB Supported
ESP32-S3 Dual-core Xtensa 512KB Supported
ESP32-C3 Single-core RISC-V 400KB Supported
ESP32-C6 Single-core RISC-V 512KB Supported

Architecture

flowchart LR subgraph Node1["ESP32 Node 1"] A1[Application] --> B1[mesh_now library] B1 --> C1[ESP-NOW] end subgraph Node2["ESP32 Node 2"] A2[Application] --> B2[mesh_now library] B2 --> C2[ESP-NOW] end subgraph Node3["ESP32 Node 3"] A3[Application] --> B3[mesh_now library] B3 --> C3[ESP-NOW] end C1 <--> C2 C2 <--> C3 C1 <--> C3