{"id":31259,"date":"2017-01-05T10:19:18","date_gmt":"2017-01-05T10:19:18","guid":{"rendered":"http:\/\/randomnerdtutorials.com\/?p=31259"},"modified":"2019-04-02T10:23:30","modified_gmt":"2019-04-02T10:23:30","slug":"esp8266-ota-updates-with-arduino-ide-over-the-air","status":"publish","type":"post","link":"https:\/\/randomnerdtutorials.com\/esp8266-ota-updates-with-arduino-ide-over-the-air\/","title":{"rendered":"ESP8266 OTA Updates with Arduino IDE | Over the Air"},"content":{"rendered":"<p>OTA (Over the Air) update is the process of loading a new firmware to ESP8266 module using WiFi connection rather than a serial communication. This type of\u00a0functionality is extremely useful in case of no physical access to the ESP module.<!--more--><\/p>\n<p>Uploading a new sketch wirelessly from Arduino IDE is intended for the following typical scenarios:<\/p>\n<ul>\n<li>during firmware development &#8211; as a quicker alternative to uploading a new sketch over a serial<\/li>\n<li>for updating the firmware of multiple ESPs in your network<\/li>\n<\/ul>\n<p>If you like the ESP and you want to do more projects\u00a0you can read my eBook <a href=\"https:\/\/randomnerdtutorials.com\/home-automation-using-esp8266\/\" target=\"_blank\" rel=\"noopener noreferrer\">Home Automation using ESP8266<\/a>.<\/p>\n<p><strong>Let\u2019s get started!<\/strong><\/p>\n<p><img fetchpriority=\"high\" decoding=\"async\" class=\"aligncenter wp-image-30778\" src=\"https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=503%2C364\" sizes=\"(max-width: 503px) 100vw, 503px\" srcset=\"https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?w=589 589w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=150%2C109 150w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=300%2C217 300w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=80%2C58 80w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=220%2C159 220w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=138%2C100 138w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=207%2C150 207w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=328%2C238 328w, https:\/\/i1.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2016\/12\/Python_2.png?resize=572%2C415 572w\" alt=\"\" width=\"503\" height=\"365\" \/><\/p>\n<h2>Step #1 &#8211; Uploading BasicOTA.ino with serial communication<\/h2>\n<p>In order to upload firmware to your ESP8266 wirelessly, you have to upload the BasicOTA.ino sketch example first.<\/p>\n<p>Having the latest Arduino IDE software installed from <a href=\"https:\/\/www.arduino.cc\/en\/Main\/Software\" target=\"_blank\" rel=\"noopener noreferrer\">arduino.cc\/en\/Main\/Software<\/a>. Follow these next instructions:<\/p>\n<p>1) Connect your ESP8266 to your computer with a USB cable:<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter wp-image-31262 size-full\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=480%2C261&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"480\" height=\"261\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?w=480&amp;quality=100&amp;strip=all&amp;ssl=1 480w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=150%2C82&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=300%2C163&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=80%2C44&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=220%2C120&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=184%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 184w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=276%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 276w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_computer.jpg?resize=438%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 438w\" sizes=\"(max-width: 480px) 100vw, 480px\" \/><\/p>\n<p>2) Go to <strong>Tools<\/strong>\u00a0to select your ESP board model. You also have to choose your ESP&#8217;s COM port<\/p>\n<p><img data-recalc-dims=\"1\" decoding=\"async\" class=\"aligncenter size-full wp-image-31264\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=548%2C393&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"548\" height=\"393\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?w=548&amp;quality=100&amp;strip=all&amp;ssl=1 548w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=150%2C108&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=300%2C215&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=80%2C57&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=220%2C158&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=139%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 139w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=209%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 209w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_com_port.png?resize=332%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 332w\" sizes=\"(max-width: 548px) 100vw, 548px\" \/><\/p>\n<p>3) Open the BasicOTA.ino example: <strong>File<\/strong> &gt; <strong>Examples<\/strong> &gt; <strong>Arduino OTA<\/strong> &gt;<strong> BasicOTA.ino<\/strong> or copy the following sketch to your Arduino IDE<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at http:\/\/randomnerdtutorials.com\n  Arduino IDE example: Examples &gt; Arduino OTA &gt; BasicOTA.ino\n*********\/\n\n#include &lt;ESP8266WiFi.h&gt;\n#include &lt;ESP8266mDNS.h&gt;\n#include &lt;WiFiUdp.h&gt;\n#include &lt;ArduinoOTA.h&gt;\n\n\/\/ Replace with your network credentials\nconst char* ssid = &quot;YOUR_SSID&quot;;\nconst char* password = &quot;YOUR_PASSWORD&quot;;\n\nvoid setup() {\n  Serial.begin(115200);\n  Serial.println(&quot;Booting&quot;);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  while (WiFi.waitForConnectResult() != WL_CONNECTED) {\n    Serial.println(&quot;Connection Failed! Rebooting...&quot;);\n    delay(5000);\n    ESP.restart();\n  }\n\n  \/\/ Port defaults to 8266\n  \/\/ ArduinoOTA.setPort(8266);\n\n  \/\/ Hostname defaults to esp8266-[ChipID]\n  \/\/ ArduinoOTA.setHostname(&quot;myesp8266&quot;);\n\n  \/\/ No authentication by default\n  \/\/ ArduinoOTA.setPassword((const char *)&quot;123&quot;);\n\n  ArduinoOTA.onStart([]() {\n    Serial.println(&quot;Start&quot;);\n  });\n  ArduinoOTA.onEnd([]() {\n    Serial.println(&quot;\\nEnd&quot;);\n  });\n  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {\n    Serial.printf(&quot;Progress: %u%%\\r&quot;, (progress \/ (total \/ 100)));\n  });\n  ArduinoOTA.onError([](ota_error_t error) {\n    Serial.printf(&quot;Error[%u]: &quot;, error);\n    if (error == OTA_AUTH_ERROR) Serial.println(&quot;Auth Failed&quot;);\n    else if (error == OTA_BEGIN_ERROR) Serial.println(&quot;Begin Failed&quot;);\n    else if (error == OTA_CONNECT_ERROR) Serial.println(&quot;Connect Failed&quot;);\n    else if (error == OTA_RECEIVE_ERROR) Serial.println(&quot;Receive Failed&quot;);\n    else if (error == OTA_END_ERROR) Serial.println(&quot;End Failed&quot;);\n  });\n  ArduinoOTA.begin();\n  Serial.println(&quot;Ready&quot;);\n  Serial.print(&quot;IP address: &quot;);\n  Serial.println(WiFi.localIP());\n}\n\nvoid loop() {\n  ArduinoOTA.handle();\n}\n<\/code><\/pre>\n\t<p style=\"text-align:center\"><a class=\"rntwhite\" href=\"https:\/\/github.com\/RuiSantosdotme\/Random-Nerd-Tutorials\/raw\/master\/Projects\/ESP_OTA_Arduino.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<p><strong>Note:<\/strong> you have to change the sketch example with your SSID and password.<\/p>\n<p>4) Press the &#8220;Upload&#8221;\u00a0button in the Arduino IDE and wait for the &#8220;Done uploading&#8221; message<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-31260\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=577%2C503&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"577\" height=\"503\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?w=730&amp;quality=100&amp;strip=all&amp;ssl=1 730w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=150%2C131&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=300%2C261&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=80%2C70&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=220%2C192&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=115%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 115w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=172%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 172w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=273%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 273w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=476%2C415&amp;quality=100&amp;strip=all&amp;ssl=1 476w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=559%2C487&amp;quality=100&amp;strip=all&amp;ssl=1 559w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/Arduino-IDE.png?resize=683%2C595&amp;quality=100&amp;strip=all&amp;ssl=1 683w\" sizes=\"(max-width: 577px) 100vw, 577px\" \/><\/p>\n<p>5) Open the Arduino IDE serial monitor at a baud rate of 115200. If you&#8217;ve entered the right network credentials you should see your ESP IP address after a few seconds:<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31261\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=570%2C350&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"570\" height=\"350\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?w=570&amp;quality=100&amp;strip=all&amp;ssl=1 570w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=150%2C92&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=300%2C184&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=80%2C49&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=220%2C135&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=163%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 163w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=244%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 244w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/arduino_serial_monitor.png?resize=388%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 388w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/p>\n<h2>Step #2 &#8211; Uploading a new sketch OTA (Over the Air)<\/h2>\n<p>Now your ESP8266 is ready to receive OTA firmware updates. You can unplug your ESP8266 from your computer and power it through any power source (for example a power bank). If your\u00a0ESP8266 has a wireless connection to your router, you should be fine to upload new firmware.<\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31263\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=550%2C382&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"550\" height=\"382\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?w=550&amp;quality=100&amp;strip=all&amp;ssl=1 550w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=150%2C104&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=300%2C208&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=80%2C56&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=220%2C153&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=144%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 144w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=216%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 216w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?resize=343%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 343w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/p>\n<p>1) Go to your Arduino IDE. Open <strong>Tools<\/strong> tab select the <strong>Port<\/strong> option and you should see something like this: <strong>esp8266-xxxxxx<\/strong> at <strong>your_esp_ip_address<\/strong><\/p>\n<p><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-31265\" src=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=660%2C394&#038;quality=100&#038;strip=all&#038;ssl=1\" alt=\"\" width=\"660\" height=\"394\" srcset=\"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?w=660&amp;quality=100&amp;strip=all&amp;ssl=1 660w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=150%2C90&amp;quality=100&amp;strip=all&amp;ssl=1 150w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=300%2C179&amp;quality=100&amp;strip=all&amp;ssl=1 300w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=80%2C48&amp;quality=100&amp;strip=all&amp;ssl=1 80w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=220%2C131&amp;quality=100&amp;strip=all&amp;ssl=1 220w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=168%2C100&amp;quality=100&amp;strip=all&amp;ssl=1 168w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=251%2C150&amp;quality=100&amp;strip=all&amp;ssl=1 251w, https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/select_esp8266_wifi.png?resize=399%2C238&amp;quality=100&amp;strip=all&amp;ssl=1 399w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><\/p>\n<p>2) Copy the\u00a0following sketch to your Arduino IDE and upload it to your ESP8266. This sketch blinks the ESP12-E NodeMCU kit built-in LED\u00a0every second<\/p>\n<pre style=\"max-height: 40em; margin-bottom: 20px;\"><code class=\"language-c\">\/*********\n  Rui Santos\n  Complete project details at http:\/\/randomnerdtutorials.com\n  Arduino IDE example: Examples &gt; Arduino OTA &gt; BasicOTA.ino\n*********\/\n\n#include &lt;ESP8266WiFi.h&gt;\n#include &lt;ESP8266mDNS.h&gt;\n#include &lt;WiFiUdp.h&gt;\n#include &lt;ArduinoOTA.h&gt;\n\n\/\/ Replace with your network credentials\nconst char* ssid = &quot;YOUR_SSID&quot;;\nconst char* password = &quot;YOUR_PASSWORD&quot;;\n\nconst int ESP_BUILTIN_LED = 2;\n\nvoid setup() {\n  Serial.begin(115200);\n  Serial.println(&quot;Booting&quot;);\n  WiFi.mode(WIFI_STA);\n  WiFi.begin(ssid, password);\n  while (WiFi.waitForConnectResult() != WL_CONNECTED) {\n    Serial.println(&quot;Connection Failed! Rebooting...&quot;);\n    delay(5000);\n    ESP.restart();\n  }\n\n  \/\/ Port defaults to 8266\n  \/\/ ArduinoOTA.setPort(8266);\n\n  \/\/ Hostname defaults to esp8266-[ChipID]\n  \/\/ ArduinoOTA.setHostname(&quot;myesp8266&quot;);\n\n  \/\/ No authentication by default\n  \/\/ ArduinoOTA.setPassword((const char *)&quot;123&quot;);\n\n  ArduinoOTA.onStart([]() {\n    Serial.println(&quot;Start&quot;);\n  });\n  ArduinoOTA.onEnd([]() {\n    Serial.println(&quot;\\nEnd&quot;);\n  });\n  ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {\n    Serial.printf(&quot;Progress: %u%%\\r&quot;, (progress \/ (total \/ 100)));\n  });\n  ArduinoOTA.onError([](ota_error_t error) {\n    Serial.printf(&quot;Error[%u]: &quot;, error);\n    if (error == OTA_AUTH_ERROR) Serial.println(&quot;Auth Failed&quot;);\n    else if (error == OTA_BEGIN_ERROR) Serial.println(&quot;Begin Failed&quot;);\n    else if (error == OTA_CONNECT_ERROR) Serial.println(&quot;Connect Failed&quot;);\n    else if (error == OTA_RECEIVE_ERROR) Serial.println(&quot;Receive Failed&quot;);\n    else if (error == OTA_END_ERROR) Serial.println(&quot;End Failed&quot;);\n  });\n  ArduinoOTA.begin();\n  Serial.println(&quot;Ready&quot;);\n  Serial.print(&quot;IP address: &quot;);\n  Serial.println(WiFi.localIP());\n  pinMode(ESP_BUILTIN_LED, OUTPUT);\n}\n\nvoid loop() {\n  ArduinoOTA.handle();\n  digitalWrite(ESP_BUILTIN_LED, LOW);\n  delay(1000);\n  digitalWrite(ESP_BUILTIN_LED, HIGH);\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\/ESP_OTA_Arduino_Modified.ino\" target=\"_blank\">View raw code<\/a><\/p>\n<p><strong>Note:<\/strong> you have to change the sketch example with your SSID and password.<\/p>\n<p>3)\u00a0Press the &#8220;Upload&#8221;\u00a0button in the Arduino IDE and wait for the &#8220;Done uploading&#8221; message<\/p>\n<p>4) Your ESP should have it&#8217;s built-in LED blinking every second<\/p>\n<h2>Wrapping Up<\/h2>\n<p>I hope this tutorial was useful. Now, you can have your ESP8266 in a remote location and update its firmware without having physical access to the ESP device.<\/p>\n<p>Do you have any questions?\u00a0Leave a comment down below.<\/p>\n<p>Thanks for reading. If you like this post probably you might like my next ones, so please support me by subscribing my <a href=\"https:\/\/randomnerdtutorials.com\/download\" target=\"_blank\" rel=\"noopener noreferrer\">blog<\/a> and my\u00a0Facebook Page.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OTA (Over the Air) update is the process of loading a new firmware to ESP8266 module using WiFi connection rather than a serial communication. This type of\u00a0functionality is extremely useful &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"ESP8266 OTA Updates with Arduino IDE | Over the Air\" class=\"read-more button\" href=\"https:\/\/randomnerdtutorials.com\/esp8266-ota-updates-with-arduino-ide-over-the-air\/#more-31259\" aria-label=\"Read more about ESP8266 OTA Updates with Arduino IDE | Over the Air\">CONTINUE READING \u00bb<\/a><\/p>\n","protected":false},"author":1,"featured_media":31263,"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":true,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,245,265,246,300,269,264],"tags":[],"class_list":["post-31259","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-arduino","category-arduino-ide","category-esp8266-project","category-esp8266-arduino-ide","category-0-esp8266","category-guide-project","category-project"],"aioseo_notices":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/randomnerdtutorials.com\/wp-content\/uploads\/2017\/01\/ESP8266_connected_to_powerbank.jpg?fit=550%2C382&quality=100&strip=all&ssl=1","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/31259","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\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/comments?post=31259"}],"version-history":[{"count":0,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/posts\/31259\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media\/31263"}],"wp:attachment":[{"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/media?parent=31259"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/categories?post=31259"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/randomnerdtutorials.com\/wp-json\/wp\/v2\/tags?post=31259"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}