{"id":92668,"date":"2020-01-29T16:15:37","date_gmt":"2020-01-29T16:15:37","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=92668"},"modified":"2024-06-11T14:03:42","modified_gmt":"2024-06-11T14:03:42","slug":"esp-now-esp32-arduino-ide","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/","title":{"rendered":"Getting Started with ESP-NOW (ESP32 with Arduino IDE)"},"content":{"rendered":"\n<p>Learn how to use ESP-NOW to exchange data between ESP32 boards programmed with Arduino IDE. ESP-NOW is a connectionless communication protocol developed by Espressif that features short packet transmission. This protocol enables multiple devices to talk to each other in an easy way.<\/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\/01\/Getting-Started-with-ESP-NOW-ESP32-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Getting Started with ESP-NOW (ESP32 with Arduino IDE)\" class=\"wp-image-93359\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/Getting-Started-with-ESP-NOW-ESP32-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\/01\/Getting-Started-with-ESP-NOW-ESP32-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\/01\/Getting-Started-with-ESP-NOW-ESP32-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\/01\/Getting-Started-with-ESP-NOW-ESP32-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 for ESP-NOW with the ESP32:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">ESP-NOW Two-Way Communication Between ESP32 Boards<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp32-esp8266\/\">ESP-NOW with ESP32: 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-esp32\/\">ESP-NOW with ESP32: Receive Data from Multiple Boards (many-to-one)<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-esp-now-wi-fi-web-server\/\">ESP32: ESP-NOW Web Server Sensor Dashboard (ESP-NOW + Wi-Fi)<\/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\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"ESP32 board (opens in a new tab)\">ESP32 board<\/a> using Arduino IDE, so before proceeding with this tutorial you should have the ESP32 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\/installing-esp32-arduino-ide-2-0\/\" title=\"\">Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, and Linux instructions)<\/a><\/li>\n<\/ul>\n\n\n\n<p class=\"rntbox rntclblue\"><strong>Note:&nbsp;<\/strong>we have a similar guide for the ESP8266 NodeMCU Board:&nbsp;<a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\">Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)<\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Introducing ESP-NOW<\/h2>\n\n\n\n<p>For a video introduction to ESP-NOW protocol, watch the following (<a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">try the project featured in this video<\/a>):<\/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 the 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 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 ESP32 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 ESP32 board sending data to another ESP32 board<\/strong><\/li>\n<\/ul>\n\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<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW One ESP32 board sending data to another ESP32 board\" class=\"wp-image-93050\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?resize=300%2C168&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><span style=\"font-size: inherit; background-color: initial;\"><strong><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp32-esp8266\/\">A &#8220;master&#8221; ESP32 sending data to multiple ESP32 &#8220;slaves&#8221;<\/a><\/strong><\/span><\/li>\n<\/ul>\n\n\n\n<p>One ESP32 board sending the same or different commands to different ESP32 boards. This configuration is ideal to build something like a remote control. You can have several ESP32 boards around the house that are controlled by one main ESP32 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=\"652\" height=\"382\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_master_multiple_slaves.png?resize=652%2C382&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW master ESP32 sending data to multiple ESP32 slaves\" class=\"wp-image-93051\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_master_multiple_slaves.png?w=652&amp;quality=100&amp;strip=all&amp;ssl=1 652w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_master_multiple_slaves.png?resize=300%2C176&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 652px) 100vw, 652px\" \/><\/figure><\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-many-to-one-esp32\/\">One ESP32 &#8220;slave&#8221; receiving data from multiple &#8220;masters&#8221;<\/a><\/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 ESP32 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=\"649\" height=\"375\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_slave_multiple_masters.png?resize=649%2C375&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW One ESP32 slave receiving data from multiple masters\" class=\"wp-image-93052\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_slave_multiple_masters.png?w=649&amp;quality=100&amp;strip=all&amp;ssl=1 649w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_slave_multiple_masters.png?resize=300%2C173&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 649px) 100vw, 649px\" \/><\/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 href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">two-way communication between boards<\/a>.<\/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\"><a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"370\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_two_way_communication_two_boards.png?resize=750%2C370&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW Two-Way Communication between two ESP32 boards\" class=\"wp-image-93054\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_two_way_communication_two_boards.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_two_way_communication_two_boards.png?resize=300%2C148&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/a><\/figure><\/div>\n\n\n<p><strong>Learn how to:<\/strong> <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-two-way-communication-esp32\/\">Exchange Sensor Readings with ESP-NOW Two-Way Communication<\/a>.<\/p>\n\n\n\n<p>You can add more boards to this configuration and have something that looks like a network (all ESP32 boards communicate with each other).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"413\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_multiple_boards_two_way_communication.png?resize=585%2C413&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW Communication between multiple ESP32 boards\" class=\"wp-image-93056\" style=\"width:585px;height:413px\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_multiple_boards_two_way_communication.png?w=585&amp;quality=100&amp;strip=all&amp;ssl=1 585w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_multiple_boards_two_way_communication.png?resize=300%2C212&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 585px) 100vw, 585px\" \/><\/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 ESP32 boards exchanging data with each other. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP32: Getting Board MAC Address<\/h2>\n\n\n\n<p>To communicate via ESP-NOW, you need to know the MAC Address of the <a aria-label=\"ESP32 receiver (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\" rel=\"noreferrer noopener\">ESP32 receiver<\/a>. That&#8217;s how you know to which device you&#8217;ll send the data to.<\/p>\n\n\n\n<p>Each ESP32 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 ESP32 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;WiFi.h&gt;\n#include &lt;esp_wifi.h&gt;\n\nvoid readMacAddress(){\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}\n\nvoid setup(){\n  Serial.begin(115200);\n\n  WiFi.mode(WIFI_STA);\n  WiFi.STA.begin();\n\n  Serial.print(&quot;[DEFAULT] ESP32 Board MAC Address: &quot;);\n  readMacAddress();\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\/ESP32\/ESP32_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 ESP32 RST\/EN 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<\/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 ESP32 to another. One ESP32 will be the &#8220;sender&#8221; and the other ESP32 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=\"421\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?resize=750%2C421&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW One-way Point to Point Communication ESP32\" class=\"wp-image-93050\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_one_way_communication_two_boards.png?resize=300%2C168&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>, 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 ESP32 #1 and &#8220;receiver&#8221; to ESP32 #2.<\/p>\n\n\n\n<p>Here&#8217;s what we should include in the sender 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 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 receiver 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 the 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. <\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_add_peer()<\/span> Call this function to pair a device and pass as an argument the peer MAC address. <\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">esp_now_send()<\/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 read the <a href=\"https:\/\/demo-dijiudu.readthedocs.io\/en\/latest\/api-reference\/wifi\/esp_now.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">ESP-NOW documentation at Read the Docs<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ESP32 Sender Sketch (ESP-NOW)<\/h3>\n\n\n\n<p>Here&#8217;s the code for the <a rel=\"noreferrer noopener\" aria-label=\"ESP32 Sender (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32 Sender board<\/a>. 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 &amp; Sara Santos - Random Nerd Tutorials\n  Complete project details at https:\/\/RandomNerdTutorials.com\/esp-now-esp32-arduino-ide\/\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;esp_now.h&gt;\n#include &lt;WiFi.h&gt;\n\n\/\/ REPLACE WITH YOUR 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  bool d;\n} struct_message;\n\n\/\/ Create a struct_message called myData\nstruct_message myData;\n\nesp_now_peer_info_t peerInfo;\n\n\/\/ callback when data is sent\nvoid OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {\n  Serial.print(&quot;\\r\\nLast Packet Send Status:\\t&quot;);\n  Serial.println(status == ESP_NOW_SEND_SUCCESS ? &quot;Delivery Success&quot; : &quot;Delivery Fail&quot;);\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() != ESP_OK) {\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_register_send_cb(OnDataSent);\n  \n  \/\/ Register peer\n  memcpy(peerInfo.peer_addr, broadcastAddress, 6);\n  peerInfo.channel = 0;  \n  peerInfo.encrypt = false;\n  \n  \/\/ Add peer        \n  if (esp_now_add_peer(&amp;peerInfo) != ESP_OK){\n    Serial.println(&quot;Failed to add peer&quot;);\n    return;\n  }\n}\n \nvoid loop() {\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 = false;\n  \n  \/\/ Send message via ESP-NOW\n  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &amp;myData, sizeof(myData));\n   \n  if (result == ESP_OK) {\n    Serial.println(&quot;Sent with success&quot;);\n  }\n  else {\n    Serial.println(&quot;Error sending the data&quot;);\n  }\n  delay(2000);\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\/ESP32\/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\">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<p>In the next line, you should insert the ESP32 receiver MAC address.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>uint8_t broadcastAddress&#091;] = {0x30, 0xAE, 0xA4, 0x07, 0x0D, 0x64};<\/code><\/pre>\n\n\n\n<p>In our case, the receiver MAC address is: <span class=\"rnthl rntliteral\">30:AE:A4:07:0D:64<\/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 4 different variable types. You can change this to send other variable types.<\/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  bool d;\n} struct_message;<\/code><\/pre>\n\n\n\n<p>Then, 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&#8217; values.<\/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 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 class=\"wp-block-code language-c\"><code>esp_now_peer_info_t peerInfo;<\/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 function simply prints if the message was successfully delivered or not.<\/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  Serial.print(\"\\r\\nLast Packet Send Status:\\t\");\n  Serial.println(status == ESP_NOW_SEND_SUCCESS ? \"Delivery Success\" : \"Delivery Fail\");\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() != 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, 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>After that, we need to pair with another ESP-NOW device to send data. That&#8217;s what we do in the next lines:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/Register peer\nmemcpy(peerInfo.peer_addr, broadcastAddress, 6);\npeerInfo.channel = 0;\npeerInfo.encrypt = false;\n\n\/\/Add peer\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>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>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 = 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, 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 other data types.<\/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_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &amp;myData, sizeof(myData));<\/code><\/pre>\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<h3 class=\"wp-block-heading\">ESP32 Receiver Sketch (ESP-NOW)<\/h3>\n\n\n\n<p>Upload the following code to your <a rel=\"noreferrer noopener\" aria-label=\"ESP32 receiver (opens in a new tab)\" href=\"https:\/\/makeradvisor.com\/tools\/esp32-dev-board-wi-fi-bluetooth\/\" target=\"_blank\">ESP32 receiver board<\/a>.<\/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\/esp-now-esp32-arduino-ide\/  \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\n#include &lt;esp_now.h&gt;\n#include &lt;WiFi.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    bool d;\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(const uint8_t * mac, const uint8_t *incomingData, int 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;Bool: &quot;);\n  Serial.println(myData.d);\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() != ESP_OK) {\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_register_recv_cb(esp_now_recv_cb_t(OnDataRecv));\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\/ESP32\/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  bool d;\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 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>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 ESP32 sender. 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: \");\nSerial.println(len);\nSerial.print(\"Char: \");\nSerial.println(myData.a);\nSerial.print(\"Int: \");\nSerial.println(myData.b);\nSerial.print(\"Float: \");\nSerial.println(myData.c);\nSerial.print(\"Bool: \");\nSerial.println(myData.d);\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\">Testing ESP-NOW Communication<\/h2>\n\n\n\n<p>Upload the sender sketch to the sender ESP32 board and the receiver sketch to the receiver ESP32 board. <\/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=\"807\" height=\"326\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Sender-Message-Print.png?resize=807%2C326&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW ESP32 Sender Message Print Arduino IDE Demonstration\" class=\"wp-image-158753\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Sender-Message-Print.png?w=807&amp;quality=100&amp;strip=all&amp;ssl=1 807w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Sender-Message-Print.png?resize=300%2C121&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Sender-Message-Print.png?resize=768%2C310&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 807px) 100vw, 807px\" \/><\/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 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=\"825\" height=\"504\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Receiver-Message-Print.png?resize=825%2C504&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW ESP32 Receiver Message Print Arduino IDE Demonstration\" class=\"wp-image-158752\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Receiver-Message-Print.png?w=825&amp;quality=100&amp;strip=all&amp;ssl=1 825w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Receiver-Message-Print.png?resize=300%2C183&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/ESP-NOW-ESP32-Receiver-Message-Print.png?resize=768%2C469&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 825px) 100vw, 825px\" \/><\/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 220 meters (approximately 722 feet) in open field. In this experiment both ESP32 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=\"389\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_ESP32_testing_range.png?resize=750%2C389&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP-NOW communication range test ESP32\" class=\"wp-image-93081\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_ESP32_testing_range.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2020\/01\/ESP_NOW_ESP32_testing_range.png?resize=300%2C156&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>We tried to keep our examples as simple as possible so that you better understand how everything works. There are more ESP-NOW-related functions that can be useful in your projects, like: managing peers, deleting peers, scanning for slave devices, etc&#8230; For a complete example, in your Arduino IDE, you can go to <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>ESP32 <\/strong>&gt; <strong>ESPNow <\/strong>and choose one of the example sketches.<\/p>\n\n\n\n<p>We hope you&#8217;ve found this introduction to ESP-NOW useful. As a simple getting started example, we&#8217;ve shown you how to send data as a structure from one ESP32 to another. The idea is to replace the structure values with sensor readings or GPIO states, for example.<\/p>\n\n\n\n<p>Additionally, with ESP-NOW, each board can simultaneously be a sender and receiver. One board can <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-one-to-many-esp32-esp8266\/\">send data to multiple boards<\/a> and also <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-many-to-one-esp32\/\">receive data from multiple boards<\/a>.<\/p>\n\n\n\n<p>We also have a tutorial about ESP-NOW with the ESP8266: <a href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp8266-nodemcu-arduino-ide\/\">Getting Started with ESP-NOW (ESP8266 NodeMCU with Arduino IDE)<\/a>.<\/p>\n\n\n\n<p>To learn more about the ESP32 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\/esp-now-two-way-communication-esp32\/\">ESP-NOW Two-Way Communication Between ESP32 Boards<\/a><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/randomnerdtutorials.com\/learn-esp32-with-arduino-ide\/\">Learn ESP32 with Arduino IDE (video course + eBook);<\/a><\/strong><\/li>\n\n\n\n<li><a 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-esp32\/\">More ESP32 resources&#8230;<\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use ESP-NOW to exchange data between ESP32 boards programmed with Arduino IDE. ESP-NOW is a connectionless communication protocol developed by Espressif that features short packet transmission. This &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"Getting Started with ESP-NOW (ESP32 with Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp-now-esp32-arduino-ide\/#more-92668\" aria-label=\"Read more about Getting Started with ESP-NOW (ESP32 with Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":93359,"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-92668","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\/01\/Getting-Started-with-ESP-NOW-ESP32-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\/92668","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=92668"}],"version-history":[{"count":9,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/92668\/revisions"}],"predecessor-version":[{"id":158755,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/92668\/revisions\/158755"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/93359"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=92668"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=92668"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=92668"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}