ESP-NOW Packet Interface
The espnow Packet Interface platform sends and receives packets with
ESP-NOW, between ESP32 and ESP8266 devices on the same Wi-Fi channel. Each packet is sent as
one ESP-NOW packet.
With a peer_address, packets are sent to that device only, and only packets that device sends to this one are
accepted, so no addressing layer is needed, and one cannot be configured.
The device is added to the peers of the espnow component.
Without a peer_address, packets are broadcast to every device on the channel, and every broadcast packet received
is accepted, including from devices that are not in the espnow component’s peers. An addressing layer can then tell
the devices apart. The reliability and
session layers, and the rolling code, work between two devices only, so on
such a link they need an addressing layer with a destination.
One espnow component can carry links to several peers and a broadcast link at the same time. On ESP8266, which does
not report where a packet was sent, a broadcast link also receives the packets sent to this device by its peers, so
there an addressing layer is needed on the broadcast link to drop them. In the same way, a peer link on ESP8266 also
receives the broadcasts sent by its peer.
ESP-NOW does not resend lost packets on its own, so add a reliability layer
if every packet must arrive. With a peer_address, the peer acknowledges each packet it receives; a packet it does not
acknowledge, because it is off, out of range or has another address, is logged as a warning at most once a minute.
Received packets carry the sender’s MAC address and, on ESP32, the RSSI.
Example Configuration
Section titled “Example Configuration”# Example configuration entryespnow:
packet_interface: - platform: espnow id: espnow_link # The MAC address of the other device peer_address: 10:22:33:44:55:66 encryption: !secret espnow_link_key reliability: session:Configuration Variables
Section titled “Configuration Variables”- peer_address (Optional, MAC address): The MAC address of the device to exchange packets with. Defaults to
FF:FF:FF:FF:FF:FF, which broadcasts to every device. A group address, or00:00:00:00:00:00, is rejected. - espnow_id (Optional, ID): The ID of the ESP-NOW component to use.
- max_packet_size (Optional, int): The largest packet, in bytes, that can be sent or received. A larger packet
received is dropped, with a warning, so set the same value on both devices. Range is 16 to 1470, and it cannot be
larger than the
max_payload_sizeof theespnowcomponent. Defaults to250. Use a fragmentation layer for larger packets. - id (Optional, ID): Manually specify the ID used for code generation.