Radio communication for ESP8266 and ESP32 with ESPNOW

Last modified 6 months

ESP-NOW is a "new" radio communications protocol supported by the ESP8266 and ESP32, developed by Espressif, its manufacturer, which allows you to make very fast data transmissions (and when I say very fast, I mean very fast).

Its main objective is to replace Wifi to enable much lower power consumption and thus greater autonomy in battery-powered devices by allowing data to be sent in a few milliseconds, instead of the several seconds (3 to 12 seconds) that would be required with Wifi.

In addition to its speed there is another area where it excels, and that is in the range it provides. Where a wifi communication can have a range of 25 to 100 metres, with ESP-NOW we can easily obtain between 100 and 500 metres rangeand even more, depending on the conditions in both cases.

As I was saying, one of the biggest problems when we want to make low energy projects that work with batteries with an ESP8266 or ESP32 is that wifi communications kill autonomy.

There are two reasons for this:

  • They force the ESP8266 or ESP32 to stay awake for a long time (just to connect to our wifi network takes a long time). several secondseven if it then sends only one byte or even nothing).
  • The wifi protocol consumes a lot of energy, And when I say a lot, I mean a lot (relatively speaking, of course).

And if we could reduce this time to 40 msec (SI, FORTY MILLISECONDS). We would reduce consumption 200 TIMES. Only with this our project would go from having 48 hours of autonomy to having several months...Interesting?

Introduction (in the words of Espressif)

Before we introduce you to the ESP-NOW Gateway, let's take a closer look at the protocol...

ESP-NOW is a type of connectionless Wi-Fi communication protocol defined by Espressif. Unlike traditional Wi-Fi protocols, the first five upper OSI layers are simplified to a single layer in ESP-NOW, data does not need to pass through the physical layer, data link layer, network layer and transport layer, which reduces the delay caused by packet loss in a congested network and enables faster response time.

ESP-NOW occupies less CPU and flash resources, can work with Wi-Fi and Blutooth LE, supports ESP8266、ESP32、ESP32-S and ESP32-C series. The data transmission mode of ESP-NOW is flexible, including unicast and broadcast, supports one-to-many and many-to-many device connection and control. And ESP-NOW can be used as an independent auxiliary module to assist network configuration, debugging and firmware upgrades.

There are two roles defined in ESP-NOW according to the data flow, initiator and responder. The same device can have two roles at the same time. Typically, switches, sensors, LCD displays, etc., play the role of initiator in an IoT system, while lights, sockets and other smart applications play the role of responder.


There are some obvious advantages to ESP-NOW:

  1. Fast response: After powering on, devices can transmit data and control other paired devices directly without any wireless connection, and the response speed is milliseconds.
  2. Low power consumption: ESP-NOW simplifies the five-layer protocols into a single layer, leading to an easier communication process and lower power consumption, one control button can be used for two years with only two AA batteries.
  3. Good Compatibility: When the device connects to the router or works as a hotspot, it can also realize fast and stable communication by ESP-NOW. And the device can maintain a stable connection through ESP-NOW even if the router is faulty or the network is unstable.
  4. Long distance communication: ESP-NOW supports long distance communication, can be applied to outdoor scenes and can maintain a stable connection, even devices are separated by walls or even floors.
  5. Multi-layer control: We can realise multi-hop control of devices by ESP-NOW. Hundreds of devices can be controlled through unicast, broadcast and group control.
    Multiple control methods: ESP-NOW supports touch switch, LCD display, different sensors and voice control.


ESP-NOW is a provisioning method in addition to Wi-Fi provisioning and Bluetooth provisioning. Firstly, it sets up the network for the first device via bluetooth, and the other devices do not need the SSID/password information, the first device connected to the network can send this information to the others directly. Users can choose whether to allow the remaining devices to access the network on the APP side.


ESP-NOW can be used for bulk data transmission such as firmware updates.

  1. Resume upgrade from breakpoint: When ESP-NOW is used to upgrade the firmware, the firmware will be sub-packaged in a fixed size and written to the flash memory one by one, the device will register the upgraded packages. If the update process is interrupted, the device shall only request the remaining firmware packages to perform the update from the interruption point.
  2. Updating multiple devices: ESP-NOW can support updating multiple devices at the same time, 50 devices can be updated in 3 minutes.
  3. Version reset: the firmware can reset to the previous version if an upgrade error occurs.


