{"id":101782,"date":"2021-02-12T11:48:21","date_gmt":"2021-02-12T11:48:21","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=101782"},"modified":"2023-02-23T00:05:57","modified_gmt":"2023-02-23T00:05:57","slug":"esp32-useful-wi-fi-functions-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-useful-wi-fi-functions-arduino\/","title":{"rendered":"ESP32 Useful Wi-Fi Library Functions (Arduino IDE)"},"content":{"rendered":"\n<p>This article is a compilation of useful Wi-Fi functions for the ESP32. We&#8217;ll cover the following topics: scan Wi-Fi networks, connect to a Wi-Fi network, get Wi-Fi connection strength, check connection status, reconnect to the network after a connection is lost, Wi-Fi status, Wi-Fi modes, get the ESP32 IP address, set a fixed IP address and more. <\/p>\n\n\n\n<p>This is not a novelty. There are plenty of examples of how to handle Wi-Fi with the ESP32. However, we thought it would be useful to compile some of the most used and practical Wi-Fi functions for the ESP32.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\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\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Useful Wi-Fi Library Functions Arduino IDE\" class=\"wp-image-101839\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-Arduino-IDE.jpg?w=1280&amp;quality=100&amp;strip=all&amp;ssl=1 1280w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-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\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-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\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-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<h2 class=\"wp-block-heading\">Table of Contents<\/h2>\n\n\n\n<p>Here&#8217;s a list of what will be covered in this tutorial (you can click on the links to go to the corresponding section):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#1\">Wi-Fi Modes<\/a>: station, access point and both (station + access point);<\/li>\n\n\n\n<li><a href=\"#2\">Scan Wi-Fi networks<\/a>;<\/li>\n\n\n\n<li><span style=\"font-size: inherit; background-color: initial;\"><a href=\"#3\">Connect to a Wi-Fi network<\/a>;<\/span><\/li>\n\n\n\n<li><a href=\"#4\">Get Wi-Fi connection status<\/a>;<\/li>\n\n\n\n<li><a href=\"#5\">Check Wi-Fi connection strength<\/a>;<\/li>\n\n\n\n<li><a href=\"#6\">Get ESP32 IP address<\/a>;<\/li>\n\n\n\n<li><a href=\"#7\">Set an ESP32 Static IP address<\/a>;<\/li>\n\n\n\n<li><a href=\"#8\">Disconnect Wi-Fi<\/a>;<\/li>\n\n\n\n<li><span style=\"background-color: initial; font-size: inherit;\"><a href=\"#9\">Reconnect to Wi-Fi after connection is lost<\/a>;<\/span><\/li>\n\n\n\n<li><a href=\"#10\">ESP32 Wi-Fi Events<\/a>;<\/li>\n\n\n\n<li><a href=\"#11\">Reconnect to Wi-Fi Network After Lost Connection (Wi-Fi Events)<\/a>;<\/li>\n\n\n\n<li><a href=\"#WiFiMulti\">ESP32 WiFiMulti<\/a><\/li>\n\n\n\n<li><a href=\"#hostname\">Change ESP32 Hostname<\/a>.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Including the Wi-Fi Library<\/h2>\n\n\n\n<p>The first thing you need to do to use the ESP32 Wi-Fi functionalities is to include the <span class=\"rnthl rntliteral\">WiFi.h<\/span> library in your code, as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;WiFi.h&gt;<\/code><\/pre>\n\n\n\n<p>This library is automatically &#8220;installed&#8221; when you install the ESP32 add-on in your Arduino IDE. If you don&#8217;t have the ESP32 installed, you can follow the next tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/installing-the-esp32-board-in-arduino-ide-windows-instructions\/\">Installing the ESP32 Board in Arduino IDE (Windows, Mac OS X, Linux)<\/a><\/li>\n<\/ul>\n\n\n\n<p>If you prefer to use <a href=\"https:\/\/randomnerdtutorials.com\/vs-code-platformio-ide-esp32-esp8266-arduino\/\">VS Code + PaltformIO<\/a>, you just need to start a new project with an ESP32 board to be able to use the <span class=\"rnthl rntliteral\">WiFi.h<\/span> library and its functions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"1\">ESP32 Wi-Fi Modes<\/h2>\n\n\n\n<p>The ESP32 board can act as Wi-Fi Station, Access Point or both. To set the Wi-Fi mode, use <span class=\"rnthl rntliteral\">WiFi.mode()<\/span> and set the desired mode as argument:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><span class=\"rnthl rntliteral\">WiFi.mode(WIFI_STA)<\/span><\/td><td>station mode: the ESP32 connects to an access point<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">WiFi.mode(WIFI_AP)<\/span><\/td><td>access point mode: stations can connect to the ESP32<\/td><\/tr><tr><td><span class=\"rnthl rntliteral\">WiFi.mode(WIFI_AP_STA)<\/span><\/td><td>access point and a station connected to another access point<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Wi-Fi Station<\/h3>\n\n\n\n<p>When the ESP32 is set as a Wi-Fi station, it can connect to other networks (like your router). In this scenario, the router assigns a unique IP address to your ESP board. You can communicate with the ESP using other devices (stations) that are also connected to the same network by referring to the ESP unique IP address.<\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"397\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Station-Mode.png?resize=750%2C397&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Station Mode Router access point\" class=\"wp-image-101842\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Station-Mode.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Station-Mode.png?resize=300%2C159&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>The router is connected to the internet, so we can request information from the internet using the ESP32 board like data from APIs (weather data, for example), publish data to online platforms, use icons and images from the internet or include JavaScript libraries to build web server pages. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Set the ESP32 as a Station and Connect to Wi-Fi Network<\/h4>\n\n\n\n<p>Go to &#8220;<a href=\"#3\">Connect to Wi-Fi Network<\/a>&#8221; to learn how to set the ESP32 as station and connect it to a network.<\/p>\n\n\n\n<p>In some cases, this might not be the best configuration &#8211; when you don\u2019t have a network nearby and want you still want to connect to the ESP to control it. In this scenario, you must set your ESP board as an access point.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Access Point<\/h3>\n\n\n\n<p>When you set your ESP32 board as an access point, you can be connected using any device with Wi-Fi capabilities without connecting to your router. When you set the ESP32 as an access point, you create its own Wi-Fi network, and nearby Wi-Fi devices (stations) can connect to it, like your smartphone or computer. So, you don\u2019t need to be connected to a router to control it.<\/p>\n\n\n\n<p>This can be also useful if you want to have several ESP32 devices talking to each other without the need for a router.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"750\" height=\"397\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Access-Point-Mode.png?resize=750%2C397&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Access Point Mode\" class=\"wp-image-101843\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Access-Point-Mode.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-Access-Point-Mode.png?resize=300%2C159&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure>\n\n\n\n<p>Because the ESP32 doesn\u2019t connect further to a wired network like your router, it is called soft-AP (soft Access Point). This means that if you try to load libraries or use firmware from the internet, it will not work. It also doesn\u2019t work if you make HTTP requests to services on the internet to publish sensor readings to the cloud or use services on the internet (like sending an email, for example). <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Set the ESP32 as an Access Point<\/h4>\n\n\n\n<p>To set the ESP32 as an access point, set the Wi-Fi mode to access point:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_AP)<\/code><\/pre>\n\n\n\n<p>And then, use the <span class=\"rnthl rntliteral\">softAP()<\/span> method as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.softAP(ssid, password);<\/code><\/pre>\n\n\n\n<p><span class=\"rnthl rntliteral\">ssid<\/span> is the name you want to give to the ESP32 access point, and the <span class=\"rnthl rntliteral\">password<\/span> variable is the password for the access point. If you don&#8217;t want to set a password, set it to <span class=\"rnthl rntliteral\">NULL<\/span>.<\/p>\n\n\n\n<p>There are also other optional parameters you can pass to the <span class=\"rnthl rntliteral\">softAP()<\/span> method. Here are all the parameters:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.softAP(const char* ssid, const char* password, int channel, int ssid_hidden, int max_connection)<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">ssid<\/span>: name for the access point &#8211; maximum of 63 characters;<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">password<\/span>: <strong>minimum of 8 characters<\/strong>; set to <span class=\"rnthl rntliteral\">NULL<\/span> if you want the access point to be open;<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">channel<\/span>: Wi-Fi channel number (1-13)<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">ssid_hidden<\/span>: (0 = broadcast SSID, 1 = hide SSID)<\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">max_connection<\/span>: maximum simultaneous connected clients (1-4)<\/li>\n<\/ul>\n\n\n\n<p>We have a complete tutorial explaining how to set up the ESP32 as an access point: <\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-access-point-ap-web-server\/\">How to Set an ESP32 Access Point (AP) for Web Server<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Wi-Fi Station + Access Point<\/h3>\n\n\n\n<p>The ESP32 can be set as a Wi-Fi station and access point simultaneously. Set its mode to <span class=\"rnthl rntliteral\">WIFI_AP_STA<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_AP_STA);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"2\">Scan Wi-Fi Networks<\/h2>\n\n\n\n<p>The ESP32 can scan nearby Wi-Fi networks within its Wi-Fi range. In your Arduino IDE, go to <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>WiFi <\/strong>&gt; <strong>WiFiScan<\/strong>. This will load a sketch that scans Wi-Fi networks within the range of your ESP32 board. <\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"397\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-WiFi-Scan-Networks_Wi-Fi-Scan.png?resize=750%2C397&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Scan WiFi Networks\" class=\"wp-image-101872\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-WiFi-Scan-Networks_Wi-Fi-Scan.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-WiFi-Scan-Networks_Wi-Fi-Scan.png?resize=300%2C159&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>This can be useful to check if the Wi-Fi network you&#8217;re trying to connect is within the range of your board or other applications. Your Wi-Fi project may not often work because it may not be able to connect to your router due to insufficient Wi-Fi strength.<\/p>\n\n\n\n<p>Here&#8217;s the example:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Example from WiFi &gt; WiFiScan\n  Complete details at https:\/\/RandomNerdTutorials.com\/esp32-useful-wi-fi-functions-arduino\/\n*\/\n\n#include &quot;WiFi.h&quot;\n\nvoid setup() {\n  Serial.begin(115200);\n\n  \/\/ Set WiFi to station mode and disconnect from an AP if it was previously connected\n  WiFi.mode(WIFI_STA);\n  WiFi.disconnect();\n  delay(100);\n\n  Serial.println(&quot;Setup done&quot;);\n}\n\nvoid loop() {\n  Serial.println(&quot;scan start&quot;);\n\n  \/\/ WiFi.scanNetworks will return the number of networks found\n  int n = WiFi.scanNetworks();\n  Serial.println(&quot;scan done&quot;);\n  if (n == 0) {\n      Serial.println(&quot;no networks found&quot;);\n  } else {\n    Serial.print(n);\n    Serial.println(&quot; networks found&quot;);\n    for (int i = 0; i &lt; n; ++i) {\n      \/\/ Print SSID and RSSI for each network found\n      Serial.print(i + 1);\n      Serial.print(&quot;: &quot;);\n      Serial.print(WiFi.SSID(i));\n      Serial.print(&quot; (&quot;);\n      Serial.print(WiFi.RSSI(i));\n      Serial.print(&quot;)&quot;);\n      Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?&quot; &quot;:&quot;*&quot;);\n      delay(10);\n    }\n  }\n  Serial.println(&quot;&quot;);\n\n  \/\/ Wait a bit before scanning again\n  delay(5000);\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_WiFiScan.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>You can upload it to your board and check the available networks as well as the RSSI (received signal strength indicator).<\/p>\n\n\n\n<p><span class=\"rnthl rntliteral\">WiFi.scanNetworks()<\/span> returns the number of networks found.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>int n = WiFi.scanNetworks();<\/code><\/pre>\n\n\n\n<p>After the scanning, you can access the parameters about each network.<\/p>\n\n\n\n<p><span class=\"rnthl rntliteral\">WiFi.SSID()<\/span> prints the SSID for a specific network:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(WiFi.SSID(i));<\/code><\/pre>\n\n\n\n<p><span class=\"rnthl rntliteral\">WiFi.RSSI()<\/span> returns the RSSI of that network. RSSI stands for <strong>R<\/strong>eceived <strong>S<\/strong>ignal <strong>S<\/strong>trength <strong>I<\/strong>ndicator. It is an estimated measure of power level that an RF client device is receiving from an access point or router.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.print(WiFi.RSSI(i));<\/code><\/pre>\n\n\n\n<p>Finally, <span class=\"rnthl rntliteral\">WiFi.encryptionType()<\/span> returns the network encryption type. That specific example puts a * in the case of open networks. However, that function can return one of the following options (not just open networks):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_OPEN<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_WEP<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_WPA_PSK<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_WPA2_PSK<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_WPA_WPA2_PSK<\/span><\/li>\n\n\n\n<li><span class=\"rnthl rntliteral\">WIFI_AUTH_WPA2_ENTERPRISE<\/span><\/li>\n<\/ul>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"541\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Scan-WiFi-Networks-ESP32-Arduino-IDE-Serial-Monitor.png?resize=733%2C541&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Scan WiFi Networks Example Serial Monitor\" class=\"wp-image-101844\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Scan-WiFi-Networks-ESP32-Arduino-IDE-Serial-Monitor.png?w=733&amp;quality=100&amp;strip=all&amp;ssl=1 733w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Scan-WiFi-Networks-ESP32-Arduino-IDE-Serial-Monitor.png?resize=300%2C221&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"3\">Connect to a Wi-Fi Network<\/h2>\n\n\n\n<p>To connect the ESP32 to a specific Wi-Fi network, you must know its SSID and password. Additionally, that network must be within the ESP32 Wi-Fi range (to check that, you can use the previous example to scan Wi-Fi networks).<\/p>\n\n\n\n<p>You can use the following function to connect the ESP32 to a Wi-Fi network <span class=\"rnthl rntliteral\">initWiFi()<\/span>:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void initWiFi() {\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  Serial.print(\"Connecting to WiFi ..\");\n  while (WiFi.status() != WL_CONNECTED) {\n    Serial.print('.');\n    delay(1000);\n  }\n  Serial.println(WiFi.localIP());\n}<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">ssid<\/span> and <span class=\"rnthl rntliteral\">password<\/span> variables hold the SSID and password of the network you want to connect to.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Replace with your network credentials\nconst char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<p>Then, you simply need to call the <span class=\"rnthl rntliteral\">initWiFi()<\/span> function in your <span class=\"rnthl rntliteral\">setup()<\/span>.<\/p>\n\n\n\n<p><strong>How it Works?<\/strong><\/p>\n\n\n\n<p>Let&#8217;s take a quick look on how this function works.<\/p>\n\n\n\n<p>First, set the Wi-Fi mode. If the ESP32 will connected to another network (access point\/hotspot) it must be in station mode.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);<\/code><\/pre>\n\n\n\n<p>Then, use <span class=\"rnthl rntliteral\">WiFi.begin()<\/span> to connect to a network. You must pass as arguments the network SSID and its password:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.begin(ssid, password);<\/code><\/pre>\n\n\n\n<p>Connecting to a Wi-Fi network can take a while, so we usually add a while loop that keeps checking if the connection was already established by using <span class=\"rnthl rntliteral\">WiFi.status()<\/span>. When the connection is successfully established, it returns <span class=\"rnthl rntliteral\">WL_CONNECTED<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>while (WiFi.status() != WL_CONNECTED) {<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"4\">Get Wi-Fi Connection Status<\/h2>\n\n\n\n<p>To get the status of the Wi-Fi connection, you can use <span class=\"rnthl rntliteral\">WiFi.status()<\/span>. This returns one of the following values that correspond to the constants on the table:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td><strong>Value<\/strong><\/td><td><strong>Constant<\/strong><\/td><td><strong>Meaning<\/strong><\/td><\/tr><tr><td>0<\/td><td><span class=\"rnthl rntliteral\">WL_IDLE_STATUS<\/span><\/td><td>temporary status assigned when&nbsp;<span class=\"rnthl rntliteral\">WiFi.begin()<\/span>&nbsp;is called<\/td><\/tr><tr><td>1<\/td><td><span class=\"rnthl rntliteral\">WL_NO_SSID_AVAIL<\/span><\/td><td>&nbsp;when no SSID are available<\/td><\/tr><tr><td>2<\/td><td><span class=\"rnthl rntliteral\">WL_SCAN_COMPLETED<\/span><\/td><td>scan networks is completed<\/td><\/tr><tr><td>3<\/td><td><span class=\"rnthl rntliteral\">WL_CONNECTED<\/span><\/td><td>when connected to a WiFi network<\/td><\/tr><tr><td>4<\/td><td><span class=\"rnthl rntliteral\">WL_CONNECT_FAILED<\/span><\/td><td>when the connection fails for all the attempts<\/td><\/tr><tr><td>5<\/td><td><span class=\"rnthl rntliteral\">WL_CONNECTION_LOST<\/span><\/td><td>when the connection is lost<\/td><\/tr><tr><td>6<\/td><td><span class=\"rnthl rntliteral\">WL_DISCONNECTED<\/span><\/td><td>when disconnected from a network<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"5\">Get WiFi Connection Strength<\/h2>\n\n\n\n<p>To get the WiFi connection strength, you can simply call <span class=\"rnthl rntliteral\">WiFi.RSSI()<\/span> after a WiFi connection.<\/p>\n\n\n\n<p>Here&#8217;s an example:<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*\n  Complete details at https:\/\/RandomNerdTutorials.com\/esp32-useful-wi-fi-functions-arduino\/\n*\/\n\n#include &lt;WiFi.h&gt;\n\n\/\/ Replace with your network credentials (STATION)\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nvoid initWiFi() {\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  Serial.print(&quot;Connecting to WiFi ..&quot;);\n  while (WiFi.status() != WL_CONNECTED) {\n    Serial.print('.');\n    delay(1000);\n  }\n  Serial.println(WiFi.localIP());\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  initWiFi();\n  Serial.print(&quot;RRSI: &quot;);\n  Serial.println(WiFi.RSSI());\n}\n\nvoid loop() {\n  \/\/ put your main code here, to run repeatedly:\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_WiFi_Signal_Strength.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Insert your network credentials and upload the code.<\/p>\n\n\n\n<p>Open the Serial Monitor and press the ESP32 on-board RST button. It will connect to your network and print the RSSI (received signal strength indicator). <\/p>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"733\" height=\"541\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Get-ESP32-Wi-Fi-Connection-Strength.png?resize=733%2C541&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Get ESP32 Wi-Fi Connection Strength\" class=\"wp-image-101845\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Get-ESP32-Wi-Fi-Connection-Strength.png?w=733&amp;quality=100&amp;strip=all&amp;ssl=1 733w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/Get-ESP32-Wi-Fi-Connection-Strength.png?resize=300%2C221&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 733px) 100vw, 733px\" \/><\/figure><\/div>\n\n\n<p>A lower absolute value means a strongest Wi-Fi connection.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"6\">Get ESP32 IP Address<\/h2>\n\n\n\n<p>When the ESP32 is set as a Wi-Fi station, it can connect to other networks (like your router). In this scenario, the router assigns a unique IP address to your ESP32 board. To get your board&#8217;s IP address, you need to call <span class=\"rnthl rntliteral\">WiFi.localIP()<\/span> after establishing a connection with your network.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>Serial.println(WiFi.localIP());<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"7\">Set a Static ESP32 IP Address<\/h2>\n\n\n\n<p>Instead of getting a randomly assigned IP address, you can set an available IP address of your preference to the ESP32 using <span class=\"rnthl rntliteral\">WiFi.config()<\/span>. <\/p>\n\n\n\n<p>Outside the <span class=\"rnthl rntliteral\">setup()<\/span> and <span class=\"rnthl rntliteral\">loop()<\/span> functions, define the following variables with your own static IP address and corresponding gateway IP address. By default, the following code assigns the IP address 192.168.1.184 that works in the gateway 192.168.1.1.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Set your Static IP address\nIPAddress local_IP(192, 168, 1, 184);\n\/\/ Set your Gateway IP address\nIPAddress gateway(192, 168, 1, 1);\n\nIPAddress subnet(255, 255, 0, 0);\nIPAddress primaryDNS(8, 8, 8, 8);   \/\/ optional\nIPAddress secondaryDNS(8, 8, 4, 4); \/\/ optional<\/code><\/pre>\n\n\n\n<p>Then, in the <span class=\"rnthl rntliteral\">setup()<\/span> you need to call the <span class=\"rnthl rntliteral\">WiFi.config()<\/span> method to assign the configurations to your ESP32.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>\/\/ Configures static IP address\nif (!WiFi.config(local_IP, gateway, subnet, primaryDNS, secondaryDNS)) {\n  Serial.println(\"STA Failed to configure\");\n}<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">primaryDNS<\/span> and <span class=\"rnthl rntliteral\">secondaryDNS<\/span> parameters are optional and you can remove them.<\/p>\n\n\n\n<p>We recommend reading the following tutorial to learn how to set a static IP address:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-static-fixed-ip-address-arduino-ide\/\">ESP32 Static\/Fixed IP Address<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"8\">Disconnect from Wi-Fi Network<\/h2>\n\n\n\n<p>To disconnect from a previously connected Wi-Fi network, use <span class=\"rnthl rntliteral\">WiFi.disconnect()<\/span>:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.disconnect()<\/code><\/pre>\n\n\n<div class=\"wp-block-image is-style-default\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"750\" height=\"374\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-disconnect-Wi-Fi-Example.png?resize=750%2C374&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Disconnect From Wi-Fi Network\" class=\"wp-image-101873\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-disconnect-Wi-Fi-Example.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/02\/ESP32-disconnect-Wi-Fi-Example.png?resize=300%2C150&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\" id=\"9\">Reconnect to Wi-Fi Network After Lost Connection<\/h2>\n\n\n\n<p>To reconnect to Wi-Fi after a connection is lost, you can use <span class=\"rnthl rntliteral\">WiFi.reconnect()<\/span> to try to reconnect to the previously connected access point:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.reconnect()<\/code><\/pre>\n\n\n\n<p>Or, you can call <span class=\"rnthl rntliteral\">WiFi.disconnect()<\/span> followed by <span class=\"rnthl rntliteral\">WiFi.begin(ssid,password)<\/span>.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.disconnect();\nWiFi.begin(ssid, password);<\/code><\/pre>\n\n\n\n<p>Alternatively, you can also try to restart the ESP32 with <span class=\"rnthl rntliteral\">ESP.restart()<\/span> when the connection is lost. <\/p>\n\n\n\n<p>You can add something like the snippet below to your <span class=\"rnthl rntliteral\">loop()<\/span> that checks once in a while if the board is connected. <\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long currentMillis = millis();\n\/\/ if WiFi is down, try reconnecting\nif ((WiFi.status() != WL_CONNECTED) &amp;&amp; (currentMillis - previousMillis &gt;=interval)) {\n  Serial.print(millis());\n  Serial.println(\"Reconnecting to WiFi...\");\n  WiFi.disconnect();\n  WiFi.reconnect();\n  previousMillis = currentMillis;\n}<\/code><\/pre>\n\n\n\n<p>Don&#8217;t forget to declare the <span class=\"rnthl rntliteral\">previousMillis<\/span> and <span class=\"rnthl rntliteral\">interval<\/span> variables. The <span class=\"rnthl rntliteral\">interval<\/span> corresponds to the period of time between each check in milliseconds (for example 30 seconds):<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>unsigned long previousMillis = 0;\nunsigned long interval = 30000;<\/code><\/pre>\n\n\n\n<p>Here&#8217;s a complete example.<\/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\/solved-reconnect-esp32-to-wifi\/\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;WiFi.h&gt;\n\n\/\/ Replace with your network credentials (STATION)\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nunsigned long previousMillis = 0;\nunsigned long interval = 30000;\n\nvoid initWiFi() {\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  Serial.print(&quot;Connecting to WiFi ..&quot;);\n  while (WiFi.status() != WL_CONNECTED) {\n    Serial.print('.');\n    delay(1000);\n  }\n  Serial.println(WiFi.localIP());\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  initWiFi();\n  Serial.print(&quot;RSSI: &quot;);\n  Serial.println(WiFi.RSSI());\n}\n\nvoid loop() {\n  unsigned long currentMillis = millis();\n  \/\/ if WiFi is down, try reconnecting every CHECK_WIFI_TIME seconds\n  if ((WiFi.status() != WL_CONNECTED) &amp;&amp; (currentMillis - previousMillis &gt;=interval)) {\n    Serial.print(millis());\n    Serial.println(&quot;Reconnecting to WiFi...&quot;);\n    WiFi.disconnect();\n    WiFi.reconnect();\n    previousMillis = currentMillis;\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_Auto_Reconnect.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>This example shows how to connect to a network and checks every 30 seconds if it is still connected. If it isn&#8217;t, it disconnects and tries to reconnect again. <\/p>\n\n\n\n<p>You can read our guide: <a href=\"https:\/\/randomnerdtutorials.com\/solved-reconnect-esp32-to-wifi\/\">[SOLVED] Reconnect ESP32 to Wi-Fi Network After Lost Connection<\/a>.<\/p>\n\n\n\n<p>Alternatively, you can also use WiFi Events to detect that the connection was lost and call a function to handle what to do when that happens (see the next section).<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"10\">ESP32 Wi-Fi Events<\/h2>\n\n\n\n<p>The ESP32 can handle all the following Wi-Fi events (check the <a href=\"https:\/\/github.com\/espressif\/arduino-esp32\/blob\/master\/libraries\/WiFi\/src\/WiFiGeneric.h\" target=\"_blank\" rel=\"noopener\">source code<\/a>):<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>0<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_READY<\/span><\/td><td>ESP32 Wi-Fi ready<\/td><\/tr><tr><td>1<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_SCAN_DONE<\/span><\/td><td>ESP32 finishes scanning AP<\/td><\/tr><tr><td>2<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_START<\/span><\/td><td>ESP32 station start<\/td><\/tr><tr><td>3<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_STOP<\/span><\/td><td>ESP32 station stop<\/td><\/tr><tr><td>4<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_CONNECTED<\/span><\/td><td>ESP32 station connected to AP<\/td><\/tr><tr><td>5<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_DISCONNECTED<\/span><\/td><td>ESP32 station disconnected from AP<\/td><\/tr><tr><td>6<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE<\/span><\/td><td>the auth mode of AP connected by ESP32 station changed<\/td><\/tr><tr><td>7<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_GOT_IP<\/span><\/td><td>ESP32 station got IP from connected AP<\/td><\/tr><tr><td>8<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_LOST_IP<\/span><\/td><td>ESP32 station lost IP and the IP is reset to 0<\/td><\/tr><tr><td>9<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WPS_ER_SUCCESS<\/span><\/td><td>ESP32 station wps succeeds in enrollee mode<\/td><\/tr><tr><td>10<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WPS_ER_FAILED<\/span><\/td><td>ESP32 station wps fails in enrollee mode<\/td><\/tr><tr><td>11<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WPS_ER_TIMEOUT<\/span><\/td><td>ESP32 station wps timeout in enrollee mode<\/td><\/tr><tr><td>12<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WPS_ER_PIN<\/span><\/td><td>ESP32 station wps pin code in enrollee mode<\/td><\/tr><tr><td>13<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_START<\/span><\/td><td>ESP32 soft-AP start<\/td><\/tr><tr><td>14<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_STOP<\/span><\/td><td>ESP32 soft-AP stop<\/td><\/tr><tr><td>15<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_STACONNECTED<\/span><\/td><td>a station connected to ESP32 soft-AP<\/td><\/tr><tr><td>16<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_STADISCONNECTED<\/span><\/td><td>a station disconnected from ESP32 soft-AP<\/td><\/tr><tr><td>17<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED<\/span><\/td><td>ESP32 soft-AP assign an IP to a connected station<\/td><\/tr><tr><td>18<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED<\/span><\/td><td>Receive probe request packet in soft-AP interface<\/td><\/tr><tr><td>19<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_AP_GOT_IP6<\/span><\/td><td>ESP32 access point v6IP addr is preferred<\/td><\/tr><tr><td>19<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_GOT_IP6<\/span><\/td><td>ESP32 station v6IP addr is preferred<\/td><\/tr><tr><td>19<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_GOT_IP6<\/span><\/td><td>Ethernet IPv6 is preferred<\/td><\/tr><tr><td>20<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_START<\/span><\/td><td>ESP32 ethernet start<\/td><\/tr><tr><td>21<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_STOP<\/span><\/td><td>ESP32 ethernet stop<\/td><\/tr><tr><td>22<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_CONNECTED<\/span><\/td><td>ESP32 ethernet phy link up<\/td><\/tr><tr><td>23<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_DISCONNECTED<\/span><\/td><td>ESP32 ethernet phy link down<\/td><\/tr><tr><td>24<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_ETH_GOT_IP<\/span><\/td><td>ESP32 ethernet got IP from connected AP<\/td><\/tr><tr><td>25<\/td><td><span class=\"rnthl rntliteral\">ARDUINO_EVENT_MAX<\/span><\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>For a complete example on how to use those events, in your Arduino IDE, go to <strong>File <\/strong>&gt; <strong>Examples <\/strong>&gt; <strong>WiFi <\/strong>&gt; <strong>WiFiClientEvents<\/strong>.<\/p>\n\n\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*   This sketch shows the WiFi event usage - Example from WiFi &gt; WiFiClientEvents\n     Complete details at https:\/\/RandomNerdTutorials.com\/esp32-useful-wi-fi-functions-arduino\/  *\/\n\/*\n* WiFi Events\n\n0  ARDUINO_EVENT_WIFI_READY               &lt; ESP32 WiFi ready\n1  ARDUINO_EVENT_WIFI_SCAN_DONE                &lt; ESP32 finish scanning AP\n2  ARDUINO_EVENT_WIFI_STA_START                &lt; ESP32 station start\n3  ARDUINO_EVENT_WIFI_STA_STOP                 &lt; ESP32 station stop\n4  ARDUINO_EVENT_WIFI_STA_CONNECTED            &lt; ESP32 station connected to AP\n5  ARDUINO_EVENT_WIFI_STA_DISCONNECTED         &lt; ESP32 station disconnected from AP\n6  ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE      &lt; the auth mode of AP connected by ESP32 station changed\n7  ARDUINO_EVENT_WIFI_STA_GOT_IP               &lt; ESP32 station got IP from connected AP\n8  ARDUINO_EVENT_WIFI_STA_LOST_IP              &lt; ESP32 station lost IP and the IP is reset to 0\n9  ARDUINO_EVENT_WPS_ER_SUCCESS       &lt; ESP32 station wps succeeds in enrollee mode\n10 ARDUINO_EVENT_WPS_ER_FAILED        &lt; ESP32 station wps fails in enrollee mode\n11 ARDUINO_EVENT_WPS_ER_TIMEOUT       &lt; ESP32 station wps timeout in enrollee mode\n12 ARDUINO_EVENT_WPS_ER_PIN           &lt; ESP32 station wps pin code in enrollee mode\n13 ARDUINO_EVENT_WIFI_AP_START                 &lt; ESP32 soft-AP start\n14 ARDUINO_EVENT_WIFI_AP_STOP                  &lt; ESP32 soft-AP stop\n15 ARDUINO_EVENT_WIFI_AP_STACONNECTED          &lt; a station connected to ESP32 soft-AP\n16 ARDUINO_EVENT_WIFI_AP_STADISCONNECTED       &lt; a station disconnected from ESP32 soft-AP\n17 ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED         &lt; ESP32 soft-AP assign an IP to a connected station\n18 ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED        &lt; Receive probe request packet in soft-AP interface\n19 ARDUINO_EVENT_WIFI_AP_GOT_IP6               &lt; ESP32 ap interface v6IP addr is preferred\n19 ARDUINO_EVENT_WIFI_STA_GOT_IP6              &lt; ESP32 station interface v6IP addr is preferred\n20 ARDUINO_EVENT_ETH_START                &lt; ESP32 ethernet start\n21 ARDUINO_EVENT_ETH_STOP                 &lt; ESP32 ethernet stop\n22 ARDUINO_EVENT_ETH_CONNECTED            &lt; ESP32 ethernet phy link up\n23 ARDUINO_EVENT_ETH_DISCONNECTED         &lt; ESP32 ethernet phy link down\n24 ARDUINO_EVENT_ETH_GOT_IP               &lt; ESP32 ethernet got IP from connected AP\n19 ARDUINO_EVENT_ETH_GOT_IP6              &lt; ESP32 ethernet interface v6IP addr is preferred\n25 ARDUINO_EVENT_MAX\n*\/\n\n#include &lt;WiFi.h&gt;\n\nconst char* ssid     = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nvoid WiFiEvent(WiFiEvent_t event){\n    Serial.printf(&quot;[WiFi-event] event: %d\\n&quot;, event);\n\n    switch (event) {\n        case ARDUINO_EVENT_WIFI_READY: \n            Serial.println(&quot;WiFi interface ready&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_SCAN_DONE:\n            Serial.println(&quot;Completed scan for access points&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_START:\n            Serial.println(&quot;WiFi client started&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_STOP:\n            Serial.println(&quot;WiFi clients stopped&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_CONNECTED:\n            Serial.println(&quot;Connected to access point&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_DISCONNECTED:\n            Serial.println(&quot;Disconnected from WiFi access point&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_AUTHMODE_CHANGE:\n            Serial.println(&quot;Authentication mode of access point has changed&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_GOT_IP:\n            Serial.print(&quot;Obtained IP address: &quot;);\n            Serial.println(WiFi.localIP());\n            break;\n        case ARDUINO_EVENT_WIFI_STA_LOST_IP:\n            Serial.println(&quot;Lost IP address and IP address is reset to 0&quot;);\n            break;\n        case ARDUINO_EVENT_WPS_ER_SUCCESS:\n            Serial.println(&quot;WiFi Protected Setup (WPS): succeeded in enrollee mode&quot;);\n            break;\n        case ARDUINO_EVENT_WPS_ER_FAILED:\n            Serial.println(&quot;WiFi Protected Setup (WPS): failed in enrollee mode&quot;);\n            break;\n        case ARDUINO_EVENT_WPS_ER_TIMEOUT:\n            Serial.println(&quot;WiFi Protected Setup (WPS): timeout in enrollee mode&quot;);\n            break;\n        case ARDUINO_EVENT_WPS_ER_PIN:\n            Serial.println(&quot;WiFi Protected Setup (WPS): pin code in enrollee mode&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_START:\n            Serial.println(&quot;WiFi access point started&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_STOP:\n            Serial.println(&quot;WiFi access point  stopped&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_STACONNECTED:\n            Serial.println(&quot;Client connected&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_STADISCONNECTED:\n            Serial.println(&quot;Client disconnected&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_STAIPASSIGNED:\n            Serial.println(&quot;Assigned IP address to client&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_PROBEREQRECVED:\n            Serial.println(&quot;Received probe request&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_AP_GOT_IP6:\n            Serial.println(&quot;AP IPv6 is preferred&quot;);\n            break;\n        case ARDUINO_EVENT_WIFI_STA_GOT_IP6:\n            Serial.println(&quot;STA IPv6 is preferred&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_GOT_IP6:\n            Serial.println(&quot;Ethernet IPv6 is preferred&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_START:\n            Serial.println(&quot;Ethernet started&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_STOP:\n            Serial.println(&quot;Ethernet stopped&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_CONNECTED:\n            Serial.println(&quot;Ethernet connected&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_DISCONNECTED:\n            Serial.println(&quot;Ethernet disconnected&quot;);\n            break;\n        case ARDUINO_EVENT_ETH_GOT_IP:\n            Serial.println(&quot;Obtained IP address&quot;);\n            break;\n        default: break;\n    }}\n\nvoid WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){\n    Serial.println(&quot;WiFi connected&quot;);\n    Serial.println(&quot;IP address: &quot;);\n    Serial.println(IPAddress(info.got_ip.ip_info.ip.addr));\n}\n\nvoid setup(){\n    Serial.begin(115200);\n\n    \/\/ delete old config\n    WiFi.disconnect(true);\n\n    delay(1000);\n\n    \/\/ Examples of different ways to register wifi events\n    WiFi.onEvent(WiFiEvent);\n    WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);\n    WiFiEventId_t eventID = WiFi.onEvent([](WiFiEvent_t event, WiFiEventInfo_t info){\n        Serial.print(&quot;WiFi lost connection. Reason: &quot;);\n        Serial.println(info.wifi_sta_disconnected.reason);\n    }, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);\n\n    \/\/ Remove WiFi event\n    Serial.print(&quot;WiFi Event ID: &quot;);\n    Serial.println(eventID);\n    \/\/ WiFi.removeEvent(eventID);\n\n    WiFi.begin(ssid, password);\n\n    Serial.println();\n    Serial.println();\n    Serial.println(&quot;Wait for WiFi... &quot;);\n}\n\nvoid loop(){\n    delay(1000);\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_WiFiClientEvents.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>With Wi-Fi Events, you don&#8217;t need to be constantly checking the Wi-Fi state. When a certain event happens, it automatically calls the corresponding handling function.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"11\">Reconnect to Wi-Fi Network After Lost Connection (Wi-Fi Events)<\/h3>\n\n\n\n<p>Wi-Fi events can be useful to detect that a connection was lost and try to reconnect right after (use the <span class=\"rnthl rntliteral\">SYSTEM_EVENT_AP_STADISCONNECTED<\/span> event). Here&#8217;s a sample code:<\/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\/solved-reconnect-esp32-to-wifi\/\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;WiFi.h&gt;\n \nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nvoid WiFiStationConnected(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(&quot;Connected to AP successfully!&quot;);\n}\n\nvoid WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(&quot;WiFi connected&quot;);\n  Serial.println(&quot;IP address: &quot;);\n  Serial.println(WiFi.localIP());\n}\n\nvoid WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(&quot;Disconnected from WiFi access point&quot;);\n  Serial.print(&quot;WiFi lost connection. Reason: &quot;);\n  Serial.println(info.wifi_sta_disconnected.reason);\n  Serial.println(&quot;Trying to Reconnect&quot;);\n  WiFi.begin(ssid, password);\n}\n\nvoid setup(){\n  Serial.begin(115200);\n\n  \/\/ delete old config\n  WiFi.disconnect(true);\n\n  delay(1000);\n\n  WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);\n  WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);\n  WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);\n\n  \/* Remove WiFi event\n  Serial.print(&quot;WiFi Event ID: &quot;);\n  Serial.println(eventID);\n  WiFi.removeEvent(eventID);*\/\n\n  WiFi.begin(ssid, password);\n    \n  Serial.println();\n  Serial.println();\n  Serial.println(&quot;Wait for WiFi... &quot;);\n}\n\nvoid loop(){\n  delay(1000);\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_Network_Events_CD.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">How it Works?<\/h4>\n\n\n\n<p>In this example we&#8217;ve added three Wi-Fi events: when the ESP32 connects, when it gets an IP address, and when it disconnects: <span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_CONNECTED<\/span>, <span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_GOT_IP<\/span>, <span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_DISCONNECTED<\/span>.<\/p>\n\n\n\n<p>When the ESP32 station connects to the access point (<span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_CONNECTED<\/span> event), the <span class=\"rnthl rntliteral\">WiFiStationConnected()<\/span> function will be called:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code> WiFi.onEvent(WiFiStationConnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_CONNECTED);\n<\/code><\/pre>\n\n\n\n<p>The <span class=\"rnthl rntliteral\">WiFiStationConnected()<\/span> function simply prints that the ESP32 connected to an access point (for example, your router) successfully. However, you can modify the function to do any other task (like light up an LED to indicate that it is successfully connected to the network).<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void WiFiStationConnected(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(\"Connected to AP successfully!\");\n}<\/code><\/pre>\n\n\n\n<p>When the ESP32 gets its IP address, the <span class=\"rnthl rntliteral\">WiFiGotIP()<\/span> function runs. <\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code> WiFi.onEvent(WiFiGotIP, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_GOT_IP);\n<\/code><\/pre>\n\n\n\n<p> That function simply prints the IP address on the Serial Monitor.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void WiFiGotIP(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(\"WiFi connected\");\n  Serial.println(\"IP address: \");\n  Serial.println(WiFi.localIP());\n}<\/code><\/pre>\n\n\n\n<p>When the ESP32 loses the connection with the access point (<span class=\"rnthl rntliteral\">ARDUINO_EVENT_WIFI_STA_DISCONNECTED<\/span>), the <span class=\"rnthl rntliteral\">WiFiStationDisconnected()<\/span> function is called.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code> WiFi.onEvent(WiFiStationDisconnected, WiFiEvent_t::ARDUINO_EVENT_WIFI_STA_DISCONNECTED);\n<\/code><\/pre>\n\n\n\n<p>That function prints a message indicating that the connection was lost and tries to reconnect:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>void WiFiStationDisconnected(WiFiEvent_t event, WiFiEventInfo_t info){\n  Serial.println(\"Disconnected from WiFi access point\");\n  Serial.print(\"WiFi lost connection. Reason: \");\n  Serial.println(info.wifi_sta_disconnected.reason);\n  Serial.println(\"Trying to Reconnect\");\n  WiFi.begin(ssid, password);\n}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"WiFiMulti\">ESP32 WiFiMulti<\/h2>\n\n\n\n<p>The ESP32 WiFiMulti allows you to register multiple networks (SSID\/password combinations). The ESP32 will connect to the Wi-Fi network with the strongest signal (RSSI). If the connection is lost, it will connect to the next network on the list. This requires that you include the <span class=\"rnthl rntliteral\">WiFiMulti.h<\/span> library (you don&#8217;t need to install it, it comes by default with the ESP32 package).<\/p>\n\n\n\n<p>To learn how to use WiFiMulti, read the following tutorial:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/esp32-wifimulti\/\">ESP32 WiFiMulti: Connect to the Strongest Wi-Fi Network (from a list of networks)<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"hostname\">Change ESP32 Hostname<\/h2>\n\n\n\n<p>To set a custom hostname for your board, call <span class=\"rnthl rntliteral\">WiFi.setHostname(YOUR_NEW_HOSTNAME);<\/span> before <span class=\"rnthl rntliteral\">WiFi.begin();<\/span><\/p>\n\n\n\n<p>The default ESP32 hostname is <span class=\"rnthl rntliteral\">espressif<\/span>. <\/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=\"976\" height=\"48\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-default-hostname-f.png?resize=976%2C48&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" class=\"wp-image-103186\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-default-hostname-f.png?w=976&amp;quality=100&amp;strip=all&amp;ssl=1 976w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-default-hostname-f.png?resize=300%2C15&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-default-hostname-f.png?resize=768%2C38&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 976px) 100vw, 976px\" \/><\/figure><\/div>\n\n\n<p>There is a method provided by the <span class=\"rnthl rntliteral\">WiFi.h<\/span> library that allows you to set a custom hostname. <\/p>\n\n\n\n<p>First, start by defining your new hostname. For example:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>String hostname = \"ESP32 Node Temperature\";<\/code><\/pre>\n\n\n\n<p>Then, call the <span class=\"rnthl rntliteral\">WiFi.setHostname()<\/span> function before calling <span class=\"rnthl rntliteral\">WiFi.begin()<\/span>. You also need to call <span class=\"rnthl rntliteral\">WiFi.config()<\/span> as shown below:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);\nWiFi.setHostname(hostname.c_str()); \/\/define hostname<\/code><\/pre>\n\n\n\n<p>You can copy the complete example below:<\/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\/esp32-set-custom-hostname-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\n\/\/ Replace with your network credentials\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\/\/ Change the hostname\nconst char* hostname = &quot;esp32-node-temperature&quot;;\n\nvoid initWiFi() {\n  WiFi.mode(WIFI_STA);\n  WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE, INADDR_NONE);\n  WiFi.setHostname(hostname);\n\n  WiFi.begin(ssid, password);\n  Serial.print(&quot;Connecting to WiFi...&quot;);\n  while (WiFi.status() != WL_CONNECTED) {\n    Serial.print('.');\n    delay(1000);\n  }\n  \n  Serial.print(&quot;\\nESP32 IP Address: &quot;);\n  Serial.println(WiFi.localIP());\n  Serial.print(&quot;ESP32 HostName: &quot;);\n  Serial.println(WiFi.getHostname());\n  Serial.print(&quot;RRSI: &quot;);\n  Serial.println(WiFi.RSSI());\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  initWiFi();\n}\n\nvoid loop() {\n  \/\/ put your main code here, to run repeatedly:\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_Set_Hostname.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>You can use this previous snippet of code in your projects to set a custom hostname for the ESP32.<\/p>\n\n\n\n<p class=\"rntbox rntcred\"><strong>Important: <\/strong> you may need to restart your router for the changes to take effect.<\/p>\n\n\n\n<p>After this, if you go to your router settings, you&#8217;ll see the ESP32 with the custom hostname.<\/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=\"964\" height=\"47\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-Custom-Hostname.jpg?resize=964%2C47&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Custom Hostname setting Arduino IDE\" class=\"wp-image-103160\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-Custom-Hostname.jpg?w=964&amp;quality=100&amp;strip=all&amp;ssl=1 964w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-Custom-Hostname.jpg?resize=300%2C15&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/04\/ESP32-Custom-Hostname.jpg?resize=768%2C37&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 964px) 100vw, 964px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>This article was a compilation of some of the most used and useful ESP32 Wi-Fi functions. Although there are plenty of examples of using the ESP32 Wi-Fi capabilities, there is little documentation explaining how to use the Wi-Fi functions with the ESP32 using Arduino IDE. So, we\u2019ve decided to put together this guide to make it easier to use ESP32 Wi-Fi-related functions in your projects.<\/p>\n\n\n\n<p>If you have other suggestions, you can share them in the comments section. <\/p>\n\n\n\n<p>We hope you\u2019ve found this tutorial useful.<\/p>\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\/build-web-servers-esp32-esp8266-ebook\/\">Build Web Servers with ESP32 and ESP8266<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">More ESP32 Projects and Tutorials\u2026<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>This article is a compilation of useful Wi-Fi functions for the ESP32. We&#8217;ll cover the following topics: scan Wi-Fi networks, connect to a Wi-Fi network, get Wi-Fi connection strength, check &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 Useful Wi-Fi Library Functions (Arduino IDE)\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-useful-wi-fi-functions-arduino\/#more-101782\" aria-label=\"Read more about ESP32 Useful Wi-Fi Library Functions (Arduino IDE)\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":101839,"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-101782","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\/2021\/02\/ESP32-Useful-WiFi-Functions-Guide-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\/101782","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=101782"}],"version-history":[{"count":6,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/101782\/revisions"}],"predecessor-version":[{"id":127966,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/101782\/revisions\/127966"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/101839"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=101782"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=101782"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=101782"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}