ESP8266 OTA Example Arduino Code Tutorial | Over The Air Update Reviewed by Momizat on . Updating Code via internet without any USB or Serial Interface is called as “Over The Air” or OTA.  OTA is very simple when it comes to implement using Arduino Updating Code via internet without any USB or Serial Interface is called as “Over The Air” or OTA.  OTA is very simple when it comes to implement using Arduino Rating: 0
You Are Here: Home » IOT » ESP8266 OTA Example Arduino Code Tutorial | Over The Air Update

ESP8266 OTA Example Arduino Code Tutorial | Over The Air Update






Updating Code via internet without any USB or Serial Interface is called as “Over The Air” or OTA.  OTA is very simple when it comes to implement using Arduino IDE. There are simple six steps involved in OTA of ESP8266.

  1. Connect ESP8266 to Arduino IDE using USB or Serial
  2. Upload OTA code
  3. Connect to wifi network
  4. Choose wifi port in arduino
  5. Remove USB or Serial From esp8266
  6. Upload New Code over the air.

Things You Needed:

You need to install these bellow software to be installed on your windows PC.

  1. Arduino IDE
  2. ESP8266 Library( Installation steps).
  3. Python 2.7 or Higher (Python is necessary to send Update using OTA)
  4. Node MCU or Esp8266

Download and Install all above software on your system.

Software Configuration:

Once you installed arudino and library for esp8266, installing python is bit tricky. You need configure the Environment variable to detect python on the path. Follow below steps to install python.

Step 1:

python-installation-1-my-electronics-lab

Check the Install for all users radio button, then click on next.

Step 2:

python-installation-2-my-electronics-lab

Remember the path you are installing the python, click on next.

Step 3:

python-installation-3-my-electronics-lab

Select “Will Be Installed on local drive”, then click on next.

Wait some time, Installation to be finished.

Step 4:

Right Click on my computer and click on properties.

pythong-enviourment-variable-setup-1-my-electroncis-lab

Step 5:

pythong-enviourment-variable-setup-2-my-electroncis-lab

Click on “Advance System Setting” then Click on Environment Variable.

Step 6:

pythong-enviourment-variable-setup-3-my-electroncis-lab

Then Click on New — > Add a variable Name — > Then on Variable Value Section, add following

C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27;

Then Click on ok to save and Restart Your PC.

Arduino OTA Code:

Once we are rebooted your PC. Connect ESP8266 to your PC using serial port.

  1. Open Arduino IDE,
  2. Go to Tool — > Choose board — > Select Node MCU or ESP8266 as per your need
  3. Choose Serial PORT — > In my case its COM 3
  4. Then Go to file — > Example — > Arduino OTA — > BasicOTA
  5. Open The Code
  6. Change Your SSID and Password as per your local wifi network.
  7. Compile and Upload Code.

Then You have successfully updated the OTA code. Open Arduino Serial Monitor, and you can see the IP address of your esp8266. Like below.

arduino-com-port-esp8266-my-electronics-lab

Then Close Arduino IDE and Open it again.  You can see new PORT in tools — > PORT section  like below.

ota-port-esp8266-in-arduino-ide-my-electroncis-lab

Now choose the new OTA port.

You can remove your  USB/Serial Cable from PC and now you can power your ESP8266 using any other power source, like I had powered using a Battery Bank.

ota-esp8266-battery-power-my-electronics-lab

Now you can upload any code ESP8266 over wifi using OTA.

But if you will  upload any random code to esp8266 , you will loose your OTA code. So every time, when you are writing new code, you also have to OTA code in the your logic code.

Like in the blow code, I had implemented simple led code along with OTA code.

You can watch this Complete Step By Step video , of above tutorials in action.

Do Let us know, If you have any doubt regarding OTA in the comment section below. Don’t forget to share  with your friends, so that others can also get benefited.

About The Author

I am a maker, who loves to think, hack and build new electronics stuff, I always find time to document , share my knowledge with others. I am graduate in BTech(Electronics and Communication Engineering).

Number of Entries : 41
  • hootan

    hi can we use this code only on esp8266 via ftdi and then connect it to arduino uno via serial .then update uno code???

  • Gaurav Bansal

    network port not showing up, pls help, done all things

  • Bruce Calder

    Hi, very nice instructions. I have tried this many times now on various ESPs, various Arduino IDEs (1.6.5, 1.6.8 and 1.8.1) but I cannot get the network port to show up. Can you please provide insight as to why? thanks.

    • Rochak Saini

      Restart your IDE.

Scroll to top