ESP8266 OTA (Over The Air) Update using Arduino IDE

ESP8266 OTA is used to load firmware using a WiFi connection instead of using a serial port. You can program ESP8266 over the air using three different methods.

  1. Arduino IDE
  2. Web Browser
  3. HTTP Server.

Complete the first-time firmware update using the serial port. After you can use the OTA update to upload a sketch to ESP8266/NodeMCU Module. You can use this method in any ESP8266 versions or in NodeMCU module. Here, we will learn to program ESP8266 OTA using Arduino IDE.

Security in OTA updates

Wireless networks for Computer and ESP8266 are same to upload a new sketch. There are chances of the hacking module or someone programme it using other code. Methods like password protection, select OTA port etc are helpful for security reasons. ArduinoOTA uses Digest-MD5 to authenticate upload. There are also some other advanced security methods to authenticate it.

ESP8266 OTA Update using Arduino IDE

OTA updates using Arduino IDE is possible in the below-given scenarios.

  • It is easier and takes less time to upload the sketch
  • Wireless networks for Computer and ESP8266 are same.
  • It is helpful for updating small quantities of the module.

This is code for programming ESP8266 OTA update. You need to connect ESP8266 physically to the computer because of enabling the OTA updates.

Firstly, we are using ESP8266WiFi and ArduinoOTA Library. Connecting to a WiFi network with provided credentials. Currently, we have set the Hostname as “ESP8266” and password as “admin”. If you don’t set the hostname, it will set the default as esp8266-[ChipID]. If you don’t set then it will disable the password authentication. After that, started the ArduinoOTA by onStart command. Similarly, written some other default ArduinoOTA functions like onEnd, onProgress and on Error. Finally, started the Arduino OTA. Also, printed IP address on Serial. In the loop, we used the ArduinoOTA.handle function to handle the incoming requests.

Now, you can upload a new sketch to ESP8266 OTA using Arduino IDE without connecting it. You will get the addition of a network port. Select it and upload the new program.

Above all shows how to program ESP8266 over the air. It requires one time physically uploading code to enable OTA support.

Learn more about Programming ESP8266 with Arduino UNO.

Leave a Reply