Check this out... ESP-NOW (communication protocol)

I think it might be possible to construct a ESP32-NOW Gateway...
[ESP-NOW Nodes] ---> [ESP32-S2 Gateway] ---> [MQTT Broker] ---> Node-RED

Possible experiment for the weekend.

2 Likes

Dave, this has been around for some time -

See also Super Simple ESPNow to Wi-Fi / MQTT Gateway : 7 Steps - Instructables

1 Like

esp-now is nice, except for one downside (to me) - a message is limited to 250 bytes, which should be sufficient for many applications but it takes away some flexibility.

I couldn't wait until the weekend - had to have a play today.
I've managed to create, using Micro-Python, a script for a 'now_sender' and a 'now_gateway'.
Note: You will need to change the suffix from .txt to .py as the Forum doesn't allow Python files.

now_gateway.txt (2.0 KB)
now_sender_v1.txt (1.4 KB)

The scripts will auto-discover the MAC addresses needed for communication.
You need to make sure the sender is on the same WiFi channel as the Gateway to MQTT.

Having got a simple 'Sender' to 'Gateway' setup working I intend to explore what I can do with ESP-NOW further. For example, sending commands (from the Gateway) to the Sender to get it send BME280 T/H/P readings on-demand or change its parameters (like update intervals).

ESP-NOW is a proprietary, low-power, peer-to-peer communication protocol developed by Espressif. It doesn’t rely on a WiFi router.

Features:

  • Peer-to-peer communication: Devices can communicate directly without a router or internet.
  • Low-latency: Message delivery is very fast (milliseconds).
  • Broadcast support: Can send to a single peer or broadcast to multiple devices.
  • Lightweight protocol: Minimal overhead, just sending raw data or JSON.
  • MAC address based: Each device identifies peers by MAC addresses.
  • No IP stack needed: Works at the link layer.

Benefits:

  • Low power consumption: Devices can stay in sleep mode most of the time.
  • Reliable for small data: Perfect for sensor networks or simple control messages.
  • No WiFi network needed: Useful in remote areas or ad-hoc networks.
  • Fast discovery and communication: Can instantly send small packets.

Limitations:

  • Short range: Similar to WiFi (depends on antenna and environment).
  • Limited payload: Max ~250 bytes per packet.
  • Limited network complexity: Best for small networks (20-30 nodes practical).
  • No encryption by default: Requires extra configuration for security.

Comparison Table

Feature ESP-NOW WiFi (Conventional)
Network Type Peer-to-peer Router-based
Latency Very low (ms) Moderate (ms → s)
Payload Small (~250 bytes) Large (KB → MB)
Power Very low Higher
Range ~100 m line-of-sight ~100 m (depends on AP)
Scalability Limited (20–30 nodes) High (hundreds of nodes)
Security Optional Standard (WPA2/WPA3, TLS)
Internet Access :cross_mark: :white_check_mark:
Best Use Case Sensor networks, remote controls, IoT nodes Cloud IoT, web apps, video, audio

Perhaps you want to consider a dedicated ESP as gateway, then you are not limited to a single wifi channel.

ie:


Where 1 is handling esp-now to wifi and the other is dedicated to esp-now

1 Like

That's a good suggestion - as I was trying work out how my Gateway could tell the Sender which WiFi channel to use. Your method means the 'esp-now to wifi' microcontroller could do a scan and pick the strongest AP (as I do with a number of my other nodes).