Skip to content

ESP-NOW Control

ESP-NOW is a connectionless protocol developed by Espressif that enables direct peer-to-peer communication between ESP32 devices without requiring a WiFi access point. This is ideal for multi-arm coordination, remote controllers, and low-latency wireless control.

  • Leader: The device that sends control commands (can be another RoArm-M2-S or any ESP32)
  • Follower: The arm that receives and executes commands
  • Broadcast: Send to all followers simultaneously using FF:FF:FF:FF:FF:FF
  • Group: Send to multiple registered peers
  • Single: Send to one specific peer by MAC address
  1. Get each device’s MAC address

    {"T":302}
  2. Configure the follower arm

    Enable broadcast reception (accepts commands from any leader):

    {"T":300,"mode":1}

    Or restrict to a specific leader MAC:

    {"T":300,"mode":0,"mac":"CC:DB:A7:5B:E4:1C"}
  3. Configure the leader device

    Set as group leader (sends to all registered followers):

    {"T":301,"mode":1}

    Or as single-target leader:

    {"T":301,"mode":2}
  4. Add follower(s) to the leader’s peer list

    {"T":303,"mac":"CC:DB:A7:5B:E4:1C"}
ModeCodeDescription
None0ESP-NOW disabled
Group Leader1Sends commands to all registered peers
Single Leader2Sends to one specific follower
Follower3Receives and executes commands (default)

Send to all registered peers simultaneously:

{"T":305,"dev":0,"b":0,"s":0,"e":1.57,"h":1.57,"cmd":0,"megs":"hello!"}
ParameterDescription
devDevice type identifier
b, s, e, hJoint angles (base, shoulder, elbow, hand)
cmdCommand mode: 0 = mirror joint positions, 1 = send JSON command in megs
megsMessage string (JSON command when cmd=1)

Send to one specific device (or broadcast to all with FF:FF:FF:FF:FF:FF):

{"T":306,"mac":"CC:DB:A7:5B:E4:1C","dev":0,"b":0,"s":0,"e":1.57,"h":1.57,"cmd":0,"megs":"hello!"}

Set cmd to 1 and put the JSON command string in megs:

{"T":306,"mac":"FF:FF:FF:FF:FF:FF","dev":0,"b":0,"s":0,"e":0,"h":0,"cmd":1,"megs":"{\"T\":114,\"led\":255}"}

This turns on the LED on all followers.

When the leader is set to mode 1 or 2 with cmd=0, it continuously mirrors its own servo positions to followers. This creates a leader-follower teleoperation setup:

  1. Move the leader arm manually (with torque lock off)
  2. The follower arm tracks the leader’s movements in real time

Add a follower:

{"T":303,"mac":"CC:DB:A7:5C:1C:40"}

Remove a follower:

{"T":304,"mac":"CC:DB:A7:5C:1C:40"}
T-CodeCommandDescription
300Broadcast follower configEnable/disable broadcast reception
301ESP-NOW modeSet leader/follower mode
302Get MACRead this device’s MAC address
303Add followerRegister a peer MAC
304Remove followerUnregister a peer MAC
305Group controlSend to all peers
306Single controlSend to specific MAC

ESP-NOW reference from firmware source json_cmd.h and Waveshare Wiki.