- Implementation of fast and low-power wireless communications without the need for a WiFi router.
- Ability to manage data flows from one-to-many, many-to-one, and complex many-to-many networks.
- Support for sending custom data structures and compatibility between different Espressif board models.
If you're involved in home automation or sensors, you'll know that conventional Wi-Fi can sometimes be a bit slow and drains the battery. This is where ESP-NOW comes in, a proprietary protocol from Espressif that allows your smart boards to communicate with each other almost instantly, without having to go through the cumbersome process of connecting to a router or waiting for DHCP to assign an IP address.
The most amazing thing about this system is its extreme versatility. Whether you simply want to send data from one board to another or you have an entire network of collaborating nodes , ESP-NOW can handle it all. In this article, we'll break down how to set up these connections, from the very basics to advanced configurations where all devices act as both transmitters and receivers.
What exactly is ESP-NOW?
Basically, it's a wireless communication protocol that simplifies the OSI model. While traditional Wi-Fi uses multiple layers to ensure data delivery, ESP-NOW merges the upper layers into a single layer , drastically reducing latency. This means response time drops from several seconds to just a few milliseconds, which is crucial when working with battery-powered devices.
In terms of range, it's surprisingly robust. While a typical home Wi-Fi network usually falters around 50 meters, with ESP-NOW you can achieve distances of between 100 and 500 meters, depending on whether there are walls in between or if you're outdoors. Furthermore, it's fully compatible with the ESP32, ESP8266, and the new S and C series.
Types of communication and architectures
Depending on your project needs, you can configure the network in different ways:
- One by one: The simplest configuration, where a sender sends data to a specific receiver.
- One to many: A master node distributes information to several slaves.
- Many to one: Ideal for sensor networks where multiple nodes send readings to a central point.
- Many to many: This is where things get interesting, because multiple devices operate simultaneously as senders and receivers, creating a network where information flows in all directions.
To set up a many-to-many network, the trick is to combine the logic of the previous methods. You'll need to register the MAC addresses of all the nodes you want to communicate with. If you want to create a mesh network where absolutely everyone can communicate with everyone else, you'll only need to manage a single, shared MAC address list.
Technical implementation and code
To get this up and running, we need the library esp_now.hA key point is that, in order for the devices to understand each other, they must use a identical data structure at both ends. If the sender sends an integer and a float, the receiver should be expecting exactly that.
The role of the sender
In order for the ESP32 to know who to send the packet to, it needs the receiver's MAC addressIn the code, we configure the device in mode WIFI_STA and we registered a callback function called OnDataSent, which will notify us if the package arrived at its destination or if there was any transmission failure.
The role of the receiver
The receiver, meanwhile, must be attentive to any signal. For this, we use the function esp_now_register_recv_cbWhen data arrives, a function is triggered that copy the information received in our local structure through memcpyallowing us to read the values and process them in real time.
Bidirectional communication (Transceivers)
If you want your boards to both communicate and listen, you need to create a transceiver . This is achieved by implementing both the sending and receiving functions within the same code. It's the foundation for creating interactive control systems where the receiver can confirm the receipt of a command or send an alert to the master.
Operational advantages and use cases
ESP-NOW's use isn't limited to simply sending data. It's an incredibly powerful tool for network provisioning . For example, you can configure a device via Bluetooth, and that device, in turn, can use ESP-NOW to pass its Wi-Fi credentials to all other nodes without any user intervention.
It's also ideal for bulk firmware updates . It allows sending fixed data packets, and if the connection drops, the device can request only the missing pieces, avoiding having to start from scratch. Furthermore, it's a boon for developers when it comes to remote debugging , as it allows them to extract logs from devices in dangerous or inaccessible areas.
Limitations and comparisons
It's not all sunshine and rainbows. ESP-NOW has an upload limit of approximately 250 bytes per packet . If you need to move large files or stream video, traditional Wi-Fi is still king. Furthermore, if you're looking for maximum security, peer encryption has its limits: you can only have a few encrypted peers (between 6 and 20 depending on the mode), although you can always program your own software encryption system.
If you're wondering whether it's better than LoRa, the answer depends on the use case. LoRa is unbeatable over distances of kilometers, but it's much slower and requires extra hardware. ESP-NOW is cheaper, faster to implement , and handles much larger amounts of data over short and medium distances.
This protocol transforms the way Espressif devices connect by eliminating the need for a router, optimizing energy consumption, and enabling flexible architectures ranging from simple sensors to complex bidirectional communication networks between multiple nodes.
FAQ
Is it possible to use WiFi and ESP-NOW simultaneously on an ESP32?
Yes, the protocol allows a station to connect to a WiFi network and, at the same time, maintain fast communications using ESP-NOW.
How much data can be sent in a single ESP-NOW message?
The maximum transmission capacity is approximately 250 bytes per data packet sent.
What is a MAC address and what is its purpose in this protocol?
It is the unique identifier of each plate and is essential for the sender to know exactly which device to direct the message to.
How can multiple ESP32s communicate with each other simultaneously?
A many-to-many architecture must be configured, registering the MAC addresses of all participating nodes as communication peers.
What is the difference between ESP-NOW and LoRa in terms of range?
ESP-NOW generally reaches between 100 and 500 meters, while LoRa can cover several kilometers of distance.
Can an ESP32 and an ESP8266 communicate using ESP-NOW?
Yes, it is entirely possible as long as the code is adapted to the specific characteristics of each card and they share the same data structure.
What happens if the connection is interrupted during a firmware update?
The protocol allows recording the packets already received and requesting only the remaining information from the point where the outage occurred.


