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).

Quick update on my journey with ESP-NOW.

A week or so ago I managed to get a simple network working using ESP32-S2-Mini devices.
Flushed with success I replaced the S2's with C3 super-minis - that is when my troubles began.


The PCBs I had designed for the network would accommodate an S2 or an C3 - the only difference was pin-mapping which was taken care-of using an external 'device_profile' file.

After loads of dead-ends and head-scratching I realised the problem was the power regulation!!
The ESP32-S2 has a larger linear regulator on the board than the C3 - look at these photos...



So what was happening was when the WiFi was in 'transmit' mode the current consumption was very near or exceeded the safe working value on the C3 - which resulted in a power surge that threw the C3 into a re-boot or reset or some situation that prevented the successful transmission of a message!! Difficult to find out as the Micro-Python didn't throw an error - just went silent.

As I'm using Micro-Python to program the devices I found the WiFi transmit power can be controlled with...

wlan.config(txpower=XX) where XX can range from 0 to 20.

I found that setting txpower=15 resulted in reliable transmissions.

I now have a working network (Sensor, Relay & Receiver) using ESP32-C3-Super-Mini devices.

4 Likes

Here's a table to show some of the mappings for txpower to dBm values.


I'm using txpower=15 (which is not shown). txpower=17 also works - also not shown.

I believe the ESP32‑C3 radio supports TX power settings in 0.25 dBm steps, all the way up to about 19.5 dBm as I've seen 17.5 and 18.5 being used in some Python scripts.

Another thing to be aware of is... there many different clones of the ESP32-C3-Super-Mini. Although they are functionally the same, the layout on the printed circuit boards can vary.

A key aspect I have discovered is the positioning of the crystal in relation to the C3 chip antenna.

Here's a photo a typical clone... notice how close the crystal is to the C3 antenna.

The photo of the ESP32-C3-Super-Mini made by Tenstar Robot - shows more space around C3.


The Wi-Fi on Tenstar Robot devices has proven to be more reliable on my ESP-NOW project.

1 Like

Another quick update...

Spotted these ESP32-C3-Super-Mini boards on AE that have an IPEX socket on the board (as well as the C3 ceramic antenna) and have the coupling-capacitor already soldered so the IPEX is active. The ESP32 bundle I ordered came with an external antenna and lead for £2.25 each.

1 Like

How "profitable" is it to buy such modules if they are similar, such as the XIAO ESP32C3, and quite close in price? For a few EUR/USD per piece, you get an excellent design, a schematic with part numbers, and a mechanical drawing.

Can you post a link to that item?

1 Like

Just adding this here as things do move quickly on the ESP32 front. One chart to rule them all!

2 Likes

OMG - they look nice - I'll have to order some and try them out.

Bit unusual having 7-pins on each edge rather than 8. I like the idea of ditching the C3 ceramic chip antenna and using a decent external rod antenna - should give a good range for the WiFi.

Loads of information on the Wiki and specifically for XIAO ESP32-C3.

David, Did you see this one?

1 Like

OMG - that looks pretty cool as well.