{"id":95718,"date":"2020-04-16T14:46:39","date_gmt":"2020-04-16T14:46:39","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=95718"},"modified":"2024-06-11T16:49:06","modified_gmt":"2024-06-11T16:49:06","slug":"esp-now-one-to-many-esp32-esp8266","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp32-esp8266\/","title":{"rendered":"ESP-NOW with ESP32: Send Data to Multiple Boards (one-to-many)"},"content":{"rendered":"\n<p>In this tutorial, you&#8217;ll learn how to use ESP-NOW communication protocol to send data from one ESP32 to multiple ESP32 or ESP8266 boards (one-to-many configuration). The boards will be programmed using Arduino IDE.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" width=\"1200\" height=\"675\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW with ESP32: Send Data to Multiple Boards one-to-many ESP8266 NodeMCU\" class=\"wp-image-96083\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?resize=1024%2C576&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>To get started with ESP-NOW on the ESP32 or ESP8266, read the following ESP-NOW guides first:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/\">Getting Started with ESP-NOW (ESP32 with Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\">Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-many-to-one-esp32\/\">ESP-NOW with ESP32: Receive Data from Multiple Boards (many-to-one)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Project Overview<\/h2>\n\n\n\n<p>This tutorial shows how to send data from one ESP32 to multiple ESP32 or ESP8266 boards using ESP-NOW (one-to-many configuration).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"722\" height=\"671\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-one-to-many-configuration-project-overview.png?resize=722%2C671&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW with ESP32: Send Data to Multiple Boards (one-to-many) Project Overview\" class=\"wp-image-95746\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-one-to-many-configuration-project-overview.png?w=722&amp;quality=100&amp;strip=all&amp;ssl=1 722w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-one-to-many-configuration-project-overview.png?resize=300%2C279&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li>One ESP32 acts as a sender; <\/li>\n\n\n\n<li>Multiple ESP32 or ESP8266 boards act as receivers. We tested this setup with two ESP32 boards and one ESP8266 board simultaneously. You should be able to add more boards to your setup; <\/li>\n\n\n\n<li>The ESP32 sender receives an acknowledge message if the messages are successfully delivered. You know which boards received the message and which boards didn&#8217;t; <\/li>\n\n\n\n<li>You need to upload a slightly different receiver code depending if you&#8217;re using an ESP32 or ESP8266;<\/li>\n\n\n\n<li>As an example, we&#8217;ll exchange random values between the boards. You should modify this example to send commands or sensor readings (<a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">exchange sensor readings using ESP-NOW<\/a>).<\/li>\n<\/ul>\n\n\n\n<p>This tutorial covers these two scenarios: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>sending the same message to all boards;<\/li>\n\n\n\n<li>sending a different message to each board.<\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclgray\">You may also like reading: <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">ESP-NOW Two-Way Communication Between ESP32 Boards<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>We\u2019ll program the ESP32\/ESP8266 boards using Arduino IDE, so before proceeding with this tutorial, make sure you have these boards installed in your Arduino IDE.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\" title=\"\">Installing ESP32 Board in Arduino IDE (Windows, Mac OS X, and Linux)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp8266-nodemcu-arduino-ide-2-0\/\" title=\"\">Installing ESP8266 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Parts Required<\/h2>\n\n\n\n<p>To follow this tutorial, you need multiple ESP32 boards and\/or ESP8266 boards.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a aria-label=\"ESP32 (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32<\/a> (read <a aria-label=\" (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/esp32-development-boards-review-comparison\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP32 development boards<\/a>)<\/li>\n\n\n\n<li><a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266<\/a>\u00a0(read\u00a0<a href=\"https:\/\/makeradvisor.com\/best-esp8266-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\">Best ESP8266 development boards<\/a>) <\/li>\n<\/ul>\n\n\n<p>You can use the preceding links or go directly to <a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\">MakerAdvisor.com\/tools<\/a> to find all the parts for your projects at the best price!<\/p><p style=\"text-align:center;\"><a href=\"https:\/\/makeradvisor.com\/tools\/?utm_source=rnt&utm_medium=post&utm_campaign=post\" target=\"_blank\"><img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/10\/header-200.png?w=1200&#038;quality=100&#038;strip=all&#038;ssl=1\"><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Getting the Boards MAC Address<\/h2>\n\n\n\n<p>To send messages via ESP-NOW, you need to know the receiver boards&#8217;&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/get-change-esp32-esp8266-mac-address-arduino\/\">MAC address<\/a>. Each board has a unique MAC address (learn how to&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/get-change-esp32-esp8266-mac-address-arduino\/\">Get and Change the ESP32 MAC Address<\/a>).<\/p>\n\n\n\n<p>Upload the following code to each of your receiver boards to get its MAC address.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/get-change-esp32-esp8266-mac-address-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.  \n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n*\/\n#ifdef ESP32\n  #include &lt;WiFi.h&gt;\n  #include &lt;esp_wifi.h&gt;\n#else\n  #include &lt;ESP8266WiFi.h&gt;\n#endif\n\nvoid setup(){\n  Serial.begin(115200);\n\n  Serial.print(&quot;ESP Board MAC Address: &quot;);\n  #ifdef ESP32\n    WiFi.mode(WIFI_STA);\n    WiFi.STA.begin();\n    uint8_t baseMac[6];\n    esp_err_t ret = esp_wifi_get_mac(WIFI_IF_STA, baseMac);\n    if (ret == ESP_OK) {\n      Serial.printf(&quot;%02x:%02x:%02x:%02x:%02x:%02x\\n&quot;,\n                    baseMac[0], baseMac[1], baseMac[2],\n                    baseMac[3], baseMac[4], baseMac[5]);\n    } else {\n      Serial.println(&quot;Failed to read MAC address&quot;);\n    }\n  #else\n    Serial.println(WiFi.macAddress());\n  #endif\n}\n \nvoid loop(){\n\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP\/ESP_Get_MAC_Address.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>After uploading the code, press the RST\/EN button, and the MAC address should be displayed on the Serial Monitor.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"652\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP32_MAC_Address_Serial_monitor.jpg?resize=652%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 board MAC Address with Arduino IDE Serial Monitor\" class=\"wp-image-93078\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP32_MAC_Address_Serial_monitor.jpg?w=652&amp;quality=100&amp;strip=all&amp;ssl=1 652w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP32_MAC_Address_Serial_monitor.jpg?resize=300%2C194&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/figure><\/div>\n\n\n<p>You can write down the boards&#8217; MAC address on a label to clearly identify each board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/Getting-the-ESP32-Board-MAC-Address-Arduino-IDE.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Identify ESP32 Board MAC Address\" class=\"wp-image-93402\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/Getting-the-ESP32-Board-MAC-Address-Arduino-IDE.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/Getting-the-ESP32-Board-MAC-Address-Arduino-IDE.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">ESP32 Sender Code (ESP-NOW) <\/h2>\n\n\n\n<p>The following code sends data to multiple (three) ESP boards via ESP-NOW. You should modify the code with your receiver boards&#8217; MAC address. You should also add or delete lines of code depending on the number of receiver boards.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\r\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-one-to-many-esp32-esp8266\/\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\r\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n*********\/\r\n#include &lt;esp_now.h&gt;\r\n#include &lt;WiFi.h&gt;\r\n\r\n\/\/ REPLACE WITH YOUR ESP RECEIVER'S MAC ADDRESS\r\nuint8_t broadcastAddress1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r\nuint8_t broadcastAddress2[] = {0xFF, , , , , };\r\nuint8_t broadcastAddress3[] = {0xFF, , , , , };\r\n\r\ntypedef struct test_struct {\r\n  int x;\r\n  int y;\r\n} test_struct;\r\n\r\ntest_struct test;\r\n\r\nesp_now_peer_info_t peerInfo;\r\n\r\n\/\/ callback when data is sent\r\nvoid OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {\r\n  char macStr[18];\r\n  Serial.print(&quot;Packet to: &quot;);\r\n  \/\/ Copies the sender mac address to a string\r\n  snprintf(macStr, sizeof(macStr), &quot;%02x:%02x:%02x:%02x:%02x:%02x&quot;,\r\n           mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);\r\n  Serial.print(macStr);\r\n  Serial.print(&quot; send status:\\t&quot;);\r\n  Serial.println(status == ESP_NOW_SEND_SUCCESS ? &quot;Delivery Success&quot; : &quot;Delivery Fail&quot;);\r\n}\r\n \r\nvoid setup() {\r\n  Serial.begin(115200);\r\n \r\n  WiFi.mode(WIFI_STA);\r\n \r\n  if (esp_now_init() != ESP_OK) {\r\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\r\n    return;\r\n  }\r\n  \r\n  esp_now_register_send_cb(OnDataSent);\r\n   \r\n  \/\/ register peer\r\n  peerInfo.channel = 0;  \r\n  peerInfo.encrypt = false;\r\n  \/\/ register first peer  \r\n  memcpy(peerInfo.peer_addr, broadcastAddress1, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n  \/\/ register second peer  \r\n  memcpy(peerInfo.peer_addr, broadcastAddress2, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n  \/\/\/ register third peer\r\n  memcpy(peerInfo.peer_addr, broadcastAddress3, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n}\r\n \r\nvoid loop() {\r\n  test.x = random(0,20);\r\n  test.y = random(0,20);\r\n \r\n  esp_err_t result = esp_now_send(0, (uint8_t *) &amp;test, sizeof(test_struct));\r\n   \r\n  if (result == ESP_OK) {\r\n    Serial.println(&quot;Sent with success&quot;);\r\n  }\r\n  else {\r\n    Serial.println(&quot;Error sending the data&quot;);\r\n  }\r\n  delay(2000);\r\n}\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP\/ESP_NOW\/ESP_NOW_Sender_Multiple_Boards_Same_Messages.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the code works<\/h3>\n\n\n\n<p>First, include the <span class=\"rnthl rntliteral\">esp_now.h<\/span> and <span class=\"rnthl rntliteral\">WiFi.h<\/span> libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;esp_now.h&gt;\n#include &lt;WiFi.h&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Receivers&#8217; MAC Address<\/h4>\n\n\n\n<p>Insert the receivers&#8217; MAC address. In our example, we&#8217;re sending data to three boards.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>uint8_t broadcastAddress1&#091;] = {0x3C, 0x71, 0xBF, 0xC3, 0xBF, 0xB0};\nuint8_t broadcastAddress2&#091;] = {0x24, 0x0A, 0xC4, 0xAE, 0xAE, 0x44};\nuint8_t broadcastAddress3&#091;] = {0x80, 0x7D, 0x3A, 0x58, 0xB4, 0xB0};<\/code><\/pre>\n\n\n\n<p>Then, create a structure that contains the data we want to send. We called this structure <span class=\"rnthl rntliteral\">test_struct<\/span> and it contains two integer variables. You can change this to send whatever variable types you want.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>typedef struct test_struct {\n  int x;\n  int y;\n} test_struct;<\/code><\/pre>\n\n\n\n<p>Create a new variable of type <span class=\"rnthl rntliteral\">test_struct<\/span> that is called <span class=\"rnthl rntliteral\">test<\/span> that will store the variables&#8217; values.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>test_struct test;<\/code><\/pre>\n\n\n\n<p>Create a variable of type <span class=\"rnthl rntliteral\">esp_now_peer_info_t<\/span> to store information about the peer.<\/p>\n\n\n\n<pre id=\"language-c\" class=\"wp-block-code\"><code>esp_now_peer_info_t peerInfo;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">OnDataSent() callback function <\/h4>\n\n\n\n<p>Next, define the <span class=\"rnthl rntliteral\">OnDataSent()<\/span> function. This is a callback function that will be executed when a message is sent. In this case, this function prints if the message was successfully delivered or not and for which MAC address. So, you know which boards received the message or and which boards didn&#8217;t.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {\n  char macStr&#091;18];\n  Serial.print(\"Packet from: \");\n  \/\/ Copies the sender mac address to a string\n  snprintf(macStr, sizeof(macStr), \"%02x:%02x:%02x:%02x:%02x:%02x\",\n           mac_addr&#091;0], mac_addr&#091;1], mac_addr&#091;2], mac_addr&#091;3], mac_addr&#091;4], mac_addr&#091;5]);\n  Serial.print(macStr);\n  Serial.print(\" send status:\\t\");\n  Serial.println(status == ESP_NOW_SEND_SUCCESS ? \"Delivery Success\" : \"Delivery Fail\");\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">setup()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize the serial monitor for debugging purposes:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Set the device as a Wi-Fi station:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);<\/code><\/pre>\n\n\n\n<p>Initialize ESP-NOW:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (esp_now_init() != ESP_OK) {\n  Serial.println(\"Error initializing ESP-NOW\");\n  return;\n}<\/code><\/pre>\n\n\n\n<p>After successfully initializing ESP-NOW, register the callback function that will be called when a message is sent. In this case, register for the <span class=\"rnthl rntliteral\">OnDataSent()<\/span> function created previously.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_now_register_send_cb(OnDataSent);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Add peers<\/h4>\n\n\n\n<p>After that, we need to pair with other ESP-NOW devices to send data. That&#8217;s what we do in the next lines &#8211; register peers:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ register peer\npeerInfo.channel = 0;\npeerInfo.encrypt = false;\n\/\/ register first peer\nmemcpy(peerInfo.peer_addr, broadcastAddress1, 6);\nif (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\n  Serial.println(\"Failed to add peer\");\n  return;\n}\n\/\/ register second peer\nmemcpy(peerInfo.peer_addr, broadcastAddress2, 6);\nif (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\n  Serial.println(\"Failed to add peer\");\n  return;\n}\n\/\/\/ register third peer\nmemcpy(peerInfo.peer_addr, broadcastAddress3, 6);\nif (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\n  Serial.println(\"Failed to add peer\");\n  return;\n}<\/code><\/pre>\n\n\n\n<p>If you want to add more peers you just need to duplicate these lines and pass the peer MAC address:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>memcpy(peerInfo.peer_addr, broadcastAddress, 6);\nif (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\n  Serial.println(\"Failed to add peer\");\n  return;\n}<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">loop()<\/h4>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, we&#8217;ll send a message via ESP-NOW every 2 seconds (you can change this delay time).<\/p>\n\n\n\n<p>Assign a value to each variable:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>test.x = random(0,20);\ntest.y = random(0,20);<\/code><\/pre>\n\n\n\n<p>Remember that <span class=\"rnthl rntliteral\">test<\/span> is a structure. Here assign the values that you want to send inside the structure. In this case, we&#8217;re just sending random values. In a practical application these should be replaced with commands or sensor readings, for example.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Send the same data to multiple boards<\/h4>\n\n\n\n<p>Finally, send the message as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_err_t result = esp_now_send(0, (uint8_t *) &amp;test, sizeof(test_struct));<\/code><\/pre>\n\n\n\n<p>The first argument of the <span class=\"rnthl rntliteral\">esp_now_send()<\/span> function is the receiver&#8217;s MAC address. If you pass <span class=\"rnthl rntliteral\">0<\/span> as an argument, it will send the same message to <strong>all registered peers<\/strong>. If you want to send a different message to each peer, follow the next section.<\/p>\n\n\n\n<p>Check if the message was successfully sent:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (result == ESP_OK) {\n  Serial.println(\"Sent with success\");\n}\nelse {\n  Serial.println(\"Error sending the data\");\n}<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">loop()<\/span> is executed every 2000 milliseconds (2 seconds).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>delay(2000);<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Send different data to each board<\/h4>\n\n\n\n<p>The code to send a different message to each board is very similar tothe previous one. So, we&#8217;ll just take a look at the differences.<\/p>\n\n\n\n<p>If you want to send a different message to each board, you need to create a data structure for each of your boards, for example:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>test_struct test;\ntest_struct test2;\ntest_struct test3;<\/code><\/pre>\n\n\n\n<p>In this case, we&#8217;re sending the same structure type (<span class=\"rnthl rntliteral\">test_struct<\/span>). You can send a different structure type as long as the receiver code is prepared to receive that type of structure.<\/p>\n\n\n\n<p>Then, assign different values to the variables of each structure. In this example, we&#8217;re just setting them to random numbers.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>test.x = random(0,20);\ntest.y = random(0,20);\ntest2.x = random(0,20);\ntest2.y = random(0,20);\ntest3.x = random(0,20);\ntest3.y = random(0,20);<\/code><\/pre>\n\n\n\n<p>Finally, you need to call the <span class=\"rnthl rntliteral\">esp_now_send()<\/span> function for each receiver.<\/p>\n\n\n\n<p>For example, send the <span class=\"rnthl rntliteral\">test<\/span> structure to the board whose MAC address is <span class=\"rnthl rntliteral\">broadcastAddress1<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_err_t result1 = esp_now_send(\n  broadcastAddress1, \n  (uint8_t *) &amp;test,\n  sizeof(test_struct));\n   \nif (result1 == ESP_OK) {\n  Serial.println(\"Sent with success\");\n}\nelse {\n  Serial.println(\"Error sending the data\");\n}<\/code><\/pre>\n\n\n\n<p>Do the same for the other boards. For the second board send the <span class=\"rnthl rntliteral\">test2<\/span> structure:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_err_t result2 = esp_now_send(\n  broadcastAddress2, \n  (uint8_t *) &amp;test2,\n  sizeof(test_struct));\n\nif (result2 == ESP_OK) {\n  Serial.println(\"Sent with success\");\n}\nelse {\n  Serial.println(\"Error sending the data\");\n}<\/code><\/pre>\n\n\n\n<p>And finally, for the third board, send the <span class=\"rnthl rntliteral\">test3<\/span> structure:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_err_t result3 = esp_now_send(\n  broadcastAddress3, \n  (uint8_t *) &amp;test3,\n  sizeof(test_struct));\n\nif (result3 == ESP_OK) {\n  Serial.println(\"Sent with success\");\n}\nelse {\n  Serial.println(\"Error sending the data\");\n}<\/code><\/pre>\n\n\n\n<p>Here&#8217;s the complete code that sends a different message to each board.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\r\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-one-to-many-esp32-esp8266\/\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\r\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n*********\/\r\n#include &lt;esp_now.h&gt;\r\n#include &lt;WiFi.h&gt;\r\n\r\n\/\/ REPLACE WITH YOUR ESP RECEIVER'S MAC ADDRESS\r\nuint8_t broadcastAddress1[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\r\nuint8_t broadcastAddress2[] = {0xFF, , , , , };\r\nuint8_t broadcastAddress3[] = {0xFF, , , , , };\r\n\r\ntypedef struct test_struct {\r\n  int x;\r\n  int y;\r\n} test_struct;\r\n\r\nesp_now_peer_info_t peerInfo;\r\n\r\nvoid OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {\r\n  char macStr[18];\r\n  Serial.print(&quot;Packet to: &quot;);\r\n  \/\/ Copies the sender mac address to a string\r\n  snprintf(macStr, sizeof(macStr), &quot;%02x:%02x:%02x:%02x:%02x:%02x&quot;,\r\n           mac_addr[0], mac_addr[1], mac_addr[2], mac_addr[3], mac_addr[4], mac_addr[5]);\r\n  Serial.print(macStr);\r\n  Serial.print(&quot; send status:\\t&quot;);\r\n  Serial.println(status == ESP_NOW_SEND_SUCCESS ? &quot;Delivery Success&quot; : &quot;Delivery Fail&quot;);\r\n}\r\n \r\nvoid setup() {\r\n \r\n  Serial.begin(115200);\r\n \r\n  WiFi.mode(WIFI_STA);\r\n \r\n  if (esp_now_init() != ESP_OK) {\r\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\r\n    return;\r\n  }\r\n\r\n  esp_now_register_send_cb(OnDataSent);\r\n\r\n  \/\/ register peer\r\n  peerInfo.channel = 0;  \r\n  peerInfo.encrypt = false;\r\n    \r\n  memcpy(peerInfo.peer_addr, broadcastAddress1, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n  \r\n  memcpy(peerInfo.peer_addr, broadcastAddress2, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n  memcpy(peerInfo.peer_addr, broadcastAddress3, 6);\r\n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\r\n    Serial.println(&quot;Failed to add peer&quot;);\r\n    return;\r\n  }\r\n}\r\n \r\nvoid loop() {\r\n  test_struct test;\r\n  test_struct test2;\r\n  test_struct test3;\r\n  test.x = random(0,20);\r\n  test.y = random(0,20);\r\n  test2.x = random(0,20);\r\n  test2.y = random(0,20);\r\n  test3.x = random(0,20);\r\n  test3.y = random(0,20);\r\n \r\n  esp_err_t result1 = esp_now_send(\r\n    broadcastAddress1, \r\n    (uint8_t *) &amp;test,\r\n    sizeof(test_struct));\r\n   \r\n  if (result1 == ESP_OK) {\r\n    Serial.println(&quot;Sent with success&quot;);\r\n  }\r\n  else {\r\n    Serial.println(&quot;Error sending the data&quot;);\r\n  }\r\n  delay(500);\r\n  esp_err_t result2 = esp_now_send(\r\n    broadcastAddress2, \r\n    (uint8_t *) &amp;test2,\r\n    sizeof(test_struct));\r\n\r\n  if (result2 == ESP_OK) {\r\n    Serial.println(&quot;Sent with success&quot;);\r\n  }\r\n  else {\r\n    Serial.println(&quot;Error sending the data&quot;);\r\n  }\r\n  \r\n  delay(500);  \r\n  esp_err_t result3 = esp_now_send(\r\n    broadcastAddress3, \r\n    (uint8_t *) &amp;test3,\r\n    sizeof(test_struct));\r\n   \r\n  if (result3 == ESP_OK) {\r\n    Serial.println(&quot;Sent with success&quot;);\r\n  }\r\n  else {\r\n    Serial.println(&quot;Error sending the data&quot;);\r\n  }\r\n  delay(2000);\r\n}\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP\/ESP_NOW\/ESP_NOW_Sender_Multiple_Boards_Different_Messages.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP32 Receiver Code (ESP-NOW) <\/h2>\n\n\n\n<p>Upload the next code to the receiver boards (in our example, we&#8217;ve used three receiver boards).<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\r\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-one-to-many-esp32-esp8266\/\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files.\r\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n*********\/\r\n#include &lt;esp_now.h&gt;\r\n#include &lt;WiFi.h&gt;\r\n\r\n\/\/Structure example to receive data\r\n\/\/Must match the sender structure\r\ntypedef struct test_struct {\r\n  int x;\r\n  int y;\r\n} test_struct;\r\n\r\n\/\/Create a struct_message called myData\r\ntest_struct myData;\r\n\r\n\/\/callback function that will be executed when data is received\r\nvoid OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {\r\n  memcpy(&amp;myData, incomingData, sizeof(myData));\r\n  Serial.print(&quot;Bytes received: &quot;);\r\n  Serial.println(len);\r\n  Serial.print(&quot;x: &quot;);\r\n  Serial.println(myData.x);\r\n  Serial.print(&quot;y: &quot;);\r\n  Serial.println(myData.y);\r\n  Serial.println();\r\n}\r\n \r\nvoid setup() {\r\n  \/\/Initialize Serial Monitor\r\n  Serial.begin(115200);\r\n  \r\n  \/\/Set device as a Wi-Fi Station\r\n  WiFi.mode(WIFI_STA);\r\n\r\n  \/\/Init ESP-NOW\r\n  if (esp_now_init() != ESP_OK) {\r\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\r\n    return;\r\n  }\r\n  \r\n  \/\/ Once ESPNow is successfully Init, we will register for recv CB to\r\n  \/\/ get recv packer info\r\n  esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataRecv));\r\n}\r\n \r\nvoid loop() {\r\n\r\n}\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP\/ESP_NOW\/ESP_NOW_Receiver_ESP32.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How the code works<\/h3>\n\n\n\n<p>Similarly to the sender, start by including the libraries:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;esp_now.h&gt;\n#include &lt;WiFi.h&gt;<\/code><\/pre>\n\n\n\n<p>Create a structure to receive the data. This structure should be the same defined in the sender sketch.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>typedef struct test_struct {\n  int x;\n  int y;\n} test_struct;<\/code><\/pre>\n\n\n\n<p>Create a&nbsp;<span class=\"rnthl rntliteral\">test_struct<\/span>&nbsp;variable called&nbsp;<span class=\"rnthl rntliteral\">myData<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>test_struct myData;<\/code><\/pre>\n\n\n\n<p>Create a callback function that is called when the ESP32 receives the data via ESP-NOW. The function is called <span class=\"rnthl rntliteral\">onDataRecv()<\/span> and should accept several parameters as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {<\/code><\/pre>\n\n\n\n<p>Copy the content of the <span class=\"rnthl rntliteral\">incomingData<\/span> data variable into the <span class=\"rnthl rntliteral\">myData<\/span> variable.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>memcpy(&amp;myData, incomingData, sizeof(myData));<\/code><\/pre>\n\n\n\n<p>Now, the&nbsp;<span class=\"rnthl rntliteral\">myData<\/span>&nbsp;structure contains several variables inside with the values sent by the sender ESP32. To access variable&nbsp;<span class=\"rnthl rntliteral\">x<\/span>, for example, call&nbsp;<span class=\"rnthl rntliteral\">myData.x<\/span>.<\/p>\n\n\n\n<p>In this example, we print the received data, but in a practical application you can print the data on an <a href=\"https:\/\/randomnerdtutorials.com\/esp32-ssd1306-oled-display-arduino-ide\/\">OLED display<\/a>, for example.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(\"Bytes received: \");\nSerial.println(len);\nSerial.print(\"x: \");\nSerial.println(myData.x);\nSerial.print(\"y: \");\nSerial.println(myData.y);\nSerial.println();<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, intialize the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.begin(115200);<\/code><\/pre>\n\n\n\n<p>Set the device as a Wi-Fi Station.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);<\/code><\/pre>\n\n\n\n<p>Initialize ESP-NOW:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>if (esp_now_init() != ESP_OK) {\n  Serial.println(\"Error initializing ESP-NOW\");\n  return;\n}<\/code><\/pre>\n\n\n\n<p>Register for a callback function that will be called when data is received. In this case, we register for the <span class=\"rnthl rntliteral\">OnDataRecv()<\/span> function that was created previously.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_now_register_recv_cb(esp_now_recv_cb_t(OnDataRecv));<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">ESP8266 Receiver Code (ESP-NOW)<\/h2>\n\n\n\n<p>If you&#8217;re using an ESP8266 board as a receiver, upload the following code instead.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\r\n  Rui Santos &amp; Sara Santos - Random Nerd Tutorials\r\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-one-to-many-esp32-esp8266\/\r\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. \r\n  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\r\n*********\/\r\n#include &lt;ESP8266WiFi.h&gt;\r\n#include &lt;espnow.h&gt;\r\n\r\n\/\/Structure example to receive data\r\n\/\/Must match the sender structure\r\ntypedef struct test_struct {\r\n  int x;\r\n  int y;\r\n} test_struct;\r\n\r\n\/\/Create a struct_message called myData\r\ntest_struct myData;\r\n\r\n\/\/callback function that will be executed when data is received\r\nvoid OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {\r\n  memcpy(&amp;myData, incomingData, sizeof(myData));\r\n  Serial.print(&quot;Bytes received: &quot;);\r\n  Serial.println(len);\r\n  Serial.print(&quot;x: &quot;);\r\n  Serial.println(myData.x);\r\n  Serial.print(&quot;y: &quot;);\r\n  Serial.println(myData.y);\r\n  Serial.println();\r\n}\r\n \r\nvoid setup() {\r\n  \/\/Initialize Serial Monitor\r\n  Serial.begin(115200);\r\n  \r\n  \/\/Set device as a Wi-Fi Station\r\n  WiFi.mode(WIFI_STA);\r\n\r\n  \/\/Init ESP-NOW\r\n  if (esp_now_init() != 0) {\r\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\r\n    return;\r\n  }\r\n  \r\n  \/\/ Once ESPNow is successfully Init, we will register for recv CB to\r\n  \/\/ get recv packer info\r\n  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);\r\n  esp_now_register_recv_cb(OnDataRecv);\r\n}\r\n \r\nvoid loop() {\r\n\r\n}\r\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP\/ESP_NOW\/ESP_NOW_Receiver_ESP8266.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Apart from small details, this code is very similar tothe ESP32 receiver code. So, we won&#8217;t explain how it works. To learn more you can read our <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\">ESP-NOW Getting Started Guide with ESP8266 NodeMCU<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Demonstration<\/h2>\n\n\n\n<p>Having all your boards powered on, open the Arduino IDE Serial Monitor for the COM port the sender is connected to.<\/p>\n\n\n\n<p>You should start receiving &#8220;<strong>Delivery Success<\/strong>&#8221; messages with the corresponding receiver&#8217;s MAC address in the Serial Monitor. <\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"445\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor.png?resize=707%2C445&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ESP-NOW Send Data To Multiple Boards Delivery Status Serial Monitor\" class=\"wp-image-95739\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor.png?w=707&amp;quality=100&amp;strip=all&amp;ssl=1 707w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor.png?resize=300%2C189&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/figure><\/div>\n\n\n<p>If you remove power from one of the boards, you&#8217;ll receive a &#8220;<strong>Delivery Fail<\/strong>&#8221; message for that specific board. So, you can quickly identify which board didn&#8217;t receive the message.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"707\" height=\"445\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor2.png?resize=707%2C445&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ESP-NOW Send Data To Multiple Boards Delivery Status Failed Serial Monitor\" class=\"wp-image-95740\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor2.png?w=707&amp;quality=100&amp;strip=all&amp;ssl=1 707w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP32-ESP-NOW-Send-Data-To-Multiple-Boards-Delivery-Status-Serial-Monitor2.png?resize=300%2C189&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 707px) 100vw, 707px\" \/><\/figure><\/div>\n\n\n<p>If you want to check if the boards are actually receiving the messages, you can open the Serial Monitor for the COM port they are connected to, or you can use <a href=\"https:\/\/www.putty.org\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"PuTTY (opens in a new tab)\">PuTTY<\/a> to establish a serial communication with your boards.<\/p>\n\n\n\n<p>If you&#8217;re using PuTTY, select Serial communication, write the COM port number and the baud rate (115200) as shown below and click <strong>Open<\/strong>.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"452\" height=\"442\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/Serial-Communication-ESP-Boards-PuTTY.png?resize=452%2C442&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Serial Communication ESP Boards PuTTY\" class=\"wp-image-95741\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/Serial-Communication-ESP-Boards-PuTTY.png?w=452&amp;quality=100&amp;strip=all&amp;ssl=1 452w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/Serial-Communication-ESP-Boards-PuTTY.png?resize=300%2C293&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 452px) 100vw, 452px\" \/><\/figure><\/div>\n\n\n<p>Then, you should see the messages being received.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"661\" height=\"418\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-Receive-Messages-Putty.png?resize=661%2C418&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ESP8266 NodeMCU ESP-NOW Send Data To Multiple Boards Delivery Success Demonstration\" class=\"wp-image-95744\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-Receive-Messages-Putty.png?w=661&amp;quality=100&amp;strip=all&amp;ssl=1 661w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-Receive-Messages-Putty.png?resize=300%2C190&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 661px) 100vw, 661px\" \/><\/figure><\/div>\n\n\n<p>Open a serial communication for each of your boards and check that they are receiving the messages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial, you&#8217;ve learned how to send data to multiple ESP32 or ESP8266 boards from a single ESP32 using ESP-NOW (one-to-many communication).<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. We have other ESP-NOW tutorials that you may like:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/\">Getting Started with ESP-NOW (ESP32 with Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\">Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">ESP-NOW Two-Way Communication Between ESP32 Boards (sensor readings)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-many-to-one-esp32\/\">ESP-NOW with ESP32: Receive Data from Multiple Boards (many-to-one)<\/a><\/li>\n<\/ul>\n\n\n\n<p>Learn more about the ESP32 with our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32\/ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">More ESP32 projects and tutorials&#8230;<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this tutorial, you&#8217;ll learn how to use ESP-NOW communication protocol to send data from one ESP32 to multiple ESP32 or ESP8266 boards (one-to-many configuration). The boards will be programmed &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP-NOW with ESP32: Send Data to Multiple Boards (one-to-many)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp32-esp8266\/#more-95718\" aria-label=\"Read more about ESP-NOW with ESP32: Send Data to Multiple Boards (one-to-many)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":96083,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[281,276,277,299,264],"tags":[],"class_list":["post-95718","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32-project","category-esp32","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/04\/ESP-NOW-ESP32-ESP8266-NodeMCU-Send-Data-Multiple-Boards-Arduino-IDE.jpg?fit=1280%2C720&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/95718","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=95718"}],"version-history":[{"count":6,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/95718\/revisions"}],"predecessor-version":[{"id":158793,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/95718\/revisions\/158793"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/96083"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=95718"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=95718"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=95718"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}