ESP-NOW can be used to receive the operating log for debugging. It can be used in cases where it cannot have direct contact with devices due to high voltage, high temperature electricity. With the support of many-to-many connections, the initiator can receive logs from multiple responders to diagnose device failures quickly.

  1. Device logs
    • Log analysis: analyse uptime and restart times from the log.
    • Log storage: store acquired data on SD cards or export it to the web.
    • Log modification: the log level of each function model can be freely adjusted.
  2. Command debugging
    • Peripheral debugging: Control commands can be sent to test peripherals such as GPIO, UART, LED, etc.
    • Wi-Fi debugging: the country code, Wi-Fi mode, Wi-Fi power, etc. can be adjusted, and Wi-Fi performance can be debugged.
    • Debugging status: restart command, reset command, memory status and running task status.
    • Customised commands
  3. Production testing
    • Interference testing: distribute a large number of Wi-Fi data packets to interfere with the network.
    • Wireless Testing: monitor RF performance, ping packet test, distance and RF performance test.
    • Module testing: flash reading time test, timing accuracy test.
    • Version check: check if the factory version of the device is as specified.

Data encryption

ESP-NOW can protect data security with ECDH and AES128-CCM.

  1. Fast configuration: 16 devices can be configured in 5 seconds.
  2. Multiple Device Handshake: The ESP-NOW initiator can support handshake of multiple devices at the same time.
  3. Security:
    • ECDH and proof of possession (PoP) string used to authorise the session and derive the shared key.
    • AES256-CTR encryption of configuration data.
    • AES128-CCM encryption of ESP-NOW data.

Limitations of ESP-NOW

As with all things in life, ESP-NOW is not all advantages. In the end, in order to achieve such short transmission times, you have to making compromises and these are some of them:

Less data

What is the wifi data limit? You know that none, we can watch a movie over wifi or we can even watch unlimited video streaming. This is not the case with ESP-NOW.

ESP-NOW has a limitation on the amount of data it can send in a few seconds. 250 bytes. Of course, there is nothing to stop us from doing all the independent data transfers (250 bytes each) to send whatever we want, no matter how big it is. But, of course, ESP-NOW is no longer so advantageous and it is probably preferable to use wifi.

Limiting encrypted pairs

If we want the transmissions are encryptedESP-NOW does not make it easy for us if we have many devices.

The following are admitted 10 encrypted pairs maximum in Station mode and 6 maximum in SoftAP or SoftAP + Station mode. Multiple unencrypted peers are supported, but the total number of encrypted nodes must be less than 20.

Fortunately ESP-NOW is mainly used for sensors in the home environment, so it is not very important if someone has access to this data and encryption is usually not a must.

Of course, nothing prevents us from creating our own software encryption system without this limitation.

Advantages and disadvantages of ESP-NOW vs LoRa

This is a question that often comes up and that is why I have included it here, although it really has little to do with each other and is intended for different cases.

ESP-NOW and LoRa are not comparable. (neither for better nor for worse):

  • Nor in cost: For ESP-NOW we do not need any additional hardware, while for LoRa we will need a LoRa radio module.
  • Neither in complexity: The solution with ESP-NOW is very fast and simple while implementing LoRa is relatively complicated.
  • Neither in range: Typically with ESP-NOW we can cover between 100 and 500 metres, whereas with LoRa we can cover several kilometres.
  • Nor in the amount of data we can send: With ESP-NOW we can send as much data as we want in 250-byte messages, as fast as we want. With LoRa, communications are much slower and the percentage of time we can transmit is limited by regulation, as well as the spacing in time between different transmissions.

ESP-NOW to MQTT Gateway

I have developed a gateway that allows you to easily link the ESP-NOW world with the MQTT world, the standard IoT (Internet of Things) protocol via WiFi.

In the following article you will find everything you need to get your gateway up and running quickly so that you can adapt it to your needs easily.

Leave a comment