<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>sensor-network &#8211; Quality RC Parts</title>
	<atom:link href="https://qualityrcparts.com/tag/sensor-network/feed/" rel="self" type="application/rss+xml" />
	<link>https://qualityrcparts.com</link>
	<description>SHIPS FAST FROM NY, USA</description>
	<lastBuildDate>Sun, 22 Nov 2026 09:19:15 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.1.5</generator>

<image>
	<url>https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/09/qrc-logo-6-com-inside-short-512x512-1.png?fit=32%2C32&#038;ssl=1</url>
	<title>sensor-network &#8211; Quality RC Parts</title>
	<link>https://qualityrcparts.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">257527959</site>	<item>
		<title>ESP-NOW Explained: Two ESP32 Boards, No Router</title>
		<link>https://qualityrcparts.com/esp-now-explained/</link>
		
		<dc:creator><![CDATA[admin]]></dc:creator>
		<pubDate>Sun, 22 Nov 2026 09:19:15 +0000</pubDate>
				<category><![CDATA[Drone Guides]]></category>
		<category><![CDATA[arduino-ide]]></category>
		<category><![CDATA[esp-now]]></category>
		<category><![CDATA[esp32]]></category>
		<category><![CDATA[esp32-c3]]></category>
		<category><![CDATA[esp32-c6]]></category>
		<category><![CDATA[esp32-s3]]></category>
		<category><![CDATA[esp32-wifi]]></category>
		<category><![CDATA[esp8266]]></category>
		<category><![CDATA[iot]]></category>
		<category><![CDATA[peer-to-peer]]></category>
		<category><![CDATA[platformio]]></category>
		<category><![CDATA[sensor-network]]></category>
		<category><![CDATA[wireless]]></category>
		<guid isPermaLink="false">https://qualityrcparts.com/esp-now-explained/</guid>

					<description><![CDATA[Last updated: 2026-11-22 Yes, two ESP32 boards can talk to each other with no router, no Wi-Fi password, and no internet connection. The protocol is called ESP-NOW. Each board sends small packets of up to 250 bytes straight to the other board&#x27;s MAC address, usually arriving in a few milliseconds. This guide explains how ESP-NOW [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Last updated: 2026-11-22</p>
<p>Yes, two ESP32 boards can talk to each other with no router, no Wi-Fi password, and no internet connection. The protocol is called ESP-NOW. Each board sends small packets of up to 250 bytes straight to the other board&#x27;s MAC address, usually arriving in a few milliseconds. This guide explains how ESP-NOW works, its limits, how to encrypt it, when to pick it over Wi-Fi or Bluetooth, and gives you a working two-way sketch.</p>
<h2 id="table-of-contents">Table of contents</h2>
<ul>
<li><a href="#what-is-esp-now">What is ESP-NOW?</a></li>
<li><a href="#what-are-the-esp-now-limits">What are the ESP-NOW limits?</a></li>
<li><a href="#how-do-the-send-and-receive-callbacks-work">How do the send and receive callbacks work?</a></li>
<li><a href="#unicast-vs-broadcast-which-one-do-i-use">Unicast vs broadcast: which one do I use?</a></li>
<li><a href="#how-do-i-encrypt-esp-now-packets">How do I encrypt ESP-NOW packets?</a></li>
<li><a href="#esp-now-vs-wi-fi-vs-bluetooth">ESP-NOW vs Wi-Fi vs Bluetooth</a></li>
<li><a href="#which-boards-support-esp-now">Which boards support ESP-NOW?</a></li>
<li><a href="#can-esp-now-and-wi-fi-run-at-the-same-time">Can ESP-NOW and Wi-Fi run at the same time?</a></li>
<li><a href="#what-range-can-i-expect">What range can I expect?</a></li>
<li><a href="#the-two-way-sketch-a-button-on-one-board-an-led-on-the-other">The two-way sketch: a button on one board, an LED on the other</a></li>
<li><a href="#what-goes-wrong">What goes wrong?</a></li>
<li><a href="#frequently-asked-questions">Frequently asked questions</a></li>
<li><a href="#parts-used-in-this-guide">Parts used in this guide</a></li>
<li><a href="#in-this-series">In this series</a></li>
<li><a href="#sources">Sources</a></li>
</ul>
<h2 id="what-is-esp-now">What is ESP-NOW?</h2>
<p>ESP-NOW is a connectionless wireless protocol from Espressif that lets ESP32 and ESP8266 boards send data directly to each other using the Wi-Fi radio, without joining a network. There is no router, no access point, no password, no DHCP, and no IP address. The sender puts its data inside a short Wi-Fi packet called a vendor-specific action frame and addresses it to the receiver&#x27;s MAC address. The receiver&#x27;s hardware answers with an acknowledgement frame, and a callback on the sender reports whether it was delivered.</p>
<p>With normal Wi-Fi, a board first connects to the router, checks the password, gets an IP address, and only then sends data, which usually takes 1 to 3 seconds. ESP-NOW skips all of it, so a <a href="https://qualityrcparts.com/low-power-esp32-battery-projects/">battery sensor</a> can wake up, send its reading, and go back to sleep within a few hundred milliseconds. While connecting to Wi-Fi the radio draws more than 100 mA for seconds; with ESP-NOW the board is awake for a fraction of a second. That is why ESP-NOW is the standard choice for battery sensors, remote controls, and <a href="https://qualityrcparts.com/esp-now-joystick-robot-car/">two-board robot cars</a>.</p>
<p>ESP-NOW is not a replacement for Wi-Fi. It has no internet, no phone can talk to it, and it only works between Espressif chips. If you need a web page or a cloud dashboard, one board acts as a gateway: it talks ESP-NOW to the sensors and Wi-Fi to your router.</p>
<h2 id="what-are-the-esp-now-limits">What are the ESP-NOW limits?</h2>
<p>Learn these limits before you design the network, because they decide the packet format and the number of boards you can use.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Limit</th>
<th>Value</th>
<th>What it means</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data per packet</td>
<td>250 bytes (ESP-NOW v1)</td>
<td>Sensor values fit easily; a photo does not</td>
</tr>
<tr>
<td>Data per packet, v2</td>
<td>1470 bytes (ESP-IDF 5.4 and later)</td>
<td>Arduino core 3.2+; a v1 board truncates or drops packets over 250 bytes, so stay at 250 in mixed networks</td>
</tr>
<tr>
<td>Registered peers</td>
<td>Up to 20 per board</td>
<td>The boards you send to; a gateway can listen to more sensors if it only receives unencrypted packets</td>
</tr>
<tr>
<td>Encrypted peers</td>
<td>7 by default</td>
<td>Older Arduino cores allowed 10; the limit is configurable in ESP-IDF up to 17</td>
</tr>
<tr>
<td>Default data rate</td>
<td>1 Mbps</td>
<td>Higher rate means shorter range; Long Range drops to 0.5 or 0.25 Mbps</td>
</tr>
<tr>
<td>Frequency</td>
<td>2.4 GHz, channels 1 to 13</td>
<td>Both boards must use the same channel</td>
</tr>
<tr>
<td>Delivery acknowledgement</td>
<td>Yes for unicast, none for broadcast</td>
<td>Unicast gets a hardware ACK; broadcast never confirms arrival</td>
</tr>
</tbody>
</table>
</figure>
<p>The 250-byte limit is the one that shapes your code. ESP-NOW only sends an array of bytes, so the clean way to send several values at once is to group them in a struct and send the struct&#x27;s bytes exactly as they sit in memory. The receiver defines the same struct and copies the incoming bytes onto it with memcpy, and the struct must have the same order, types, and size on both sides. Add <code>__attribute__((packed))</code> so the compiler inserts no padding bytes between fields; the sketch below also has a <code>static_assert</code> that stops compilation with a clear message if the struct grows past 250 bytes. Never send a String or a pointer: only a memory address goes out, which means nothing on the other board.</p>
<h2 id="how-do-the-send-and-receive-callbacks-work">How do the send and receive callbacks work?</h2>
<p>ESP-NOW reports results through two callback functions, one for sending and one for receiving. Setup order matters: start Wi-Fi in station mode, then call <code>esp_now_init()</code>, then register the callbacks, then add the peer. ESP-NOW cannot work without the Wi-Fi radio, so <code>esp_now_init()</code> must always come after the <code>WiFi.mode()</code> line.</p>
<p>Adding a peer registers the other board by its MAC address. Clear the peer struct with <code>= {}</code> first; leftover values in uncleared fields cause a &quot;Peer interface is invalid&quot; error. Set <code>channel</code> to the channel both boards use, or to 0 to mean &quot;use the board&#x27;s current channel&quot;, and set <code>encrypt</code> to false for plain packets. If <code>esp_now_add_peer()</code> returns <code>ESP_ERR_ESPNOW_FULL</code>, the peer list is full at 20 entries; remove peers you no longer need with <code>esp_now_del_peer()</code>.</p>
<p><code>esp_now_send()</code> puts the packet in a queue and returns immediately; its return value only means the packet was accepted for sending. The real result arrives a few milliseconds later in the send callback: <code>ESP_NOW_SEND_SUCCESS</code> means the receiver&#x27;s Wi-Fi hardware acknowledged the packet. &quot;Delivered&quot; means the packet reached the receiver&#x27;s hardware, not that its program processed it. For commands that must not be lost, add a counter and a software acknowledgement: if the receiver sees the counter jump, it knows how many packets were lost, and if the same number arrives twice, it ignores the duplicate.</p>
<p>The receive callback runs in the Wi-Fi task, not in your <code>loop()</code>, so keep it short: no <code>Serial.print</code>, no <code>delay</code>, no long calculations. Copy the data into your own variable with <code>memcpy</code>, set a volatile flag, and let <code>loop()</code> do the work. On Arduino core 3.x the callback also tells you who sent the packet and the signal strength in dBm; copy those values inside the callback, because they are only valid there. A receiver need not add the sender as a peer for unencrypted unicast or broadcast; it only needs the sender on its list for encrypted packets.</p>
<p>Most ESP-NOW examples on the internet were written for Arduino core 2.x, and that code does not compile on core 3.x because Espressif changed the callback forms: core 3.0 changed the receive callback, and core 3.3 changed the send callback. Compiling old code on 3.x gives an &quot;invalid conversion&quot; error. The sketch below uses <code>ESP_IDF_VERSION</code> checks to pick the right form, so it compiles unchanged on 2.x, 3.0 to 3.2, and 3.3 and later.</p>
<h2 id="unicast-vs-broadcast-which-one-do-i-use">Unicast vs broadcast: which one do I use?</h2>
<p>Unicast sends a packet to one board by its MAC address. Broadcast sends one packet to every ESP-NOW board on the same channel. Use unicast when delivery matters, and broadcast when you need to reach boards whose addresses you do not know.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Feature</th>
<th>Unicast</th>
<th>Broadcast</th>
</tr>
</thead>
<tbody>
<tr>
<td>Address</td>
<td>One board&#x27;s MAC address</td>
<td>FF:FF:FF:FF:FF:FF</td>
</tr>
<tr>
<td>Delivery acknowledgement</td>
<td>Yes, hardware ACK</td>
<td>None; the send result always looks successful</td>
</tr>
<tr>
<td>Encryption</td>
<td>Yes, with PMK and LMK</td>
<td>No, broadcast packets cannot be encrypted</td>
</tr>
<tr>
<td>Peer list</td>
<td>Add the board as a peer first</td>
<td>Add the broadcast address as a peer first</td>
</tr>
<tr>
<td>Best for</td>
<td>Commands and sensor readings</td>
<td>Discovery and announcements</td>
</tr>
</tbody>
</table>
</figure>
<p>A practical pattern is to let the boards find each other with a broadcast on first boot, then learn their MAC addresses and switch to acknowledged unicast. Passing <code>NULL</code> as the address to <code>esp_now_send()</code> sends the packet separately to every peer on the list; if the broadcast address is on the list too, the packet also goes out once as a broadcast.</p>
<h2 id="how-do-i-encrypt-esp-now-packets">How do I encrypt ESP-NOW packets?</h2>
<p>By default ESP-NOW packets are unencrypted: anyone on the same channel can capture them and send fake packets that imitate your struct. Use encryption for anything that controls something physical, such as a door lock, a garage door, or a relay.</p>
<p>ESP-NOW uses CCMP, the same method as WPA2, with two keys. The Primary Master Key (PMK) is 16 bytes and is the same on all devices; set it with <code>esp_now_set_pmk()</code>, or a default PMK is used. The Local Master Key (LMK) is 16 bytes per peer; set it when you add the peer, with <code>encrypt</code> set to true, and the other side must also add you as an encrypted peer with the same LMK. To receive encrypted packets, the receiver must add the sender to its list; that rule does not apply to unencrypted packets.</p>
<p>Two limits apply. Broadcast packets cannot be encrypted, so a network that needs encryption must use unicast. And only 7 of the 20 peers can be encrypted by default in current ESP-IDF; older Arduino cores allowed 10, and the limit is configurable up to 17.</p>
<h2 id="esp-now-vs-wi-fi-vs-bluetooth">ESP-NOW vs Wi-Fi vs Bluetooth</h2>
<p>ESP-NOW sits between Wi-Fi and Bluetooth. Pick it when several ESP32 boards only need to talk to each other.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Method</th>
<th>Extra module</th>
<th>Router</th>
<th>Packet size</th>
<th>Typical range (open space)</th>
<th>Best for</th>
</tr>
</thead>
<tbody>
<tr>
<td>ESP-NOW</td>
<td>Not needed</td>
<td>Not needed</td>
<td>250 bytes</td>
<td>100 to 200 m</td>
<td>Commands and sensor data between boards</td>
</tr>
<tr>
<td>Wi-Fi (HTTP, MQTT)</td>
<td>Not needed</td>
<td>Required</td>
<td>Practically unlimited</td>
<td>The router&#x27;s coverage</td>
<td>Internet, web pages, cloud</td>
</tr>
<tr>
<td>Bluetooth (BLE)</td>
<td>Not needed</td>
<td>Not needed</td>
<td>20 bytes by default</td>
<td>10 to 20 m indoors</td>
<td>Connecting to a phone</td>
</tr>
</tbody>
</table>
</figure>
<p>Talk to a phone: use Bluetooth. Need the internet: use Wi-Fi. Several ESP32 boards that only need to talk to each other: ESP-NOW is usually the simplest way, with no extra module, cable, or router, and only a few lines of code. Its latency is a few milliseconds per packet, against 50 to 500 ms for a Wi-Fi round trip and 10 to 100 ms for BLE. The trade is that ESP-NOW only works between Espressif chips, the packet is at most 250 bytes, and there is no built-in routing or internet connection.</p>
<h2 id="which-boards-support-esp-now">Which boards support ESP-NOW?</h2>
<p>ESP-NOW needs a Wi-Fi radio, so it runs on every ESP32 chip that has one, plus the ESP8266.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Board or chip</th>
<th>ESP-NOW</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>ESP32 (WROOM-32, DevKit V1)</td>
<td>Yes</td>
<td>Also supports Long Range mode</td>
</tr>
<tr>
<td>ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6</td>
<td>Yes</td>
<td>Same code, only the board selection changes</td>
</tr>
<tr>
<td>ESP32-C2 (ESP8684)</td>
<td>Yes</td>
<td>No Long Range mode</td>
</tr>
<tr>
<td>ESP32-H2</td>
<td>No</td>
<td>No Wi-Fi radio, so no ESP-NOW</td>
</tr>
<tr>
<td>ESP8266 (NodeMCU, Wemos D1 Mini)</td>
<td>Yes</td>
<td>Different library (espnow.h), v1 only</td>
</tr>
<tr>
<td>Raspberry Pi Pico W / Pico 2 W</td>
<td>No</td>
<td>Its Wi-Fi chip cannot run ESP-NOW</td>
</tr>
<tr>
<td>Arduino Uno, Nano, Mega</td>
<td>No</td>
<td>Use a small ESP32 over UART as a bridge</td>
</tr>
</tbody>
</table>
</figure>
<p>ESP-NOW also works between different ESP chips: an <a href="https://qualityrcparts.com/esp32-supermini-guide/">ESP32-C3 sensor</a> can send packets to a classic ESP32 gateway or to an ESP8266 board. The only requirements are that both sides are on the same Wi-Fi channel and that the data struct is defined exactly the same on both sides. The examples in this guide use two ESP32 DevKit V1 boards.</p>
<h2 id="can-esp-now-and-wi-fi-run-at-the-same-time">Can ESP-NOW and Wi-Fi run at the same time?</h2>
<p>Yes. The gateway pattern depends on it. One board connects to your router over Wi-Fi, talks ESP-NOW to the sensors, and forwards the readings to a web page, MQTT, or Home Assistant. But the ESP32 has a single 2.4 GHz radio that can only work on one channel at a time. Once the gateway connects to a router, the router decides the channel: if the router is on channel 6, ESP-NOW also runs on channel 6, so every sensor must switch to the router&#x27;s channel too.</p>
<p>The sensors in that pattern are usually battery-powered deep sleep nodes: the <a href="https://qualityrcparts.com/esp32-battery-sensor-node-deep-sleep/">battery sensor node</a> post shows the wake, send, and sleep cycle, and the <a href="https://qualityrcparts.com/power-esp32-arduino-projects-lipo/">LiPo power</a> post covers the battery and regulator side.</p>
<p>Follow four rules for a trouble-free setup. First, the gateway connects to Wi-Fi first, starts ESP-NOW after that, and prints the router&#x27;s channel with <code>WiFi.channel()</code>. Second, the sensors do not connect to the router; they find the channel by scanning for the network name or use a fixed channel in the code, and they do not need the Wi-Fi password. Third, set your router&#x27;s channel from Auto to a fixed channel (1, 6, or 11). In Auto mode, if the router changes channel, the sensors lose the gateway. Fourth, turn off power saving on the gateway with <code>WiFi.setSleep(false)</code>; by default a connected ESP32 puts its radio to sleep at intervals and can miss ESP-NOW packets.</p>
<p>If the channels do not match, the sender prints &quot;failed&quot;, and if you added the peer with a non-zero channel, the Serial Monitor also shows &quot;ESPNOW: Peer channel is not equal to the home channel, send fail!&quot;. Read <code>WiFi.channel()</code> on the gateway and set the sender to match.</p>
<h2 id="what-range-can-i-expect">What range can I expect?</h2>
<p>ESP-NOW range is similar to a Wi-Fi link, because it uses the same radio. With the onboard PCB antenna, expect 100 to 200 m in open space and 20 to 40 m indoors through one to three walls. Reinforced concrete walls and metal objects weaken the signal the most, so place the boards high and keep the antenna clear of metal plates, batteries, and cables.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Metric</th>
<th>Typical value</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>Indoor range</td>
<td>20 to 40 m (1 to 3 walls)</td>
<td>Concrete and metal cut it fastest</td>
</tr>
<tr>
<td>Open-space range</td>
<td>100 to 200 m</td>
<td>PCB antenna, higher is better</td>
</tr>
<tr>
<td>Long Range mode</td>
<td>Up to 1 km</td>
<td>Espressif line-of-sight figure</td>
</tr>
<tr>
<td>Default data rate</td>
<td>1 Mbps</td>
<td>A higher rate means a shorter range</td>
</tr>
<tr>
<td>Airtime, 250-byte packet</td>
<td>About 2.5 ms</td>
<td>Including ACK and waiting</td>
</tr>
<tr>
<td>Theoretical packet rate</td>
<td>About 300 packets per second</td>
<td>Lower in practice</td>
</tr>
<tr>
<td>Command latency</td>
<td>A few milliseconds</td>
<td>No connection setup or server needed</td>
</tr>
</tbody>
</table>
</figure>
<p>To increase range, use modules with an external antenna, such as the ESP32-WROOM-32U, and enable Long Range mode on both sides with <code>esp_wifi_set_protocol(WIFI_IF_STA, WIFI_PROTOCOL_LR)</code>. Long Range only works between two ESP32 boards; an interface set to Long Range cannot connect to normal routers, and the ESP8266 and ESP32-C2 do not support it. When testing range on core 3.x, print the received signal strength: minus 50 dBm is very strong, minus 80 dBm is close to the limit, and packet loss starts around minus 90 dBm.</p>
<h2 id="the-two-way-sketch-a-button-on-one-board-an-led-on-the-other">The two-way sketch: a button on one board, an LED on the other</h2>
<p>This sketch runs on both boards; the only line that differs is the peer MAC address, since each board holds the other board&#x27;s address. Press the button on one board and the LED on the other board toggles, and the other board sends an acknowledgement back, so you see both the hardware ACK and the proof that the LED really changed.</p>
<p>Wire each board the same way: the button goes between GPIO 4 and GND and uses the internal pull-up, so no resistor is needed. The LED is the onboard blue LED on GPIO 2 on most DevKit V1 boards; use a 220 ohm resistor and an external LED if yours has none there.</p>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Part</th>
<th>ESP32 pin</th>
<th>Note</th>
</tr>
</thead>
<tbody>
<tr>
<td>Push button</td>
<td>GPIO 4 and GND</td>
<td>Internal pull-up, no extra resistor</td>
</tr>
<tr>
<td>LED</td>
<td>GPIO 2</td>
<td>Onboard blue LED on most DevKit V1 boards</td>
</tr>
<tr>
<td>Power</td>
<td>USB</td>
<td>Both boards can use separate USB ports or adapters</td>
</tr>
</tbody>
</table>
</figure>
<p>Upload the sketch to the first board and open the Serial Monitor at 115200 baud. It prints that board&#x27;s STA MAC address, both as text and as an array line you can paste straight into the other board&#x27;s code. Do the same on the second board, paste each address into the other board&#x27;s <code>peerMac</code> array, and upload again. Use the STA address, not the AP address: the AP address is usually the STA address with the last byte increased by one, and using the wrong one is the most common reason for a &quot;failed&quot; message. On core 3.x, <code>WiFi.macAddress()</code> can return all zeros if called too early, so this sketch reads the address with <code>esp_wifi_get_mac()</code> instead.</p>
<pre class="wp-block-preformatted"><code>// ESP-NOW two-way sketch: two ESP32 boards, no router.
// Upload this SAME sketch to both boards. The only line that differs
// between the two boards is peerMac below: each board holds the OTHER
// board&#x27;s STA MAC address (printed at startup).
// Board: ESP32 DevKit V1 (30-pin WROOM-32), Arduino-ESP32 core.
// Libraries: built-in only (WiFi.h, esp_now.h, esp_wifi.h). Nothing to
// install from the Library Manager.
// Wiring on EACH board: push button between GPIO 4 and GND (internal
// pull-up, no resistor). LED is the onboard blue LED on GPIO 2.
// Press the button on one board: the LED on the other board toggles,
// and the other board sends an acknowledgement back.
#include &lt;Arduino.h&gt;
#include &lt;WiFi.h&gt;
#include &lt;esp_now.h&gt;
#include &lt;esp_wifi.h&gt;
#include &lt;esp_idf_version.h&gt;

#define BUTTON_PIN 4  // push button between GPIO 4 and GND
#define LED_PIN 2     // onboard blue LED on most DevKit V1 boards

// Paste the OTHER board&#x27;s STA MAC address here. Run the sketch once
// with any value and read &quot;My STA MAC&quot; from the Serial Monitor.
uint8_t peerMac[6] = {0x24, 0x6F, 0x28, 0x00, 0x00, 0x00};

typedef struct __attribute__((packed)) {
  uint8_t type;      // 1 = command (set the LED), 2 = acknowledgement
  bool ledOn;        // the LED state the sender wants on the other board
  uint32_t counter;  // packet number, so the receiver spots lost or duplicate packets
} EspNowMessage;
static_assert(sizeof(EspNowMessage) &lt;= 250, &quot;ESP-NOW v1 packet limit is 250 bytes&quot;);

EspNowMessage outMsg;
volatile bool haveIncoming = false;
volatile bool lastSendOk = false;
volatile bool haveSendResult = false;
volatile int8_t lastRssi = 0;
EspNowMessage inMsg;

// Receive callback. It runs in the Wi-Fi task, so it only copies the
// packet and sets a flag; loop() does the real work.
#if ESP_IDF_VERSION &gt;= ESP_IDF_VERSION_VAL(5, 0, 0)
void onDataRecv(const esp_now_recv_info_t *info, const uint8_t *data, int len) {
  if (len != (int)sizeof(EspNowMessage)) return;
  memcpy((void *)&amp;inMsg, data, len);
  lastRssi = info-&gt;rx_ctrl-&gt;rssi;
  haveIncoming = true;
}
#else
void onDataRecv(const uint8_t *mac, const uint8_t *data, int len) {
  if (len != (int)sizeof(EspNowMessage)) return;
  memcpy((void *)&amp;inMsg, data, len);
  haveIncoming = true;
}
#endif

// Send callback. Fires a few milliseconds after esp_now_send() with the
// hardware acknowledgement result. &quot;Delivered&quot; means the other board&#x27;s
// Wi-Fi hardware answered, not that its program processed the packet.
#if ESP_IDF_VERSION &gt;= ESP_IDF_VERSION_VAL(5, 5, 0)
void onDataSent(const esp_now_send_info_t *info, esp_now_send_status_t status) {
  lastSendOk = (status == ESP_NOW_SEND_SUCCESS);
  haveSendResult = true;
}
#else
void onDataSent(const uint8_t *mac, esp_now_send_status_t status) {
  lastSendOk = (status == ESP_NOW_SEND_SUCCESS);
  haveSendResult = true;
}
#endif

void setup() {
  Serial.begin(115200);
  pinMode(BUTTON_PIN, INPUT_PULLUP);
  pinMode(LED_PIN, OUTPUT);
  digitalWrite(LED_PIN, LOW);

  // ESP-NOW needs the Wi-Fi radio, so start Wi-Fi in station mode.
  // No router is joined and no password is needed.
  WiFi.mode(WIFI_STA);

  // Print this board&#x27;s STA MAC address. Use the STA address, not the
  // AP address (the AP address is usually the STA address plus one).
  uint8_t mac[6];
  esp_wifi_get_mac(WIFI_IF_STA, mac);
  Serial.printf(&quot;My STA MAC: %02X:%02X:%02X:%02X:%02X:%02X\n&quot;,
                mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
  Serial.printf(&quot;Paste as: {0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X, 0x%02X}\n&quot;,
                mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);

  if (esp_now_init() != ESP_OK) {
    Serial.println(&quot;esp_now_init failed&quot;);
    while (true) { delay(1000); }
  }
  esp_now_register_recv_cb(onDataRecv);
  esp_now_register_send_cb(onDataSent);

  esp_now_peer_info_t peer = {};
  memcpy(peer.peer_addr, peerMac, 6);
  peer.channel = 1;      // both boards must use the same channel
  peer.encrypt = false;  // unencrypted; see the guide for PMK/LMK encryption
  if (esp_now_add_peer(&amp;peer) != ESP_OK) {
    Serial.println(&quot;esp_now_add_peer failed: check the peer MAC address&quot;);
  }

  outMsg.type = 1;
  outMsg.ledOn = false;
  outMsg.counter = 0;
  Serial.println(&quot;Ready. Press the button to toggle the other board&#x27;s LED.&quot;);
}

void loop() {
  static int buttonState = HIGH;  // stable, debounced button state
  static int lastButton = HIGH;   // raw reading from the previous loop
  static unsigned long lastDebounce = 0;
  static bool ledState = false;   // the LED state we last asked the other board for

  int reading = digitalRead(BUTTON_PIN);
  if (reading != lastButton) lastDebounce = millis();
  lastButton = reading;
  if ((millis() - lastDebounce) &gt; 30 &amp;&amp; reading != buttonState) {
    buttonState = reading;
    if (buttonState == LOW) {
      // Button pressed: toggle the LED we want on the other board.
      ledState = !ledState;
      outMsg.type = 1;
      outMsg.ledOn = ledState;
      outMsg.counter++;
      haveSendResult = false;
      if (esp_now_send(peerMac, (uint8_t *)&amp;outMsg, sizeof(outMsg)) != ESP_OK) {
        Serial.println(&quot;esp_now_send rejected the packet&quot;);
      }
    }
  }

  if (haveSendResult) {
    haveSendResult = false;
    Serial.println(lastSendOk ? &quot;Delivered (hardware ACK)&quot; : &quot;Failed (no ACK)&quot;);
  }

  if (haveIncoming) {
    haveIncoming = false;
    if (inMsg.type == 1) {
      // Command: set our LED to the state the other board asked for,
      // then send an acknowledgement back.
      digitalWrite(LED_PIN, inMsg.ledOn ? HIGH : LOW);
      Serial.printf(&quot;Command #%u: LED %s (RSSI %d dBm)\n&quot;,
                    inMsg.counter, inMsg.ledOn ? &quot;ON&quot; : &quot;OFF&quot;, lastRssi);
      EspNowMessage ack;
      ack.type = 2;
      ack.ledOn = inMsg.ledOn;
      ack.counter = inMsg.counter;
      esp_now_send(peerMac, (uint8_t *)&amp;ack, sizeof(ack));
    } else if (inMsg.type == 2) {
      Serial.printf(&quot;Ack #%u: the other board set its LED %s\n&quot;,
                    inMsg.counter, inMsg.ledOn ? &quot;ON&quot; : &quot;OFF&quot;);
    }
  }
}</code></pre>
<p>The sketch compiles as written. With both boards running, press the button on one board and watch the Serial Monitor on both: the sender prints &quot;Delivered (hardware ACK)&quot;, the receiver prints the command number, the LED state, and the signal strength, then the sender prints the acknowledgement. If the button press does nothing, check the troubleshooting table below before changing the code.</p>
<h2 id="what-goes-wrong">What goes wrong?</h2>
<figure class="wp-block-table">
<table>
<thead>
<tr>
<th>Symptom</th>
<th>Cause</th>
<th>Fix</th>
</tr>
</thead>
<tbody>
<tr>
<td>Send callback says &quot;Failed (no ACK)&quot;</td>
<td>The boards are on different channels</td>
<td>Set the same channel on both boards; if one board also joins Wi-Fi, match the router&#x27;s channel</td>
</tr>
<tr>
<td>&quot;Peer channel is not equal to the home channel&quot;</td>
<td>Peer added with a non-zero channel that differs from the board&#x27;s channel</td>
<td>Set the peer channel to 0 (current channel) or to the channel the board actually uses</td>
</tr>
<tr>
<td>Packets send fine and never arrive</td>
<td>Wrong MAC address: AP address used instead of STA</td>
<td>Use the STA address the sketch prints; the AP address is usually STA plus one</td>
</tr>
<tr>
<td>Receiver reads garbage</td>
<td>Struct differs between the two boards</td>
<td>Same order, types, and size on both sides; add <code>__attribute__((packed))</code></td>
</tr>
<tr>
<td>Old example will not compile on core 3.x</td>
<td>Callback signatures changed in core 3.0 and 3.3</td>
<td>Use the <code>ESP_IDF_VERSION</code> guards from the sketch above</td>
</tr>
<tr>
<td>It works between two boards and breaks when one joins Wi-Fi</td>
<td>The Wi-Fi board followed the router to another channel</td>
<td>Read <code>WiFi.channel()</code> on the gateway and match it; fix the router channel to 1, 6, or 11</td>
</tr>
<tr>
<td>Gateway misses packets</td>
<td>Power saving puts the radio to sleep</td>
<td>Call <code>WiFi.setSleep(false)</code> on the gateway</td>
</tr>
<tr>
<td>Range is much worse than Wi-Fi</td>
<td>Antenna blocked or board in a metal case</td>
<td>Keep the antenna clear, raise the boards, or try an external antenna or Long Range mode</td>
</tr>
</tbody>
</table>
</figure>
<h2 id="frequently-asked-questions">Frequently asked questions</h2>
<h3>Does ESP-NOW need a router?</h3>
<p>No. ESP-NOW sends packets directly from one ESP32 board to another by MAC address, with no router, no Wi-Fi password, and no internet connection.</p>
<h3>What is the biggest ESP-NOW packet?</h3>
<p>250 bytes with ESP-NOW v1, which is what the Arduino core uses by default. ESP-NOW v2 on ESP-IDF 5.4 and later allows 1470 bytes, but a v1 board truncates or drops packets over 250 bytes, so stay at 250 in a mixed network.</p>
<h3>How many ESP32 boards can talk ESP-NOW at once?</h3>
<p>One board can register up to 20 peers it sends to. A gateway that only receives unencrypted packets can listen to more than 20 sensors, because receiving does not need the sender on the list.</p>
<h3>Can ESP-NOW reach the internet?</h3>
<p>No. ESP-NOW has no TCP/IP and no routing. Use one board as a gateway: it talks ESP-NOW to the sensors and Wi-Fi to your router.</p>
<h3>Does ESP-NOW work on the ESP32-S3 and ESP32-C3?</h3>
<p>Yes, on the ESP32, S2, S3, C2, C3, and C6, and on the ESP8266 with a different library. It does not work on the ESP32-H2, which has no Wi-Fi radio.</p>
<h3>Why does my ESP-NOW code not compile on Arduino core 3.x?</h3>
<p>Espressif changed the callback signatures: the receive callback changed in core 3.0 and the send callback in core 3.3. The sketch in this guide uses <code>ESP_IDF_VERSION</code> checks to pick the right form, so it compiles on 2.x, 3.0 to 3.2, and 3.3 and later.</p>
<h2 id="parts-used-in-this-guide">Parts used in this guide</h2>
<ul>
<li><a href="https://qualityrcparts.com/product/esp32-devkit-v1-development-board-30-pin-wroom-32-wifi-bluetooth-dual-core/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/esp32-devkit-v1-development-board-30-pin-wroom-32-wifi-bluetooth-dual-core-1.jpg?fit=1200%2C823&amp;ssl=1" alt="ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, WiFi + Bluetooth, Dual-Core" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/esp32-devkit-v1-development-board-30-pin-wroom-32-wifi-bluetooth-dual-core/">ESP32 DevKit V1 Development Board, 30-Pin WROOM-32, WiFi + Bluetooth, Dual-Core</a> &#8211; buy two for the two-way sketch, one per board</li>
<li><a href="https://qualityrcparts.com/product/esp32-s3-devkitc-1-development-board/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/clean_img2.jpg?fit=1080%2C1080&amp;ssl=1" alt="ESP32-S3 Development Board DevKitC-1 N8R2 N16R8 WiFi BT Module 44Pin Type-C USB" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/esp32-s3-devkitc-1-development-board/">ESP32-S3 Development Board DevKitC-1 N8R2 N16R8 WiFi BT Module 44Pin Type-C USB</a> &#8211; same sketch, only the board selection changes</li>
<li><a href="https://qualityrcparts.com/product/esp32-c3-supermini-development-board-4-pack-risc-v-160mhz-wifi-bluetooth-le/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/esp32-c3-supermini-development-board-4-pack-risc-v-160mhz-wifi-bluetooth-le-1.jpg?fit=1200%2C1173&amp;ssl=1" alt="ESP32-C3 SuperMini Development Board 4-Pack, RISC-V 160MHz, WiFi + Bluetooth LE" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/esp32-c3-supermini-development-board-4-pack-risc-v-160mhz-wifi-bluetooth-le/">ESP32-C3 SuperMini Development Board 4-Pack, RISC-V 160MHz, WiFi + Bluetooth LE</a> &#8211; four boards for a multi-node network with one gateway</li>
<li><a href="https://qualityrcparts.com/product/seeed-studio-xiao-esp32c6-development-board-1-pack/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/item8-xiao-1pc-crop.jpg?fit=1200%2C1200&amp;ssl=1" alt="Seeed Studio XIAO ESP32C6 Development Board, 1-Pack" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/seeed-studio-xiao-esp32c6-development-board-1-pack/">Seeed Studio XIAO ESP32C6 Development Board, 1-Pack</a> &#8211; a tiny ESP-NOW sensor node</li>
<li><a href="https://qualityrcparts.com/product/esp32-s2-mini-development-board-wifi-4mb-flash-2mb-psram-usb-c-single/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/esp32-s2-mini-development-board-wifi-4mb-flash-2mb-psram-usb-c-1.jpg?fit=1140%2C1200&amp;ssl=1" alt="ESP32-S2 Mini Development Board, WiFi, 4MB Flash, 2MB PSRAM, USB-C" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/esp32-s2-mini-development-board-wifi-4mb-flash-2mb-psram-usb-c-single/">ESP32-S2 Mini Development Board, WiFi, 4MB Flash, 2MB PSRAM, USB-C</a> &#8211; a small low-cost ESP-NOW node</li>
<li><a href="https://qualityrcparts.com/product/breadboard-jumper-wires-male-male-120-piece-10cm/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/breadboard-jumper-wires-male-male-120-piece-10cm-1.jpg?fit=1200%2C1108&amp;ssl=1" alt="Breadboard Jumper Wires 120-Piece, Male to Male, 10cm Multicolored Dupont Wire" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/breadboard-jumper-wires-male-male-120-piece-10cm/">Breadboard Jumper Wires 120-Piece, Male to Male, 10cm Multicolored Dupont Wire</a> &#8211; for the button wiring</li>
<li><a href="https://qualityrcparts.com/product/solderless-breadboard-kit-830-point-400-point-jumper-wires/"><img decoding="async" src="https://i0.wp.com/qualityrcparts.com/wp-content/uploads/2026/11/solderless-breadboard-kit-830-point-400-point-jumper-wires-2.jpg?fit=500%2C500&amp;ssl=1" alt="Solderless Breadboard Kit, 2 x 830-Point + 2 x 400-Point Boards + 126 Jumper Wir" width="150" height="150" loading="lazy"></a> <a href="https://qualityrcparts.com/product/solderless-breadboard-kit-830-point-400-point-jumper-wires/">Solderless Breadboard Kit, 2 x 830-Point + 2 x 400-Point Boards + 126 Jumper Wir</a> &#8211; a bench base for both boards</li>
</ul>
<h2 id="in-this-series">In this series</h2>
<ul>
<li><a href="https://qualityrcparts.com/which-esp32-should-i-buy/">Which ESP32 Should I Buy? Pick the Right Board for Your Project</a></li>
<li><a href="https://qualityrcparts.com/esp32-devkit-v1-pinout/">ESP32 DevKit V1 Pinout: Every Pin on the 30-Pin Board, Explained</a></li>
<li><a href="https://qualityrcparts.com/esp32-s3-devkitc-1-pinout/">ESP32-S3 DevKitC-1 Pinout: Every Pin on the 44-Pin Board, Explained</a></li>
<li><a href="https://qualityrcparts.com/esp32-cam-pinout/">ESP32-CAM Pinout: Camera, SD Card, and Free GPIO Pins</a></li>
<li><a href="https://qualityrcparts.com/esp32-cam-troubleshooting-brownout-camera-init-failed/">ESP32-CAM Camera Init Failed and Brownout Fixes</a></li>
<li><a href="https://qualityrcparts.com/esp32-cam-rtsp-streaming/">ESP32-CAM RTSP Streaming: Setup Guide for VLC and NVR</a></li>
<li><a href="https://qualityrcparts.com/esp32-cam-battery/">ESP32-CAM Battery: Power Draw, Runtime, and Deep Sleep</a></li>
<li>ESP-NOW Explained: Two ESP32 Boards, No Router (this post)</li>
</ul>
<h2 id="sources">Sources</h2>
<ul>
<li><a href="https://docs.espressif.com/projects/esp-idf/en/release-v5.4/esp32/api-reference/network/esp_now.html" target="_blank" rel="noopener">Espressif ESP-NOW API Reference (ESP-IDF v5.4)</a></li>
<li><a href="https://bluegrays.com/en/blog/esp-now-esp32-tutorial" target="_blank" rel="noopener">BlueGrays: ESP-NOW Tutorial, ESP32 Wireless Communication Without a Router</a></li>
<li><a href="https://docs.micropython.org/en/latest/library/espnow.html" target="_blank" rel="noopener">MicroPython espnow module documentation</a></li>
<li><a href="https://www.componentindex.net/components/esp-now/" target="_blank" rel="noopener">ComponentIndex: ESP-NOW Guide, Code and Setup for ESP32 Peer-to-Peer Communication</a></li>
<li><a href="https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/" target="_blank" rel="noopener">Random Nerd Tutorials: ESP-NOW with ESP32, Send Data to Multiple Boards</a></li>
</ul>
]]></content:encoded>
					
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">23633</post-id>	</item>
	</channel>
</rss>
