{"id":164492,"date":"2024-12-17T18:49:51","date_gmt":"2024-12-17T18:49:51","guid":{"rendered":"https:\/\/randomnerdtutorials.com\/?p=164492"},"modified":"2025-03-24T11:44:47","modified_gmt":"2025-03-24T11:44:47","slug":"esp32-ota-elegantota-arduino","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp32-ota-elegantota-arduino\/","title":{"rendered":"ESP32 OTA (Over-the-Air) Updates \u2013  ElegantOTA Library with Arduino IDE"},"content":{"rendered":"\n<p>This tutorial shows how to do OTA (over-the-air) updates to your ESP32 boards using the ElegantOTA library (V3 version) with Arduino IDE. This library sets up a web server that lets you update the firmware (a new sketch) on your board wirelessly. This way, you don&#8217;t need a connection between the ESP32 and your computer to upload a new sketch. This library also allows uploading files to the filesystem (LittleFS or SPIFFS) wirelessly.<\/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\/2024\/12\/ESP32-ElegantOTA-Arduino-IDE.jpg?resize=1200%2C675&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 OTA (Over-the-Air) Updates \u2013  ElegantOTA Library with Arduino IDE\" class=\"wp-image-164531\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-ElegantOTA-Arduino-IDE.jpg?w=1920&amp;quality=100&amp;strip=all&amp;ssl=1 1920w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-ElegantOTA-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\/2024\/12\/ESP32-ElegantOTA-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\/2024\/12\/ESP32-ElegantOTA-Arduino-IDE.jpg?resize=768%2C432&amp;quality=100&amp;strip=all&amp;ssl=1 768w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-ElegantOTA-Arduino-IDE.jpg?resize=1536%2C864&amp;quality=100&amp;strip=all&amp;ssl=1 1536w\" sizes=\"(max-width: 1200px) 100vw, 1200px\" \/><\/figure><\/div>\n\n\n<p>By the end of this tutorial, you\u2019ll be able to easily add OTA capabilities to your web server projects with the ESP32 to upload new firmware and files to the filesystem wirelessly in the future.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Table Of Contents<\/h2>\n\n\n\n<p>Throughout this tutorial, we&#8217;ll cover:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"#elegant-ota-usage\" title=\"\">Add the ElegantOTA feature to your web server<\/a><\/li>\n\n\n\n<li><a href=\"#upload-new-firmware-ota\" title=\"\">Upload new firmware via OTA to the ESP32 board<\/a><\/li>\n\n\n\n<li><a href=\"#upload-files-littlefs-filesystem-ota\" title=\"\">Upload files to LittleFS via OTA to the ESP32 board<\/a><\/li>\n<\/ul>\n\n\n\n<p>We recommend that you follow all the tutorial steps to understand how the <a href=\"https:\/\/github.com\/ayushsharma82\/ElegantOTA\" target=\"_blank\" rel=\"noopener\" title=\"\">ElegantOTA library<\/a> works and how you can use it in your projects. To demonstrate how to do this, we\u2019ll upload files to build different web server projects.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">ESP32 OTA (Over-the-Air) Programming<\/h2>\n\n\n\n<p>OTA (Over-the-Air) update is the process of loading new firmware to the ESP32 board using a Wi-Fi connection rather than a serial communication. This functionality is extremely useful in case of no physical access to the ESP32 board. You don&#8217;t need a connection between your computer and the board to upload new code.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"751\" height=\"370\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/Async-Elegant-OTA-Web-Server-ESP32-How-it-Works.png?resize=751%2C370&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Async ElegantOTA Web Server How it Works ESP32\" class=\"wp-image-101670\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/Async-Elegant-OTA-Web-Server-ESP32-How-it-Works.png?w=751&amp;quality=100&amp;strip=all&amp;ssl=1 751w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2021\/01\/Async-Elegant-OTA-Web-Server-ESP32-How-it-Works.png?resize=300%2C148&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 751px) 100vw, 751px\" \/><\/figure><\/div>\n\n\n<p>There are different ways to perform OTA updates. In this tutorial, we\u2019ll cover how to do that using the <a href=\"https:\/\/github.com\/ayushsharma82\/ElegantOTA\" target=\"_blank\" rel=\"noopener\" title=\"\">ElegantOTA library<\/a> (version V3 \u2014 this is the successor of the deprecated <a href=\"https:\/\/randomnerdtutorials.com\/esp32-ota-over-the-air-arduino\/\" target=\"_blank\" rel=\"noopener\" title=\"\">AsyncElegantOTA library<\/a>). In our opinion, this is one of the best and easiest ways to perform OTA updates.<\/p>\n\n\n\n<p>The ElegantOTA library creates a web server that you can access on your local network to upload new firmware or files to the filesystem (SPIFFS or LittleFS). The files you upload should be in <em>.bin<\/em> format. We\u2019ll show you later in this tutorial how to convert your files to <em>.bin<\/em> format.<\/p>\n\n\n\n<p>The only disadvantage of OTA programming is that you need to add the code for OTA in every sketch you upload so that you\u2019re able to use OTA in the future. In case of the ElegantOTA library, it consists of just three lines of code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"elegant-ota-usage\">ElegantOTA Library<\/h2>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"796\" height=\"190\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-logo.png?resize=796%2C190&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ElegantOTA logo\" class=\"wp-image-164532\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-logo.png?w=796&amp;quality=100&amp;strip=all&amp;ssl=1 796w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-logo.png?resize=300%2C72&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-logo.png?resize=768%2C183&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 796px) 100vw, 796px\" \/><\/figure><\/div>\n\n\n<p>Here are some great features of this library:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>It is compatible with the built-in <span class=\"rnthl rntliteral\">WebServer.h<\/span> library and with several forks of the <span class=\"rnthl rntliteral\">ESPAsyncWebServer<\/span> library.<\/li>\n\n\n\n<li>You just need to add three lines of code to add OTA capabilities to your \u201cregular\u201d web server;<\/li>\n\n\n\n<li>It allows you to update not only new firmware to the board but also files to the ESP32 filesystem (LittleFS or SPIFFS);<\/li>\n\n\n\n<li>It provides a beautiful and modern web server interface;<\/li>\n\n\n\n<li>It is available as a pro paid version that adds more features.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">OTA Updates with the ElegantOTA Library &#8211; Quick Summary<\/h3>\n\n\n\n<p>To add OTA capabilities to your projects using the ElegantOTA library, follow these steps:<\/p>\n\n\n\n<p><strong>1) <\/strong>Install the <a href=\"https:\/\/github.com\/ayushsharma82\/ElegantOTA\" target=\"_blank\" rel=\"noopener\" title=\"\">ElegantOTA<\/a>, <a href=\"https:\/\/github.com\/ESP32Async\/AsyncTCP\" target=\"_blank\" rel=\"noopener\" title=\"\">AsyncTCP<\/a>, and <a href=\"https:\/\/github.com\/ESP32Async\/ESPAsyncWebServer\" target=\"_blank\" rel=\"noopener\" title=\"\">ESPAsyncWebServer <\/a>libraries;<\/p>\n\n\n\n<p><strong>2)<\/strong> Include ElegantOTA library at the top of the Arduino sketch:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code><span class=\"rnthl rntliteral\">#include &lt;ElegantOTA.h&gt;;<\/span><\/code><\/pre>\n\n\n\n<p><strong>3)<\/strong> Add the following line in the setup before <span class=\"rnthl rntliteral\">server.begin();<\/span><\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.begin(&amp;server);<\/code><\/pre>\n\n\n\n<p><strong>4)<\/strong> In the <span class=\"rnthl rntliteral\">loop()<\/span>, add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.loop();<\/code><\/pre>\n\n\n\n<p><strong>5)<\/strong> Open your browser and go to <span class=\"rnthl rntliteral\">http:\/\/&lt;IPAddress&gt;\/update<\/span>, where <span class=\"rnthl rntliteral\">&lt;IPAddress&gt;<\/span> is your ESP32 IP address to access the web server page for the OTA updates.<\/p>\n\n\n\n<p>Continue reading the tutorial for more detailed steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">How does OTA Web Updater Work?<\/h3>\n\n\n\n<p>The first sketch must be uploaded using a serial connection. This sketch should include the code to set up the OTA Web Updater, allowing you to upload new sketches through a web browser.<\/p>\n\n\n\n<p>The OTA Web Updater creates a web server where you can upload sketches wirelessly.<\/p>\n\n\n\n<p>If your code doesn\u2019t include an OTA routine, you won\u2019t be able to use the web server to upload new sketches wirelessly.<\/p>\n\n\n\n<p>After that, make sure every sketch you upload includes OTA routines so you can continue updating the board wirelessly in the future.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Installing the ElegantOTA Library<\/h2>\n\n\n\n<p><a href=\"https:\/\/randomnerdtutorials.com\/installing-esp32-arduino-ide-2-0\/\">Having the ESP32 Board installed in your Arduino IDE<\/a>, you also need to install the ElegantOTA library in the Arduino IDE go to <strong>Sketch <\/strong>> <strong>Include Library<\/strong> > <strong>Manage Libraries<\/strong>, search for <strong>ElegantOTA <\/strong>and install the <em>ElegantOTA library by Ayush Sharma<\/em>.<\/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=\"877\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/install-elegantota-library-Arduino-IDE.png?resize=877%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing ElegantOTA Library Arduino IDE\" class=\"wp-image-164503\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/install-elegantota-library-Arduino-IDE.png?w=877&amp;quality=100&amp;strip=all&amp;ssl=1 877w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/install-elegantota-library-Arduino-IDE.png?resize=300%2C200&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/install-elegantota-library-Arduino-IDE.png?resize=768%2C513&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 877px) 100vw, 877px\" \/><\/figure><\/div>\n\n\n<h3 class=\"wp-block-heading\">Enabling Async Mode<\/h3>\n\n\n\n<p>For the ElegantOTA library to work in async mode (with the ESPAsyncWebServer library), you need to do the following procedure.<\/p>\n\n\n\n<p><strong>1)<\/strong> Go to your Arduino <em>libraries <\/em>directory.<\/p>\n\n\n\n<p><strong>2)<\/strong> Open the <em>ElegantOTA<\/em> folder and then open the <em>src <\/em>folder.<\/p>\n\n\n\n<p><strong>3)<\/strong> Locate the <span class=\"rnthl rntliteral\">ELEGANTOTA_USE_ASYNC_WEBSERVER<\/span> macro in the <em>ElegantOTA.h<\/em> file, and set it to <span class=\"rnthl rntliteral\">1<\/span> as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#define ELEGANTOTA_USE_ASYNC_WEBSERVER 1<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"711\" height=\"357\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-set-async-mode.png?resize=711%2C357&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"elegantota library enable async mode\" class=\"wp-image-164505\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-set-async-mode.png?w=711&amp;quality=100&amp;strip=all&amp;ssl=1 711w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-set-async-mode.png?resize=300%2C151&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 711px) 100vw, 711px\" \/><\/figure><\/div>\n\n\n<p><strong>4)<\/strong> Save the changes to the <em>ElegantOTA.h<\/em> file.<\/p>\n\n\n\n<p><strong>5)<\/strong> Now you can use the ElegantOTA in async mode for your OTA updates and with the  ESPAsyncWebServer library.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Install AsyncTCP and ESPAsyncWebServer Libraries<\/h3>\n\n\n\n<p>To test the examples in this tutorial, you also need to install the AsyncTCP and the ESPAsyncWebServer libraries.<\/p>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>Note:<\/strong> the ElegantOTA library works with different forked versions of the ESPAsyncWebServer and the AsyncTCP web server libraries, so you don&#8217;t necessarily need to use the same ones that we&#8217;re using.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Async Web Server Libraries<\/h3>\n\n\n\n<p>We&#8217;ll build the web server using the following libraries:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/github.com\/ESP32Async\/ESPAsyncWebServer\" target=\"_blank\" rel=\"noopener\" title=\"\">ESPAsyncWebServer&nbsp;<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/ESP32Async\/AsyncTCP\" target=\"_blank\" rel=\"noopener\" title=\"\">AsyncTCP<\/a><\/li>\n<\/ul>\n\n\n\n<p>You can install these libraries in the Arduino Library Manager. Open the Library Manager by clicking the Library icon at the left sidebar.<\/p>\n\n\n\n<p>Search for <span class=\"rnthl rntliteral\">ESPAsyncWebServer<\/span> and install the <strong>ESPAsyncWebServer by ESP32Async<\/strong>.<\/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=\"666\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?resize=666%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing ESPAsyncWebServer ESP32 Arduino IDE\" class=\"wp-image-167890\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?w=666&amp;quality=100&amp;strip=all&amp;ssl=1 666w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-ESPAsyncWebServer-Library-ArduinoIDE-2-f.png?resize=300%2C264&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 666px) 100vw, 666px\" \/><\/figure><\/div>\n\n\n<p>Then, install the AsyncTCP library. Search for <span class=\"rnthl rntliteral\">AsyncTCP<\/span> and install the <strong>AsyncTCP by ESP32Async<\/strong>.<\/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=\"722\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?resize=722%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Installing AsyncTCP ESP32 Arduino IDE\" class=\"wp-image-167886\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?w=722&amp;quality=100&amp;strip=all&amp;ssl=1 722w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/06\/Install-AsyncTCP-Library-ArduinoIDE.png?resize=300%2C243&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 722px) 100vw, 722px\" \/><\/figure><\/div>\n\n\n<h2 class=\"wp-block-heading\" id=\"1-basic-elegantota\">ElegantOTA ESP32 Basic Example<\/h2>\n\n\n\n<p>Let\u2019s start with a basic example (based on one of the library&#8217;s examples). The following code creates a simple web server with the ESP32. The root URL displays some text, and the&nbsp;<strong>\/update<\/strong>&nbsp;URL displays the interface to update the firmware and the filesystem.<\/p>\n\n\n\n<p>Copy the following code to your Arduino IDE.<\/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-ota-elegantota-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Softwar\n*********\/\n\n#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &lt;ElegantOTA.h&gt;\n\nconst char* ssid = &quot;REPLACE_WITH_YOUR_SSID&quot;;\nconst char* password = &quot;REPLACE_WITH_YOUR_PASSWORD&quot;;\n\nAsyncWebServer server(80);\n\nvoid setup(void) {\n  Serial.begin(115200);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  Serial.println(&quot;&quot;);\n\n  \/\/ Wait for connection\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(500);\n    Serial.print(&quot;.&quot;);\n  }\n  Serial.println(&quot;&quot;);\n  Serial.print(&quot;Connected to &quot;);\n  Serial.println(ssid);\n  Serial.print(&quot;IP address: &quot;);\n  Serial.println(WiFi.localIP());\n\n  server.on(&quot;\/&quot;, HTTP_GET, [](AsyncWebServerRequest *request) {\n    request-&gt;send(200, &quot;text\/plain&quot;, &quot;Hi! I am ESP32.&quot;);\n  });\n\n  server.begin();\n  Serial.println(&quot;HTTP server started&quot;);\n\n  ElegantOTA.begin(&amp;server);    \/\/ Start ElegantOTA\n}\n\nvoid loop(void) {\n  ElegantOTA.loop();\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\/ElegantOTA\/ElegantOTA_Basic.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>Insert your network credentials and the code should work straight away.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">How Does the Code Work?<\/h3>\n\n\n\n<p>Start by including the required libraries.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &lt;ElegantOTA.h&gt;<\/code><\/pre>\n\n\n\n<p>Insert your network credentials in the following variables so that the ESP32 can connect to the Wi-Fi on your local network.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<p>Create an <span class=\"rnthl rntliteral\">AsyncWebServer<\/span> object on port 80:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>AsyncWebServer server(80);<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">setup()<\/span>, initialize 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>Initialize Wi-Fi:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>WiFi.mode(WIFI_STA);\nWiFi.begin(ssid, password);\nSerial.println(\"\");\n\n\/\/ Wait for connection\nwhile (WiFi.status() != WL_CONNECTED) {\n  delay(500);\n  Serial.print(\".\");\n}\nSerial.println(\"\");\nSerial.print(\"Connected to \");\nSerial.println(ssid);\nSerial.print(\"IP address: \");\nSerial.println(WiFi.localIP());<\/code><\/pre>\n\n\n\n<p>Then, handle the client requests. The following lines, send some text <span class=\"rnthl rntliteral\">Hi! I am ESP32.<\/span> when you access the root (<span class=\"rnthl rntliteral\">\/<\/span>) URL:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.on(\"\/\", HTTP_GET, &#091;](AsyncWebServerRequest *request) {\n  request-&gt;send(200, \"text\/plain\", \"Hi! I am ESP32.\");\n});<\/code><\/pre>\n\n\n\n<p>If your web server needs to handle more requests you can add them (we&#8217;ll show you in the next example).<\/p>\n\n\n\n<p>Initialize the server:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>server.begin();<\/code><\/pre>\n\n\n\n<p>Then, add the next line to start ElegantOTA:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.begin(&amp;server);    \/\/ Start ElegantOTA<\/code><\/pre>\n\n\n\n<p>In the <span class=\"rnthl rntliteral\">loop()<\/span>, add the following line:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.loop();<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Accessing the Web Server<\/h2>\n\n\n\n<p>After uploading code to the board, open the Serial Monitor at a baud rate of 115200. Press the ESP32 on-board RST button. It should display the ESP IP address as follows (yours may be different):<\/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=\"678\" height=\"345\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantOTA-web-server-ip-address.png?resize=678%2C345&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ElegantOTA Web Server Getting the IP Address Serial Monitor\" class=\"wp-image-164506\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantOTA-web-server-ip-address.png?w=678&amp;quality=100&amp;strip=all&amp;ssl=1 678w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantOTA-web-server-ip-address.png?resize=300%2C153&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 678px) 100vw, 678px\" \/><\/figure><\/div>\n\n\n<p>In your local network, open your browser and type the ESP32 IP address. You should get access the root (<span class=\"rnthl rntliteral\">\/<\/span>) web page with some text displayed.<\/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=\"667\" height=\"362\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/async-web-server-with-OTA.png?resize=667%2C362&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Web Server Basic OTA \" class=\"wp-image-164507\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/async-web-server-with-OTA.png?w=667&amp;quality=100&amp;strip=all&amp;ssl=1 667w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/async-web-server-with-OTA.png?resize=300%2C163&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 667px) 100vw, 667px\" \/><\/figure><\/div>\n\n\n<p>Now, if you want to modify your web server code via OTA, go to the ESP IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span>. The following web page should load.<\/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=\"907\" height=\"666\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-elegant-ota-webserver.png?resize=907%2C666&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ElegantOTA Web Server Page ESP32\" class=\"wp-image-164508\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-elegant-ota-webserver.png?w=907&amp;quality=100&amp;strip=all&amp;ssl=1 907w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-elegant-ota-webserver.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-elegant-ota-webserver.png?resize=768%2C564&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/figure><\/div>\n\n\n<p>To upload new code to your board or files to the filesystem, you need to upload them in <em>.bin<\/em> format. Follow the next section to learn how to generate a <em>.bin<\/em> file from your sketch in Arduino IDE.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"upload-new-firmware-ota\">Upload New Code to the ESP32 via OTA<\/h2>\n\n\n\n<p>Every file that you upload via OTA should be in&nbsp;<em>.bin<\/em>&nbsp;format. You can generate a&nbsp;<em>.bin<\/em>&nbsp;file from your sketch using the Arduino IDE.<\/p>\n\n\n\n<p>With your sketch opened, you just need to select the ESP32 board you&#8217;re using in <strong>Tools<\/strong> &gt; <strong>Board<\/strong>, and then go to&nbsp;<strong>Sketch&nbsp;<\/strong>&gt;&nbsp;<strong>Export Compiled Binary<\/strong>. A&nbsp;<em>.bin<\/em>&nbsp;file will be generated from your sketch.<\/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=\"383\" height=\"272\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=383%2C272&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE export bin file\" class=\"wp-image-164549\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?w=383&amp;quality=100&amp;strip=all&amp;ssl=1 383w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=300%2C213&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/figure><\/div>\n\n\n<p>The generated file will be saved under your project folder inside a series of other folders. The file with the <em>.ino.bin<\/em>&nbsp;extension is the one you should upload to your board using the ElegantOTA web page.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Upload a New Web Server Sketch via OTA &#8211; Example<\/h3>\n\n\n\n<p>Imagine that after uploading the previous sketch, you want to upload a new one that allows you to control an LED via a web interface like <a href=\"https:\/\/randomnerdtutorials.com\/esp32-websocket-server-arduino\/\">this project<\/a>. Here&#8217;s the steps you need to follow:<\/p>\n\n\n\n<p>1. Copy the following code to your Arduino IDE. Don&#8217;t forget to insert your network credentials.<\/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-ota-elegantota-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Softwar\n*********\/\n\n\/\/ Import required libraries\n#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &lt;ElegantOTA.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\nbool ledState = 0;\nconst int ledPin = 2;\n\n\/\/ Create AsyncWebServer object on port 80\nAsyncWebServer server(80);\nAsyncWebSocket ws(&quot;\/ws&quot;);\n\nconst char index_html[] PROGMEM = R&quot;rawliteral(\n&lt;!DOCTYPE HTML&gt;&lt;html&gt;\n&lt;head&gt;\n  &lt;title&gt;ESP Web Server&lt;\/title&gt;\n  &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n  &lt;link rel=&quot;icon&quot; href=&quot;data:,&quot;&gt;\n  &lt;style&gt;\n  html {\n    font-family: Arial, Helvetica, sans-serif;\n    text-align: center;\n  }\n  h1 {\n    font-size: 1.8rem;\n    color: white;\n  }\n  h2{\n    font-size: 1.5rem;\n    font-weight: bold;\n    color: #143642;\n  }\n  .topnav {\n    overflow: hidden;\n    background-color: #143642;\n  }\n  body {\n    margin: 0;\n  }\n  .content {\n    padding: 30px;\n    max-width: 600px;\n    margin: 0 auto;\n  }\n  .card {\n    background-color: #F8F7F9;;\n    box-shadow: 2px 2px 12px 1px rgba(140,140,140,.5);\n    padding-top:10px;\n    padding-bottom:20px;\n  }\n  .button {\n    padding: 15px 50px;\n    font-size: 24px;\n    text-align: center;\n    outline: none;\n    color: #fff;\n    background-color: #0f8b8d;\n    border: none;\n    border-radius: 5px;\n    -webkit-touch-callout: none;\n    -webkit-user-select: none;\n    -khtml-user-select: none;\n    -moz-user-select: none;\n    -ms-user-select: none;\n    user-select: none;\n    -webkit-tap-highlight-color: rgba(0,0,0,0);\n   }\n   \/*.button:hover {background-color: #0f8b8d}*\/\n   .button:active {\n     background-color: #0f8b8d;\n     box-shadow: 2 2px #CDCDCD;\n     transform: translateY(2px);\n   }\n   .state {\n     font-size: 1.5rem;\n     color:#8c8c8c;\n     font-weight: bold;\n   }\n  &lt;\/style&gt;\n&lt;title&gt;ESP Web Server&lt;\/title&gt;\n&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt;\n&lt;link rel=&quot;icon&quot; href=&quot;data:,&quot;&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n  &lt;div class=&quot;topnav&quot;&gt;\n    &lt;h1&gt;ESP WebSocket Server&lt;\/h1&gt;\n  &lt;\/div&gt;\n  &lt;div class=&quot;content&quot;&gt;\n    &lt;div class=&quot;card&quot;&gt;\n      &lt;h2&gt;Output - GPIO 2&lt;\/h2&gt;\n      &lt;p class=&quot;state&quot;&gt;state: &lt;span id=&quot;state&quot;&gt;%STATE%&lt;\/span&gt;&lt;\/p&gt;\n      &lt;p&gt;&lt;button id=&quot;button&quot; class=&quot;button&quot;&gt;Toggle&lt;\/button&gt;&lt;\/p&gt;\n    &lt;\/div&gt;\n  &lt;\/div&gt;\n&lt;script&gt;\n  var gateway = `ws:\/\/${window.location.hostname}\/ws`;\n  var websocket;\n  window.addEventListener('load', onLoad);\n  function initWebSocket() {\n    console.log('Trying to open a WebSocket connection...');\n    websocket = new WebSocket(gateway);\n    websocket.onopen    = onOpen;\n    websocket.onclose   = onClose;\n    websocket.onmessage = onMessage; \/\/ &lt;-- add this line\n  }\n  function onOpen(event) {\n    console.log('Connection opened');\n  }\n  function onClose(event) {\n    console.log('Connection closed');\n    setTimeout(initWebSocket, 2000);\n  }\n  function onMessage(event) {\n    var state;\n    if (event.data == &quot;1&quot;){\n      state = &quot;ON&quot;;\n    }\n    else{\n      state = &quot;OFF&quot;;\n    }\n    document.getElementById('state').innerHTML = state;\n  }\n  function onLoad(event) {\n    initWebSocket();\n    initButton();\n  }\n  function initButton() {\n    document.getElementById('button').addEventListener('click', toggle);\n  }\n  function toggle(){\n    websocket.send('toggle');\n  }\n&lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;)rawliteral&quot;;\n\nvoid notifyClients() {\n  ws.textAll(String(ledState));\n}\n\nvoid handleWebSocketMessage(void *arg, uint8_t *data, size_t len) {\n  AwsFrameInfo *info = (AwsFrameInfo*)arg;\n  if (info-&gt;final &amp;&amp; info-&gt;index == 0 &amp;&amp; info-&gt;len == len &amp;&amp; info-&gt;opcode == WS_TEXT) {\n    data[len] = 0;\n    if (strcmp((char*)data, &quot;toggle&quot;) == 0) {\n      ledState = !ledState;\n      notifyClients();\n    }\n  }\n}\n\nvoid onEvent(AsyncWebSocket *server, AsyncWebSocketClient *client, AwsEventType type,\n             void *arg, uint8_t *data, size_t len) {\n  switch (type) {\n    case WS_EVT_CONNECT:\n      Serial.printf(&quot;WebSocket client #%u connected from %s\\n&quot;, client-&gt;id(), client-&gt;remoteIP().toString().c_str());\n      break;\n    case WS_EVT_DISCONNECT:\n      Serial.printf(&quot;WebSocket client #%u disconnected\\n&quot;, client-&gt;id());\n      break;\n    case WS_EVT_DATA:\n      handleWebSocketMessage(arg, data, len);\n      break;\n    case WS_EVT_PONG:\n    case WS_EVT_ERROR:\n      break;\n  }\n}\n\nvoid initWebSocket() {\n  ws.onEvent(onEvent);\n  server.addHandler(&amp;ws);\n}\n\nString processor(const String&amp; var){\n  Serial.println(var);\n  if(var == &quot;STATE&quot;){\n    if (ledState){\n      return &quot;ON&quot;;\n    }\n    else{\n      return &quot;OFF&quot;;\n    }\n  }\n  return String();\n}\n\nvoid setup(){\n  \/\/ Serial port for debugging purposes\n  Serial.begin(115200);\n\n  pinMode(ledPin, OUTPUT);\n  digitalWrite(ledPin, LOW);\n  \n  \/\/ Connect to Wi-Fi\n  WiFi.begin(ssid, password);\n  while (WiFi.status() != WL_CONNECTED) {\n    delay(1000);\n    Serial.println(&quot;Connecting to WiFi..&quot;);\n  }\n\n  \/\/ Print ESP Local IP Address\n  Serial.println(WiFi.localIP());\n\n  initWebSocket();\n\n  \/\/ Route for root \/ web page\n  server.on(&quot;\/&quot;, HTTP_GET, [](AsyncWebServerRequest *request){\n    request-&gt;send(200, &quot;text\/html&quot;, index_html, processor);\n  });\n\n  \/\/ Start server\n  server.begin();\n\n  ElegantOTA.begin(&amp;server);    \/\/ Start ElegantOTA\n\n}\n\nvoid loop() {\n  ws.cleanupClients();\n  digitalWrite(ledPin, ledState);\n  ElegantOTA.loop();\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\/ElegantOTA\/ESP32_WebServer_LED_ElegantOTA.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p>This is the same code used in <a href=\"https:\/\/randomnerdtutorials.com\/esp32-websocket-server-arduino\/\">this project<\/a>, but it contains the needed lines of code to handle ElegantOTA:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include &lt;ElegantOTA.h&gt;<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.begin(&amp;server);<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>ElegantOTA.loop();<\/code><\/pre>\n\n\n\n<p><strong>2. <\/strong>Save your sketch: <strong>File<\/strong> &gt; <strong>Save <\/strong>and give it a name. For example: <em>Web_Server_LED_OTA_ESP32<\/em>.<\/p>\n\n\n\n<p><strong>3.<\/strong> Generate a <em>.bin<\/em> file from your sketch. First, select the board model you&#8217;re using in <strong>Tools<\/strong> &gt; <strong>Board<\/strong>. Then, go to <strong>Sketch <\/strong>&gt; <strong>Export Compiled Binary<\/strong>.<\/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=\"383\" height=\"272\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=383%2C272&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE, expor bin file\" class=\"wp-image-164549\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?w=383&amp;quality=100&amp;strip=all&amp;ssl=1 383w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=300%2C213&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/figure><\/div>\n\n\n<p>Go to your sketch folder. You should have a <em>build<\/em> folder. Inside that folder, you&#8217;ll have another folder related to your board model. Open that folder. There&#8217;ll be several files. You should upload the file with the <em>ino.bin<\/em> extension.<\/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=\"908\" height=\"365\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-bin-file-to-upload.jpg?resize=908%2C365&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"bin file for ESP32 OTA updates\" class=\"wp-image-164511\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-bin-file-to-upload.jpg?w=908&amp;quality=100&amp;strip=all&amp;ssl=1 908w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-bin-file-to-upload.jpg?resize=300%2C121&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-bin-file-to-upload.jpg?resize=768%2C309&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 908px) 100vw, 908px\" \/><\/figure><\/div>\n\n\n<p><strong>4.<\/strong> Now, you need to upload that file using the ElegantOTA page. Go to your ESP IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span>. Make sure you have the <strong>firmware<\/strong> option selected. Click on <strong>Choose File<\/strong> and select the <em>.ino.bin<\/em> file you&#8217;ve just generated.<\/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=\"907\" height=\"666\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-ESP32-uploading-new-file-ota.png?resize=907%2C666&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ElegantOTA Uploading new firmware\" class=\"wp-image-164522\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-ESP32-uploading-new-file-ota.png?w=907&amp;quality=100&amp;strip=all&amp;ssl=1 907w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-ESP32-uploading-new-file-ota.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegant-ota-ESP32-uploading-new-file-ota.png?resize=768%2C564&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/figure><\/div>\n\n\n<p><strong>5.<\/strong> After a few seconds, you should get a success message. Then, click on the <strong>Back<\/strong> button.<\/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=\"907\" height=\"666\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/esp32-elegant-ota-upload-success.png?resize=907%2C666&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 ElegantOTA Upload new Firmware Success\" class=\"wp-image-164523\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/esp32-elegant-ota-upload-success.png?w=907&amp;quality=100&amp;strip=all&amp;ssl=1 907w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/esp32-elegant-ota-upload-success.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/esp32-elegant-ota-upload-success.png?resize=768%2C564&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 907px) 100vw, 907px\" \/><\/figure><\/div>\n\n\n<p><strong>6. <\/strong>Now, you can go to the root (<span class=\"rnthl rntliteral\">\/<\/span>) URL to access the new web server. This is the page you should see when you access the ESP IP address on the root (<span class=\"rnthl rntliteral\">\/<\/span>) URL.<\/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=\"875\" height=\"514\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-GPIO-websocket-server.png?resize=875%2C514&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Websocket server - control outputs\" class=\"wp-image-164524\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-GPIO-websocket-server.png?w=875&amp;quality=100&amp;strip=all&amp;ssl=1 875w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-GPIO-websocket-server.png?resize=300%2C176&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-GPIO-websocket-server.png?resize=768%2C451&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 875px) 100vw, 875px\" \/><\/figure><\/div>\n\n\n<p>You can click on the button to turn the ESP32 on-board LED on and off.<\/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=\"422\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=750%2C422&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\" ESP32 on-board LED on and off\" class=\"wp-image-120420\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2022\/10\/ESP32-board-Built_in-LED-turned-on-HIGH.jpg?resize=300%2C169&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 750px) 100vw, 750px\" \/><\/figure><\/div>\n\n\n<p>Because we&#8217;ve also added OTA capabilities to this new web server, we can upload a new sketch in the future if needed. You just need to go to the ESP32 IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span>.<\/p>\n\n\n\n<p>Congratulations, you&#8217;ve uploaded new code to your ESP32 via Wi-Fi using ElegantOTA.<\/p>\n\n\n\n<p>Continue reading if you want to learn how to upload files to the ESP32 filesystem (LittleFS) using the ElegantOTA library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"upload-files-littlefs-filesystem-ota\">Upload Files to Filesystem via OTA to the ESP32<\/h2>\n\n\n\n<p>In this section you&#8217;ll learn to upload files to the ESP32 filesystem (LittleFS) using the ElegantOTA library.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">ESP32 Filesystem Uploader Plugin<\/h3>\n\n\n\n<p>Before proceeding, you need to have the ESP32 Filesystem Uploader Plugin installed in your Arduino IDE. Follow the next tutorial before proceeding:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/randomnerdtutorials.com\/arduino-ide-2-install-esp32-littlefs\/\">Arduino IDE 2: Install ESP32 LittleFS Uploader (Upload Files to the Filesystem)<\/a><\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Web Server with Files from LittleFS<\/h3>\n\n\n\n<p>Imagine the scenario that you need to upload files to the ESP32 filesystem, for example: configuration files; HTML, CSS and JavaScript files to update the web server page; or any other file that you may want to save in the LittleFS filesystem via OTA.<\/p>\n\n\n\n<p>To show you how to do this, we&#8217;ll create a new web server that serves files from LittleFS: HTML, and CSS files to build a web page that controls the ESP32 built-in LED remotely using a different interface.<\/p>\n\n\n\n<p>Copy the following code to your Arduino IDE.<\/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-ota-elegantota-arduino\/\n  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files. The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Softwar\n*********\/\n\n#include &lt;Arduino.h&gt;\n#include &lt;WiFi.h&gt;\n#include &lt;AsyncTCP.h&gt;\n#include &lt;ESPAsyncWebServer.h&gt;\n#include &quot;LittleFS.h&quot;\n#include &lt;ElegantOTA.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\n\/\/ Create AsyncWebServer object on port 80\nAsyncWebServer server(80);\n\n\/\/ Set LED GPIO\nconst int ledPin = 2;\n\n\/\/ Stores LED state\nString ledState;\n\n\/\/ Initialize LittleFS\nvoid initLittleFS() {\n  if (!LittleFS.begin(true)) {\n    Serial.println(&quot;An error has occurred while mounting LittleFS&quot;);\n  }\n  else {\n    Serial.println(&quot;LittleFS mounted successfully&quot;);\n  }\n}\n\n\/\/ Initialize WiFi\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\n\/\/ Replaces placeholder with LED state value\nString processor(const String&amp; var) {\n  if(var == &quot;STATE&quot;) {\n    if(digitalRead(ledPin)) {\n      ledState = &quot;ON&quot;;\n    }\n    else {\n      ledState = &quot;OFF&quot;;\n    }\n    return ledState;\n  }\n  return String();\n}\n\nvoid setup() {\n  Serial.begin(115200);\n  initWiFi();\n  initLittleFS();\n\n  \/\/ Set GPIO2 as an OUTPUT\n  pinMode(2, OUTPUT);\n\n  \/\/ Route for root \/ web page\n  server.on(&quot;\/&quot;, HTTP_GET, [](AsyncWebServerRequest *request) {\n    request-&gt;send(LittleFS, &quot;\/index.html&quot;, &quot;text\/html&quot;, false, processor);\n  });\n\n  server.serveStatic(&quot;\/&quot;, LittleFS, &quot;\/&quot;);\n\n  \/\/ Route to set GPIO state to HIGH\n  server.on(&quot;\/on&quot;, HTTP_GET, [](AsyncWebServerRequest *request) {\n    digitalWrite(ledPin, HIGH);\n    request-&gt;send(LittleFS, &quot;\/index.html&quot;, &quot;text\/html&quot;, false, processor);\n  });\n\n  \/\/ Route to set GPIO state to LOW\n  server.on(&quot;\/off&quot;, HTTP_GET, [](AsyncWebServerRequest *request) {\n    digitalWrite(ledPin, LOW);\n    request-&gt;send(LittleFS, &quot;\/index.html&quot;, &quot;text\/html&quot;, false, processor);\n  });\n\n  \/\/ Start server\n  server.begin();\n\n  ElegantOTA.begin(&amp;server);    \/\/ Start ElegantOTA\n\n}\n\nvoid loop() {\n  ElegantOTA.loop();\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\/ElegantOTA\/ESP32_WebServer_LED_ElegantOTA_2\/ESP32_WebServer_LED_ElegantOTA_2.ino\" target=\"_blank\">View raw code<\/a><\/p>\n\n\n\n<p class=\"rntbox rntclgreen\"><strong>Note<\/strong>: this example is covered and explained in our eBook: <a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\" title=\"\">Build Web Severs with the ESP32 and ESP8266<\/a>.<\/p>\n\n\n\n<p>Insert your network credentials in the following variables and save the code.<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>const char* ssid = \"REPLACE_WITH_YOUR_SSID\";\nconst char* password = \"REPLACE_WITH_YOUR_PASSWORD\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Update Firmware<\/h3>\n\n\n\n<p>Create a <em>.ino.bin<\/em> file from this sketch as shown previously (this sketch also includes the needed lines of code to provide OTA capabilities).<\/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=\"383\" height=\"272\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=383%2C272&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE, expor bin file\" class=\"wp-image-164549\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?w=383&amp;quality=100&amp;strip=all&amp;ssl=1 383w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/export-bin-file-arduino-ide.jpg?resize=300%2C213&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 383px) 100vw, 383px\" \/><\/figure><\/div>\n\n\n<p>Go to the ESP32 IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span> and upload the new firmware.<\/p>\n\n\n\n<p>Next, we&#8217;ll see how to upload the files.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"update-filesystem-arduino\">Update the Filesystem<\/h3>\n\n\n\n<p>Under the project folder, create a folder called <em><strong>data <\/strong><\/em>and move the following HTML and CSS files (click on the links to download the files):<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/refs\/heads\/master\/Projects\/ESP32\/ElegantOTA\/ESP32_WebServer_LED_ElegantOTA_2\/data\/index.html\" target=\"_blank\" rel=\"noopener\" title=\"\">HTML file: <em>index.html<\/em><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/raw.githubusercontent.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/refs\/heads\/master\/Projects\/ESP32\/ElegantOTA\/ESP32_WebServer_LED_ElegantOTA_2\/data\/style.css\" target=\"_blank\" rel=\"noopener\" title=\"\">CSS file: <em>style.css<\/em><\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/refs\/heads\/master\/Projects\/ESP32\/ElegantOTA\/ESP32_WebServer_LED_ElegantOTA_2\/ESP32_WebServer_LED_ElegantOTA_2.zip\" target=\"_blank\" rel=\"noopener\" title=\"\"><strong>Click here to donwload all project files<\/strong><\/a><\/li>\n<\/ul>\n\n\n\n<p>To find your project folder, you can simply go to <strong>Sketch <\/strong>&gt; <strong>Show Sketch Folder<\/strong>.<\/p>\n\n\n\n<p>This is the folder structure of your project and where the data folder should be located:<\/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=\"408\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-Web-Server-Folder-Structure.png?resize=750%2C408&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Web Server with Filesystem Files and with OTA Folder Structure\" class=\"wp-image-164552\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-Web-Server-Folder-Structure.png?w=750&amp;quality=100&amp;strip=all&amp;ssl=1 750w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-Web-Server-Folder-Structure.png?resize=300%2C163&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>Web_Server_OTA_ESP32_Example_2\n<ul class=\"wp-block-list\">\n<li><strong>data<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong><em>style.css<\/em><\/strong><\/li>\n\n\n\n<li><strong><em>index.html<\/em><\/strong><\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><em>Web_Server_OTA_ESP32_Example_2.ino<\/em><\/li>\n\n\n\n<li>build\n<ul class=\"wp-block-list\">\n<li>esp32.es32.esp32doit-devkit-v1 (or similar depending on the selected board)\n<ul class=\"wp-block-list\">\n<li><em>Web_Server_OTA_ESP32_Example_2.ino.bin<\/em><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>After this, with the <strong>ESP32 disconnected from your computer<\/strong> (that&#8217;s the whole purpose of OTA), let&#8217;s pretend we&#8217;ll upload the files to the filesystem. Press [<strong>Ctrl<\/strong>] + [<strong>Shift<\/strong>] + [<strong>P<\/strong>] to open the command palette. An instruction called \u2018<strong>Upload Little FS to Pico\/ESP8266\/ESP32<\/strong>\u2018 should be there (just scroll down or search for the name of the instruction).<\/p>\n\n\n\n<p class=\"rntbox rntclblue\">If you don&#8217;t have that option, it means you don&#8217;t have the Filesystem Uploader Plugin installed in your Arduino IDE. Follow the next tutorial to install it: <a href=\"https:\/\/randomnerdtutorials.com\/arduino-ide-2-install-esp32-littlefs\/\">Arduino IDE 2: Install ESP32 LittleFS Uploader (Upload Files to the Filesystem)<\/a>.<\/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=\"732\" height=\"586\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/05\/Upload-littlefs-esp32-esp8266-pico.png?resize=732%2C586&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Upload Little FS to Pico\/ESP8266\/ESP32 Arduino IDE\" class=\"wp-image-154910\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/05\/Upload-littlefs-esp32-esp8266-pico.png?w=732&amp;quality=100&amp;strip=all&amp;ssl=1 732w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/05\/Upload-littlefs-esp32-esp8266-pico.png?resize=300%2C240&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 732px) 100vw, 732px\" \/><\/figure><\/div>\n\n\n<p>You&#8217;ll get an error because there isn&#8217;t any ESP32 board connected to your computer &#8211; don&#8217;t worry. It will still create a <em>.bin<\/em> file from the <em>data<\/em> folder.<\/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=\"933\" height=\"356\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/filesystem-image-bin-file-for-OTA.png?resize=933%2C356&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"Arduino IDE create bin file from filesystem image\" class=\"wp-image-164527\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/filesystem-image-bin-file-for-OTA.png?w=933&amp;quality=100&amp;strip=all&amp;ssl=1 933w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/filesystem-image-bin-file-for-OTA.png?resize=300%2C114&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/filesystem-image-bin-file-for-OTA.png?resize=768%2C293&amp;quality=100&amp;strip=all&amp;ssl=1 768w\" sizes=\"(max-width: 933px) 100vw, 933px\" \/><\/figure><\/div>\n\n\n<p>On the debugging window you&#8217;ll see the <em>.littlefs.bin<\/em> file location. That&#8217;s that file that you should upload (in our case the file is called <em>tmp-29172-heLR8chx1V9e-.littlefs.bin<\/em>.<\/p>\n\n\n\n<p>In our case, this is the path where that file is located:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">C:\\Users\\sarin\\AppData\\Local\\Temp\\tmp-29172-heLR8chx1V9e-.littlefs.bin.<\/pre>\n\n\n\n<p>Find that file in your computer.<\/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=\"758\" height=\"504\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/littlefs-bin-file-to-upload-via-ota.png?resize=758%2C504&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"LittleFS .bin file to upload via OTA\" class=\"wp-image-164528\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/littlefs-bin-file-to-upload-via-ota.png?w=758&amp;quality=100&amp;strip=all&amp;ssl=1 758w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/littlefs-bin-file-to-upload-via-ota.png?resize=300%2C199&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 758px) 100vw, 758px\" \/><\/figure><\/div>\n\n\n<p>To make things easier, you can copy that file to your project folder.<\/p>\n\n\n\n<p>Now that we have a <em>.litlefs.bin <\/em>file from the <em>data <\/em>folder, we can upload that file. Go to your ESP32 IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span>. Make sure you have the <strong>Filesystem <\/strong>option selected in the OTA Mode option.<\/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=\"756\" height=\"664\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-upload-filesystem-image.png?resize=756%2C664&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ElegantOTA upload filesystem image LittleFS\" class=\"wp-image-164526\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-upload-filesystem-image.png?w=756&amp;quality=100&amp;strip=all&amp;ssl=1 756w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/elegantota-upload-filesystem-image.png?resize=300%2C263&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 756px) 100vw, 756px\" \/><\/figure><\/div>\n\n\n<p>Then, select the file with the <em>.littlefs.bin<\/em> extension.<\/p>\n\n\n\n<p>After successfully uploading, click the <strong>Back <\/strong>button. And go to the root (<span class=\"rnthl rntliteral\">\/<\/span>) URL again. You should get access to the following web page that controls the ESP32 built-in LED with two buttons.<\/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=\"684\" height=\"502\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-LED-two-buttons-Web-server-with-OTA-capabilities.png?resize=684%2C502&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"ESP32 Web Server Control LED with Two Buttons with OTA capabilities\" class=\"wp-image-164530\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-LED-two-buttons-Web-server-with-OTA-capabilities.png?w=684&amp;quality=100&amp;strip=all&amp;ssl=1 684w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-control-LED-two-buttons-Web-server-with-OTA-capabilities.png?resize=300%2C220&amp;quality=100&amp;strip=all&amp;ssl=1 300w\" sizes=\"(max-width: 684px) 100vw, 684px\" \/><\/figure><\/div>\n\n\n<p>If you need to update something on your project, you just need to go to your ESP32 IP address followed by <span class=\"rnthl rntliteral\">\/update<\/span>.<\/p>\n\n\n\n<p>Congratulations! You&#8217;ve successfully uploaded files to the ESP32 filesystem using the ElegantOTA library.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Wrapping Up<\/h2>\n\n\n\n<p>In this tutorial you&#8217;ve learned how to add OTA capabilities to your Async Web Server projects using the ElegantOTA library. This library is straightforward to use\u2014you just need to add three lines of code to your project.<\/p>\n\n\n\n<p>Additionally, this library also allows you to upload new firmware or files to the LittleFS filesystem effortlessly using a web page.<\/p>\n\n\n\n<p>We hope you&#8217;ve 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> (eBook)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/build-web-servers-esp32-esp8266-ebook\/\">Build ESP32 Web Servers with Arduino IDE<\/a> (eBook)<\/li>\n\n\n\n<li><a href=\"https:\/\/randomnerdtutorials.com\/projects-esp32\/\">More ESP32 Projects and Tutorials&#8230; <\/a><\/li>\n<\/ul>\n\n\n\n<p>Thanks for reading.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial shows how to do OTA (over-the-air) updates to your ESP32 boards using the ElegantOTA library (V3 version) with Arduino IDE. This library sets up a web server that &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP32 OTA (Over-the-Air) Updates \u2013  ElegantOTA Library with Arduino IDE\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp32-ota-elegantota-arduino\/#more-164492\" aria-label=\"Read more about ESP32 OTA (Over-the-Air) Updates \u2013  ElegantOTA Library with Arduino IDE\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":5,"featured_media":164531,"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":[276,281,277,299,264],"tags":[],"class_list":["post-164492","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-esp32","category-esp32-project","category-esp32-arduino-ide","category-0-esp32","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2024\/12\/ESP32-ElegantOTA-Arduino-IDE.jpg?fit=1920%2C1080&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/164492","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=164492"}],"version-history":[{"count":16,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/164492\/revisions"}],"predecessor-version":[{"id":168249,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/164492\/revisions\/168249"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/164531"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=164492"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=164492"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=164492"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}