Dhananjay Khairnar @. Powered by Blogger.

1 February 2017

ESP 8266 OTA(Over The Air) Update Firmware Demo :


My friend Sanket encourage me to do some stuff on ESP8266OTA.
No need of wire to upload Arduino sketch in ESP8266. OTA give you advantage of uploading sketch or upgrade firmware over the WiFi without any wired connection.
*Program uploading is Faster than regular arduino upload.

1) Go through previous tutorials of ESP8266on my blog
2) ESP8266

3) python27 installed on System from where your going to upload firmware.\

Step 1:
Download The library and tools required for OTA click here

Step 2:
Extract downloaded file and install arduino OTA library in Arduino IDE.

Step 3:
 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 : 
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 use in espota tool.

Step 5:
 Now prepare system which can access ESP8266in network.
In download rar file you will find espota.py script that can upload firmware in esp.

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

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

firmware upgradation will start


You can observe blinking speed of LED get changed.

If you have any questions please comment below.
Thank You.

About DK

Hi, My Name is DK. I am a embedded system designer and embedded programmer. I am a certified holder of Diploma in Embedded system designing. We have a team of professinal programmers, developers work together and implement innovative concepts.


  1. Nice blog Help me in my final year project.

  2. Hello! Great write up but when I run the python command, my console only returns "No answer". I've tried modifying the commands to my local IP but I'm not sure if I'm doing something wrong. Not sure if you'll see this.