a simple network using esp-now
  • C 94.2%
  • CMake 5.8%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-10-01 10:12:34 +02:00
agent improve: use enum for message types 2025-11-21 22:21:46 +01:00
handler improve: use enum for message types 2025-11-21 22:21:46 +01:00
.gitignore feat: add basic agent 2025-10-28 14:31:22 +01:00
README.md chore: fix typo's, cleanup and clarifications 2026-10-01 10:12:34 +02:00

ESP32 Command Control

A simple handler-agent like network with encryption, uses the ESP-NOW protocol.

Objectives

  • Implement ESP-NOW device-to-device communication
  • Analyze protocol security and encryption
  • Build a simple network

Retrospect: Project is complete


Architecture

    Handler
        |
        | ESP-NOW broadcasts
        |
    +---+---+
    |       |
Agent #1  Agent #2

The handler listens for special messages containing a shared secret (base64 encoded string) with certain message types. Example: An agent sends a type 0 msg, the handler receives & validates it. It adds the agent to a local list, waits for type 2 messages (heartbeats). The handler registers an agent as an encrypted peer when its first heartbeat arrives, so that heartbeat is unencrypted and all later ones are encrypted.


Requirements

  • 3x ESP32 DevKit boards
  • USB cables
  • Development environment: ESP-IDF

Project Structure

root/
├── handler/
│   └── main/
│       └── main.c
├── agent/
│   └── main/
│       └── main.c
└── README.md

Building & flashing

Note: Hold BOOT button before flashing (At least, I have to do this, on windows...)

Prerequisites

Install CP210x/CH340 USB drivers:

MacOS (arm64 in my case)

brew install cmake ninja dfu-util

# setup ESP-IDF
mkdir -p ~/esp
cd ~/esp
git clone --recursive https://github.com/espressif/esp-idf.git
cd esp-idf
./install.sh esp32

# build and flash - X = handler or agent dir
cd X 
# activate esp dev env (i use an alias)
idf.py build
idf.py -p /dev/cu.usbserial-* flash monitor

Windows

Manually install the IDF tools

# open "ESP-IDF PowerShell"

# build and flash - X = handler or agent dir
cd X 
idf.py build
idf.py -p COM3 flash monitor

Usage

Flash Handler to one ESP32, Agent firmware to the others. Monitor serial output to observe communication.