{"id":93712,"date":"2020-02-20T14:40:25","date_gmt":"2020-02-20T14:40:25","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=93712"},"modified":"2024-06-11T14:04:41","modified_gmt":"2024-06-11T14:04:41","slug":"esp-now-esp8266-nodemcu-arduino-ide","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/","title":{"rendered":"Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)"},"content":{"rendered":"\n<p>In this article, we&#8217;ll show you how you can use ESP-NOW to exchange data between ESP8266 NodeMCU boards programmed with Arduino IDE. ESP-NOW is a connectionless communication protocol developed by Espressif that features short packet transmission and can be used with ESP8266 and <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/\">ESP32 boards<\/a>.<\/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\/02\/Getting-Started-with-ESP-NOW-ESP8266-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Started with ESP-NOW ESP8266 NodeMCU with Arduino IDE\" class=\"wp-image-93846\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/Getting-Started-with-ESP-NOW-ESP8266-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\/02\/Getting-Started-with-ESP-NOW-ESP8266-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\/02\/Getting-Started-with-ESP-NOW-ESP8266-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\/02\/Getting-Started-with-ESP-NOW-ESP8266-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>We have other tutorials about ESP-NOW with the ESP8266:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp8266-nodemcu\/\">ESP-NOW Two-Way Communication Between ESP8266 NodeMCU Boards<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp8266-nodemcu\/\">ESP-NOW with ESP8266: Send Data to Multiple Boards (one-to-many)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-many-to-one-esp8266-nodemcu\/\">ESP-NOW with ESP8266: Receive Data from Multiple Boards (many-to-one)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Arduino IDE<\/h2>\n\n\n\n<p>We\u2019ll program the <a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\">ESP8266 NodeMCU board<\/a> using Arduino IDE, so before proceeding with this tutorial you should have the ESP8266 add-on installed in your Arduino IDE. Follow the next guide:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/how-to-install-esp8266-board-arduino-ide\/\">Installing ESP8266 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> we have a similar guide for the ESP32: <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/\">Getting Started with ESP-NOW (ESP32 with Arduino IDE)<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing ESP-NOW<\/h2>\n\n\n\n<p>The following video shows an introduction to ESP-NOW. This video was recorded for the ESP32, but most concepts also apply to the ESP8266 NodeMCU board.<\/p>\n\n\n<p style=\"text-align:center\"><iframe width=\"720\" height=\"405\" src=\"https:\/\/www.youtube.com\/embed\/qxwXwNS3Avw?rel=0\" frameborder=\"0\" allowfullscreen><\/iframe><\/p>\n\n\n\n<p>Stating Espressif website, ESP-NOW is a &#8220;<em>protocol developed by Espressif, which enables multiple devices to communicate with one another without using Wi-Fi. The protocol is similar to the low-power 2.4GHz wireless connectivity (&#8230;) . The pairing between devices is needed prior to their communication. After the pairing is done, the connection is safe and peer-to-peer, with no handshake being required<\/em>.&#8221;<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"256\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/esp-now-logo.png?resize=1024%2C256&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW - ESP32 Logo\" class=\"wp-image-93360\" style=\"width:345px;height:86px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/esp-now-logo.png?resize=1024%2C256&amp;quality=100&amp;strip=all&amp;ssl=1 1024w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/esp-now-logo.png?resize=300%2C75&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/esp-now-logo.png?resize=768%2C192&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/esp-now-logo.png?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure><\/div>\n\n\n<p>This means that after pairing a device with each other, the connection is persistent. In other words, if suddenly one of your boards loses power or resets, when it restarts, it will automatically connect to its peer to continue the communication.<\/p>\n\n\n\n<p>ESP-NOW supports the following features:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Encrypted and unencrypted unicast communication;<\/li>\n\n\n\n<li>Mixed encrypted and unencrypted peer devices;<\/li>\n\n\n\n<li><strong>Up to 250-byte<\/strong> payload can be carried;<\/li>\n\n\n\n<li>Sending callback function that can be set to inform the application layer of<br> transmission success or failure.<\/li>\n<\/ul>\n\n\n\n<p>ESP-NOW technology also has the following limitations:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-size: inherit; background-color: initial;\">Limited encrypted peers. 10 encrypted peers at the most are supported in Station mode; 6 at the most in SoftAP or SoftAP + Station mode;<\/span><\/li>\n\n\n\n<li>Multiple unencrypted peers are supported, however, their total number should be less than 20, including encrypted peers;<\/li>\n\n\n\n<li><strong>Payload is limited to 250 bytes<\/strong>. <\/li>\n<\/ul>\n\n\n\n<p><strong>In simple words, ESP-NOW is a fast communication protocol that can be used to exchange small messages (up to 250 bytes) between ESP8266 boards.<\/strong><\/p>\n\n\n\n<p>ESP-NOW is very versatile and you can have one-way or two-way communication in different setups.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ESP-NOW One-Way Communication<\/h3>\n\n\n\n<p>For example, in one-way communication, you can have scenarios like this:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>One ESP8266 board sending data to another ESP8266 board<\/strong><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"340\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?resize=750%2C340&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 ESP-NOW One-way Communication\" class=\"wp-image-93801\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?resize=300%2C136&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>This configuration is very easy to implement and it is great to send data from one board to the other like sensor readings or ON and OFF commands to control GPIOs.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span style=\"font-size: inherit; background-color: initial;\"><strong>A &#8220;master&#8221; ESP8266 sending data to multiple ESP8266 &#8220;slaves&#8221;<\/strong><\/span><\/li>\n<\/ul>\n\n\n\n<p>One ESP8266 board sending the same or different commands to different ESP8266 boards. This configuration is ideal to build something like a remote control. You can have several ESP8266 boards around the house that are controlled by one main ESP8266 board.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"404\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Master-Multiple-Slaves.png?resize=750%2C404&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW master ESP8266 sending data to multiple ESP8266 slaves\" class=\"wp-image-93799\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Master-Multiple-Slaves.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Master-Multiple-Slaves.png?resize=300%2C162&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>One ESP8266 &#8220;slave&#8221; receiving data from multiple &#8220;masters&#8221;<\/strong><\/li>\n<\/ul>\n\n\n\n<p>This configuration is ideal if you want to collect data from several sensors nodes into one ESP8266 board. This can be configured as a web server to display data from all the other boards, for example.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"412\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Slave-Multiple-Masters.PNG.png?resize=750%2C412&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW one ESP32 slave receiving data from multiple masters\" class=\"wp-image-93800\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Slave-Multiple-Masters.PNG.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Slave-Multiple-Masters.PNG.png?resize=300%2C165&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\"><strong>Note: <\/strong> in the ESP-NOW documentation there isn&#8217;t such thing as &#8220;sender\/master&#8221; and &#8220;receiver\/slave&#8221;. Every board can be a sender or receiver. However, to keep things clear we&#8217;ll use the terms &#8220;sender&#8221; and &#8220;receiver&#8221; or &#8220;master&#8221; and &#8220;slave&#8221;. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ESP-NOW Two-Way Communication<\/h3>\n\n\n\n<p>With ESP-NOW, each board can be a sender and a receiver at the same time. So, you can establish a two-way communication between boards.<\/p>\n\n\n\n<p>For example, you can have two boards communicating with each other.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"340\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-Two-Way-Communication.png?resize=750%2C340&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 ESP-NOW Two-way Communication\" class=\"wp-image-93802\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-Two-Way-Communication.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-Two-Way-Communication.png?resize=300%2C136&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>You can add more boards to this configuration and have something that looks like a network (all ESP8266 boards communicate with each other).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"416\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266_ESP_NOW_multiple_boards_two_way_communication.png?resize=750%2C416&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW two-way communication between multiple ESP8266 boards\" class=\"wp-image-93798\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266_ESP_NOW_multiple_boards_two_way_communication.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266_ESP_NOW_multiple_boards_two_way_communication.png?resize=300%2C166&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p class=\"rntbox rntclblue\">In summary, ESP-NOW is ideal to build a network in which you can have several ESP8266 boards exchanging data with each other.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP8266: Getting Board MAC Address<\/h2>\n\n\n\n<p>To communicate via ESP-NOW, you need to know the MAC Address of the ESP8266 receiver. That&#8217;s how you know to which device you&#8217;ll send the information to.<\/p>\n\n\n\n<p>Each ESP8266 has a <a href=\"https:\/\/randomnerdtutorials.com\/get-change-esp32-esp8266-mac-address-arduino\/\">unique MAC Address<\/a> and that&#8217;s how we identify each board to send data to it using ESP-NOW (learn how to <a href=\"https:\/\/randomnerdtutorials.com\/get-change-esp32-esp8266-mac-address-arduino\/\">Get and Change the ESP8266 MAC Address<\/a>).<\/p>\n\n\n\n<p>To get your board&#8217;s MAC Address, upload the following code.<\/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#include &lt;ESP8266WiFi.h&gt;\n\nvoid setup(){\n  Serial.begin(115200);\n  Serial.println();\n  Serial.print(&quot;ESP Board MAC Address:  &quot;);\n  Serial.println(WiFi.macAddress());\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\/ESP8266\/ESP8266_Get_MAC_Address.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>After uploading the code, open the Serial Monitor at a baud rate of 115200 and press the ESP8266 RESET button. The MAC address should be printed as follows:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" 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=\"ESP-NOW ESP32 Getting Board MAC Address\" 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>Save your board MAC address because you&#8217;ll need it to send data to the right board via ESP-NOW.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP-NOW One-way Point to Point Communication with ESP8266<\/h2>\n\n\n\n<p>To get you started with ESP-NOW wireless communication, we&#8217;ll build a simple project that shows how to send a message from one ESP8266 to another. One ESP8266 will act as a &#8220;sender&#8221; and the other ESP8266 will be the &#8220;receiver&#8221;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"340\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?resize=750%2C340&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP8266 ESP-NOW One-way Communication Example with Arduino IDE\" class=\"wp-image-93801\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-One-Way-Communication.PNG.png?resize=300%2C136&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>We&#8217;ll send a structure that contains a variable of type <em>char<\/em>, <em>int<\/em>, <em>float<\/em>, <em>String <\/em>and <em>boolean<\/em>. Then, you can modify the structure to send whichever variable types are suitable for your project (like sensor readings, or boolean variables to turn something on or off).<\/p>\n\n\n\n<p>For better understanding we&#8217;ll call &#8220;sender&#8221; to ESP8266 #1 and &#8220;receiver&#8221; to ESP8266 #2.<\/p>\n\n\n\n<p>Here&#8217;s what we should include in the <strong>sender<\/strong> sketch:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Initialize ESP-NOW;<\/li>\n\n\n\n<li>Register a callback function upon sending data \u2013 the <span class=\"rnthl rntliteral\">OnDataSent<\/span> function will be executed when a message is sent. This can tell us if the message was successfully delivered or not;<\/li>\n\n\n\n<li>Add a peer device (the receiver). For this, you need to know the the receiver MAC address;<\/li>\n\n\n\n<li>Send a message to the peer device.<\/li>\n<\/ol>\n\n\n\n<p>On the <strong>receiver <\/strong>side, the sketch should include:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Initialize ESP-NOW;<\/li>\n\n\n\n<li>Register for a receive callback function (<span class=\"rnthl rntliteral\">OnDataRecv<\/span>). This is a function that will be executed when a message is received.<\/li>\n\n\n\n<li>Inside that callback function save the message into a variable to execute any task with that information.<\/li>\n<\/ol>\n\n\n\n<p>ESP-NOW works with callback functions that are called when a device receives a message or when a message is sent (you get if the message was successfully delivered or if it failed).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP-NOW Useful Functions<\/h2>\n\n\n\n<p>Here&#8217;s a summary of most essential ESP-NOW functions:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Function Name and Description<\/strong><\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_init()<\/span> Initializes ESP-NOW. You must initialize Wi-Fi before initializing ESP-NOW. Returns 0, if succeed.<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_set_self_role(role)<\/span> the role can be: <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_IDLE = 0<\/span>,<br><span class=\"rnthl rntliteral\">ESP_NOW_ROLE_CONTROLLER<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_SLAVE<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_COMBO<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_MAX<\/span><\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_add_peer(uint8 mac_addr, uint8 role, uint8 channel, uint8 key, uint8 key_len)<\/span> Call this function to pair a device.<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_send(uint8 mac_address, uint8 data, int len)<\/span> Send data with ESP-NOW.<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_register_send_cb()<\/span> Register a callback function that is triggered upon sending data. When a message is sent, a function is called &#8211; this function returns whether the delivery was successful or not.<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_register_recv_cb()<\/span> Register a callback function that is triggered upon receiving data. When data is received via ESP-NOW, a function is called.<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For more information about these functions:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/demo-dijiudu.readthedocs.io\/en\/latest\/api-reference\/wifi\/esp_now.html\" target=\"_blank\" rel=\"noreferrer noopener\">ESP-NOW documentation at Read the Docs<\/a><\/li>\n\n\n\n<li><a aria-label=\" (opens in a new tab)\" href=\"https:\/\/www.espressif.com\/sites\/default\/files\/documentation\/2c-esp8266_non_os_sdk_api_reference_en.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">ESP8266 API reference from Espressif<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">ESP8266 NodeMCU Sender Sketch (ESP-NOW)<\/h3>\n\n\n\n<p>Here&#8217;s the code for the ESP8266 NodeMCU Sender board. Copy the code to your Arduino IDE, but don&#8217;t upload it yet. You need to make a few modifications to make it work for you.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\n  \n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files.\n  \n  The above copyright notice and this permission notice shall be included in all\n  copies or substantial portions of the Software.\n*\/\n\n#include &lt;ESP8266WiFi.h&gt;\n#include &lt;espnow.h&gt;\n\n\/\/ REPLACE WITH RECEIVER MAC Address\nuint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};\n\n\/\/ Structure example to send data\n\/\/ Must match the receiver structure\ntypedef struct struct_message {\n  char a[32];\n  int b;\n  float c;\n  String d;\n  bool e;\n} struct_message;\n\n\/\/ Create a struct_message called myData\nstruct_message myData;\n\nunsigned long lastTime = 0;  \nunsigned long timerDelay = 2000;  \/\/ send readings timer\n\n\/\/ Callback when data is sent\nvoid OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {\n  Serial.print(&quot;Last Packet Send Status: &quot;);\n  if (sendStatus == 0){\n    Serial.println(&quot;Delivery success&quot;);\n  }\n  else{\n    Serial.println(&quot;Delivery fail&quot;);\n  }\n}\n \nvoid setup() {\n  \/\/ Init Serial Monitor\n  Serial.begin(115200);\n \n  \/\/ Set device as a Wi-Fi Station\n  WiFi.mode(WIFI_STA);\n\n  \/\/ Init ESP-NOW\n  if (esp_now_init() != 0) {\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\n    return;\n  }\n\n  \/\/ Once ESPNow is successfully Init, we will register for Send CB to\n  \/\/ get the status of Trasnmitted packet\n  esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);\n  esp_now_register_send_cb(OnDataSent);\n  \n  \/\/ Register peer\n  esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);\n}\n \nvoid loop() {\n  if ((millis() - lastTime) &gt; timerDelay) {\n    \/\/ Set values to send\n    strcpy(myData.a, &quot;THIS IS A CHAR&quot;);\n    myData.b = random(1,20);\n    myData.c = 1.2;\n    myData.d = &quot;Hello&quot;;\n    myData.e = false;\n\n    \/\/ Send message via ESP-NOW\n    esp_now_send(broadcastAddress, (uint8_t *) &amp;myData, sizeof(myData));\n\n    lastTime = millis();\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\/ESP8266\/ESP_NOW\/ESP_NOW_Sender.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\">ESP8266WiFi.h<\/span> and <span class=\"rnthl rntliteral\">espnow.h<\/span> libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;ESP8266WiFi.h&gt;\n#include &lt;espnow.h&gt;<\/code><\/pre>\n\n\n\n<p>In the next line, you should insert the ESP8266 receiver MAC address.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>uint8_t broadcastAddress&#091;] = {0x5C, 0xCF, 0x7F, 0x99, 0x9A, 0xEA};<\/code><\/pre>\n\n\n\n<p>In our case, the receiver MAC address is: <span class=\"rnthl rntliteral\">5C:CF:7F:99:9A:EA<\/span>, but you need to replace that variable with your own MAC address.<\/p>\n\n\n\n<p>Then, create a structure that contains the type of data we want to send. We called this structure <span class=\"rnthl rntliteral\">struct_message<\/span> and it contains 5 different variable types. 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 struct_message {\n  char a&#091;32];\n  int b;\n  float c;\n  String d;\n  bool e;\n} struct_message;<\/code><\/pre>\n\n\n\n<p>Create a new variable of type <span class=\"rnthl rntliteral\">struct_message<\/span> that is called <span class=\"rnthl rntliteral\">myData<\/span> that will store the variables values.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>struct_message myData;<\/code><\/pre>\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 message simply prints if the message was successfully sent or not.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {\n  Serial.print(\"Last Packet Send Status: \");\n  if (sendStatus == 0){\n    Serial.println(\"Delivery success\");\n  }\n  else{\n    Serial.println(\"Delivery fail\");\n  }\n}<\/code><\/pre>\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() != 0) {\n  Serial.println(\"Error initializing ESP-NOW\");\n  return;\n}<\/code><\/pre>\n\n\n\n<p>Set the ESP8266 role:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_now_set_self_role(ESP_NOW_ROLE_CONTROLLER);<\/code><\/pre>\n\n\n\n<p>It accepts the following roles: <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_CONTROLLER<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_SLAVE<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_COMBO<\/span>, <span class=\"rnthl rntliteral\">ESP_NOW_ROLE_MAX<\/span>.<\/p>\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, we 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<p>Then, pair with another ESP-NOW device to send data:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_SLAVE, 1, NULL, 0);<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">esp_now_add_peer<\/span> accepts the following arguments, in this order: mac address, role, wi-fi channel, key, and key length.<\/p>\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 on the <span class=\"rnthl rntliteral\">timerDelay<\/span> variable).<\/p>\n\n\n\n<p>First, we set the variables values as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>strcpy(myData.a, \"THIS IS A CHAR\");\nmyData.b = random(1,20);\nmyData.c = 1.2;\nmyData.d = \"Hello\";\nmyData.e = false;<\/code><\/pre>\n\n\n\n<p>Remember that <span class=\"rnthl rntliteral\">myData<\/span> is a structure. Here we assign the values we want to send inside the structure. For example, the first line assigns a char, the second line assigns a random Int number, a Float, a String and a Boolean variable.<\/p>\n\n\n\n<p>We create this kind of structure to show you how to send the most common variable types. You can change the structure to send any other type of data.<\/p>\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_now_send(broadcastAddress, (uint8_t *) &amp;myData, sizeof(myData));<\/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>if ((millis() - lastTime) &gt; timerDelay) {\n  \/\/ Set values to send\n  strcpy(myData.a, \"THIS IS A CHAR\");\n  myData.b = random(1,20);\n  myData.c = 1.2;\n  myData.d = \"Hello\";\n  myData.e = false;\n\n  \/\/ Send message via ESP-NOW\n  esp_now_send(broadcastAddress, (uint8_t *) &amp;myData, sizeof(myData));\n\n  lastTime = millis();\n}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">ESP8266 NodeMCU Receiver Sketch (ESP-NOW)<\/h3>\n\n\n\n<p>Upload the following code to your <a href=\"https:\/\/makeradvisor.com\/tools\/esp8266-esp-12e-nodemcu-wi-fi-development-board\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">ESP8266 NodeMCU receiver board<\/a>.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Rui Santos\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\n  \n  Permission is hereby granted, free of charge, to any person obtaining a copy\n  of this software and associated documentation files.\n  \n  The above copyright notice and this permission notice shall be included in all\n  copies or substantial portions of the Software.\n*\/\n\n#include &lt;ESP8266WiFi.h&gt;\n#include &lt;espnow.h&gt;\n\n\/\/ Structure example to receive data\n\/\/ Must match the sender structure\ntypedef struct struct_message {\n    char a[32];\n    int b;\n    float c;\n    String d;\n    bool e;\n} struct_message;\n\n\/\/ Create a struct_message called myData\nstruct_message myData;\n\n\/\/ Callback function that will be executed when data is received\nvoid OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {\n  memcpy(&amp;myData, incomingData, sizeof(myData));\n  Serial.print(&quot;Bytes received: &quot;);\n  Serial.println(len);\n  Serial.print(&quot;Char: &quot;);\n  Serial.println(myData.a);\n  Serial.print(&quot;Int: &quot;);\n  Serial.println(myData.b);\n  Serial.print(&quot;Float: &quot;);\n  Serial.println(myData.c);\n  Serial.print(&quot;String: &quot;);\n  Serial.println(myData.d);\n  Serial.print(&quot;Bool: &quot;);\n  Serial.println(myData.e);\n  Serial.println();\n}\n \nvoid setup() {\n  \/\/ Initialize Serial Monitor\n  Serial.begin(115200);\n  \n  \/\/ Set device as a Wi-Fi Station\n  WiFi.mode(WIFI_STA);\n\n  \/\/ Init ESP-NOW\n  if (esp_now_init() != 0) {\n    Serial.println(&quot;Error initializing ESP-NOW&quot;);\n    return;\n  }\n  \n  \/\/ Once ESPNow is successfully Init, we will register for recv CB to\n  \/\/ get recv packer info\n  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);\n  esp_now_register_recv_cb(OnDataRecv);\n}\n\nvoid loop() {\n  \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\/ESP8266\/ESP_NOW\/ESP_NOW_Receiver.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 struct_message {\n  char a&#091;32];\n  int b;\n  float c;\n  String d;\n  bool e;\n} struct_message;<\/code><\/pre>\n\n\n\n<p>Create a <span class=\"rnthl rntliteral\">struct_message<\/span> variable called <span class=\"rnthl rntliteral\">myData<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>struct_message myData;<\/code><\/pre>\n\n\n\n<p>Create a callback function that will be called when the ESP8266 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>We 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 <span class=\"rnthl rntliteral\">myData<\/span> structure contains several variables inside with the values sent by the sender ESP8266. To access variable <span class=\"rnthl rntliteral\">a<\/span>, for example, we just need to call <span class=\"rnthl rntliteral\">myData.a<\/span>.<\/p>\n\n\n\n<p>In this example, we simply print the received data, but in a practical application you can print the data on a display, for example.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>  Serial.print(\"Bytes received: \");\n  Serial.println(len);\n  Serial.print(\"Char: \");\n  Serial.println(myData.a);\n  Serial.print(\"Int: \");\n  Serial.println(myData.b);\n  Serial.print(\"Float: \");\n  Serial.println(myData.c);\n  Serial.print(\"String: \");\n  Serial.println(myData.d);\n  Serial.print(\"Bool: \");\n  Serial.println(myData.e);\n  Serial.println();\n}<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, intialize Serial communication 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>Set the ESP8266 role:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);<\/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(OnDataRecv);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Testing ESP-NOW Communication<\/h2>\n\n\n\n<p>Upload the sender sketch to one board and the receiver sketch to the other board. Don&#8217;t forget to insert the receiver MAC address on the sender sketch.<\/p>\n\n\n\n<p>Now, open two Arduino IDE windows. One for the receiver, and another for the sender. Open the Serial Monitor for each board. It should be a different COM port for each board.<\/p>\n\n\n\n<p>This is what you should get on the sender side.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"652\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-delivery-success-serial-monitor.png?resize=652%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ESP-NOW Communication ESP8266 with Arduino IDE Sender\" class=\"wp-image-93808\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-delivery-success-serial-monitor.png?w=652&amp;quality=100&amp;strip=all&amp;ssl=1 652w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-ESP-NOW-delivery-success-serial-monitor.png?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>And this is what you should get on the receiver side. Note that the Int variable changes between each reading received (because we set it to a random number in the sender side).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"859\" height=\"452\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_Receiver_Serial_Monitor.jpg?resize=859%2C452&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Testing ESP-NOW Communication ESP32 with Arduino IDE Receiver\" class=\"wp-image-92909\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_Receiver_Serial_Monitor.jpg?w=859&amp;quality=100&amp;strip=all&amp;ssl=1 859w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_Receiver_Serial_Monitor.jpg?resize=300%2C158&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_Receiver_Serial_Monitor.jpg?resize=768%2C404&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 859px) 100vw, 859px\" \/><\/figure><\/div>\n\n\n<p>We tested the communication range between the two boards, and we are able to get a stable communication up to 140 meters (approximately 459 feet) in open field. In this experiment both ESP8266 on-board antennas were pointing to each other.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"423\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-NodeMCU-ESP-NOW-communication-range.jpg?resize=750%2C423&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW communication range test ESP8266 NodeMCU boards\" class=\"wp-image-94187\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-NodeMCU-ESP-NOW-communication-range.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/ESP8266-NodeMCU-ESP-NOW-communication-range.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\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial you&#8217;ve learned how to use ESP-NOW with the ESP8266 NodeMCU board. Now, you can combine the sender and receiver sketch so that you have a two-way communication (each board acting as a server and sender at the same time). You can also use more boards to have a communication between multiple boards.<\/p>\n\n\n\n<p>ESP8266 and ESP32 boards can communicate with each other using ESP-NOW communication protocol. You just need to upload the proper sketches to each board. To learn how to use ESP-NOW with the ESP32, you can read our <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/\">ESP-NOW getting started guide for the ESP32<\/a>.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this tutorial useful. To learn more about the ESP8266 board, make sure you take a look at our resources:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\">Home Automation with ESP8266<\/a><\/li>\n\n\n\n<li><a style=\"font-size: inherit; background-color: initial;\" href=\"https:\/\/randomnerdtutorials.com\/micropython-programming-with-esp32-and-esp8266\/\">MicroPython Programming with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp8266\/\">More ESP8266 resources&#8230;<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this article, we&#8217;ll show you how you can use ESP-NOW to exchange data between ESP8266 NodeMCU boards programmed with Arduino IDE. ESP-NOW is a connectionless communication protocol developed by &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/#more-93712\" aria-label=\"Read more about Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":93846,"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":[265,214,246,300,240,264],"tags":[],"class_list":["post-93712","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp8266-project","category-esp8266","category-esp8266-arduino-ide","category-0-esp8266","category-esp8266-projects","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/02\/Getting-Started-with-ESP-NOW-ESP8266-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\/93712","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=93712"}],"version-history":[{"count":1,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/93712\/revisions"}],"predecessor-version":[{"id":158756,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/93712\/revisions\/158756"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/93846"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=93712"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=93712"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=93712"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}