Introduction: IoT Over the Air Update (OTA) ESP8266

Picture of IoT Over the Air Update (OTA) ESP8266

In This project I am going to explain steps of make ESP8266 ready for OTA update. We use here Arduino IDE for programe ESP8266 first time for giving support of OTA boot loader

Step 1: Install Python on Your System

You need to install python27 on your system in order to program ESP8266 from your system you need to run OTA script. Install python27 on System from where your going to upload firmware.

Step 2: Download and Install Arduino OTA Library

Download The library and tools required for OTA click here

Install "" in arduino library.

Step 3: Upload Sketch With OTA Bootloader

Complile and Upload following sketch in ESP by our regular method through serial terminal. Its necessary to upload first time sketch with OTA suppot.

#include < esp8266wifi.h >

#include < esp8266mdns .h >

#include < wifiudp .h >

#include < arduinoota .h >

const char* ssid = "WIFI ROUTER NAME";

const char* password = "WIFI ROUTER PASSWORD";

void setup() {




WiFi.begin(ssid, password);

while (WiFi.waitForConnectResult() != WL_CONNECTED) {

Serial.println("Connection Failed! Rebooting...");




ArduinoOTA.onStart([]() {

String type;

if (ArduinoOTA.getCommand() == U_FLASH)

type = "sketch";

else // U_SPIFFS

type = "filesystem";

// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()

Serial.println("Start updating " + type);


ArduinoOTA.onEnd([]() {



ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {

Serial.printf("Progress: %u%%\r", (progress / (total / 100)));


ArduinoOTA.onError([](ota_error_t error) {

Serial.printf("Error[%u]: ", error);

if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");

else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");

else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");

else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");

else if (error == OTA_END_ERROR) Serial.println("End Failed");



Serial.println("Ready v1.0"); //Change version for every new modification in firmaware

Serial.print("IP address: ");




void loop() {







Step 4: Create New Bin File for Test Working of OTA

Picture of Create New Bin File for Test Working of OTA

Now your ESP8266is ready for OTA support.
How to test OTA is working ?

first you need new firm ware file OTA support two types of file i.e 1) .bin, 2 ) SPIFF

Here we are dealing with only .bin file.

modify above sketch withc some changes like

Serial.println("Ready v2.0"); //Change version for every new modification in firmaware


void loop() {







here we change version of firmware and make some changes in program. That can be reflect after OTA update.

Now only Verify/Compile program in Arduino IDE do not Upload.

goto run > %temp% in temp folder find out your arduino build folder

Locate build folder

Locate .bin file

copy .bin file path which is used for espota tool.

Step 5: Upgrade Firmware OTA and Verify OTA Is Working

Picture of Upgrade Firmware OTA and Verify OTA Is Working

Now prepare system which can access ESP8266 in network.
In download rar file you will find script that can upload firmware in esp.

Open command prompt in file location by pressing shift key and right click > open command window here.

give this command

python -i -p 8266 -f "C:\User\INDIA\AppData\Local\\Temp\builda0eb11f6003a2bd55895c96acd777afe.tmp\BasicOTA.ino.bin" -d -r

firmware up-gradation will start

For detail procedure follow this blog


YashK11 (author)2017-10-13

hello.. please help me.. i've a nodeMcu chip .. so when i upload this code from arduino ide it gives error that

"Arduino: 1.8.4 (Windows 7), Board: "NodeMCU 1.0 (ESP-12E Module), 80 MHz, 115200, 4M (3M SPIFFS)"

C:\Windows\bootloader_wifi\bootloader_wifi.ino:1:27: fatal error: esp8266wifi.h : No such file or directory

#include < esp8266wifi.h >


compilation terminated.

exit status 1

Error compiling for board NodeMCU 1.0 (ESP-12E Module)."

i am new to this so if i haven't given complete details tell me..

I have already installed python, ota libraries, nodemcu libraries

Swansong (author)2017-02-13

Thanks for sharing :)

About This Instructable




More by dkhairnar:Start Programming ESP3212 With Arduino IDEArduino 2.4 TFT Touch Screen LCD InterfaceGesture Controlled HID Mouse Using STM32 and Accelerometer
Add instructable to: