arduino ota


Again, I started the adventure to create a platform for my future things which are connected with the Internet. As mentioned in the previous videos, I was so far able to connect to a web service program. The ESP modules, even when they are soldered on a small, PCB and load some initial information from the smartphone to the module programming with my programmer and the pogo pins, is not easy. If the thing is not reachable because it’s built into something so the guys around. Even developed a completely new method to load the software on an esp8266 module, we now can load it over the Wi Fi network or, as engineers say over the air, the abbreviation is OTA. This is extremely convenient and, in addition, quite fast in this video, I show you how to do it and, of course, also some tricks. I learned during my experiments. How is it done? Even and his friends took care that the necessary programs are already implemented in the Arduino one point: 6.5 version, so on our computers, everything is already there in the ESP sketch. However, some additions have to be made to our normal sketches. Just at the beginning, OTA works only with 4 megabyte flash chips. These chips are currently used in the ESP 12 II modules to find out, you can run a sketch and get the size of your flash. Currently, my ESP or 107 and 201 only have 512 K. Flash and cannot be used for OTA.

I already ordered bigger flash chips and if successful, I will show you in a later video on how to change them. Let’S start from what we know in the old world, we load a sketch to the module using serial communication on the ESP s and also on the arduino z’. There is a program called bootloader which takes all the necessary steps on the modules. Many arduino users even do not know about this program because it’s flashed during production. I call this bootloader serial bootloader, because serial boot loaders wait for input on the serial line. They are useless in the over the air world. We need a new Wi Fi bootloader function on the ESP. Currently we have to create this vibe bootloader ourselves and it is part of our normal sketch. Unfortunately, it has no protection mechanism against unattended changes like the serial boot loaders. The principle is the same. We have to put our modules somehow in a Wi, Fi bootloader state, and then it is ready to accept the sketch from the IDE very similar to the procedure with a serial line after the upload, the module boots, and we have to make sure it ends in Our regular sketch, I show you first how simple it works. We load the example provided with the IDE and adapt the access point name and password that the module can connect to our network after a while. A new port shows up the wireless connection to our module.

You choose the OTA communication protocol and this sport, the rest stays the same and off you go with uploading, a sketch, very simple in the OTA mode of the IDE. The serial console does not work anymore and I have to use a trick to show you what happens during upload. I use another serial communications program called potty to connect to the normal serial adapter. Then you still are able to see the result of serial print commands. You see here if I reset the ESP it goes directly into this Wi Fi bootloader mode connects to the Internet and waits for input from the arduino ide. You see here its IP address after the upload, the module automatically resets itself and again waits for programming input. Of course, in future sketches we have to make sure that the sketch goes into normal operation after a successful OTA upload. But for now we loaded a new sketch without any physical connection to the module through the air. Awesome let’s look into the Wi Fi bootloader sketch. It consists of two parts, one part which has to be in the setup and the other part which has to be in the loop in order to use our ESP module not only for a software update, but also for real applications. We have to add our normal sketch in both areas set up and loop. Just after reboot, the sketch has to decide whether it wants to do upload or normal operation.

We have to find a way to signal the board if we want to upload a new sketch or run it here is my example. In my thing, I need anyway to button switches for the normal operation, so during startup, if both buttons are pressed, the sketch goes into the Wi Fi bootloader mode and after the uploading of the sketch, the module goes directly into normal operation. Because I did not push the two buttons anymore, simple trick. Now I want to show you that this really works. I change the welcome text and upload the program. As you can see, the new sketch was really uploaded. Let’S now have a closer look at the code. I will not cover the technicalities of the OTA coding. There are much brighter people out there to explain that. I include a link below to the coding I used. I unleash oh you how to embed the two code snippets into your normal sketch. First, during startup, I have to check the two buttons or you do something else, to make sure that the ESP knows that you want it in the Wi Fi bootloader mode. Then I set the OTA flag and do the part of the OTA script, which has to be placed in setup. I call this part o da in it. If the buttons are not pressed, the sketch continues into normal operation and the OTA flag is set false. My loop is very simple: if the OTA mode was selected, the sketch goes to the OTA receive part, and if not, it goes to the normal loop that’s, all again, very simple, with Arduino Sui all use serial communication for debugging.

As I said before, this does not work here, but I already showed you the trick. I use connect a simple USB to serial adapter and a small program called putty to show the results of the serial communication like that we can debug as usual. Of course, this procedure is not used for modules placed in things, but to test your sketch it is a good way. I have also to mention that this procedure is not yet completely reliable. Sometimes it does not work and the upload is interrupted without an obvious reason. Unfortunately, then, the sketch was destroyed and I had to load it the old way through the serial cable. But I know these guys work hard and I’m sure they were resolve the issues or at least make sure that during an unsuccessful load we do not lose the original program and can try another time. So, as a summary, my workflow is as follows. I still use serial communication for development with a note, MCU board. This is more convenient, but from time to time I load the release to the thing over the air just to check if everything also works in the target system. Before that, I always upload it once over the air, to my note, MCU port, to make sure that the OTA part of my sketch really works before I flash it to my thing. This was all for today in the next video. I will look deeper inside the coding of such things to make them stable and responsive.


arduino ota Video







arduino ota news








arduino ota Social






See the world through the eyes of this camera-equipped, snake-like robot.
safe image.php?d=AQB2kdm3zOD71KQX&w=720&h=720& content%2Fuploads%2F2019%2F09%2FUntitled 2 3 - arduino ota

This 3D-printed prosthesis uses computer vision to adjust its grip depending on the object.
safe image.php?d=AQD dQbotzfS6mLl&w=720&h=720&url=fbstaging%3A%2F%2Fgraph.facebook - arduino ota
5mWnipCa normal - arduino ota
Tue May 08 01:25:53 +0000 2012

@Kai__Facts MicroPython is separate from anything Arduino IDE related. You can upload and run a Python file using MicroPython. Some modules even do OTA updates

XgRAw9SX normal - arduino ota
Wed Mar 28 15:20:02 +0000 2007

RT @LuisLlamas: Nuevo tutorial del ESP8266, la muy interesante programación OTA
“Cómo programar el ESP8266 por WiFi con Arduino OTA”









(Visited 10 times, 2 visits today)

About The Author

You might be interested in

Comment (50)

  1. Thank you for your videos, they are really interresting! You open so many “doors” for our schools projects!
    If I may ask you an advise, my students and I are working on a school project with an ESP8266. We need a sub program (only activate on boot of the program by a special input during the first 3 sec) to start the Wifi to get update OTA like the one you show in that video. We try so many things, it seems to work but the wifi is always on and we don’t want that (wifi on only when this sub program is activate).
    May we ask you to take a look of our small program to help us find how to get only wifi activate when the sub program is chose?
    My students and I thank you in advance.

    1. Did you try WiFi.disconnect() or WiFi.mode(WIFI_OFF)? I do not know if it works.
      Another possibility could be to use ESP.deepsleep for 1 microsecond and wake-up with WiFi disabled (after you did the OTA update).

      “ESP.deepSleep(microseconds, mode) will put the chip into deep sleep. mode is one of WAKE_RF_DEFAULT, WAKE_RFCAL, WAKE_NO_RFCAL, WAKE_RF_DISABLED. (GPIO16 needs to be tied to RST to wake from deepSleep.)”

      You can also have a look at my videos concerning IOTappstore, which give you another possibility for OTA.

  2. Hi Andreas,
    Thanks for your contribution clarifying how OTA works on the ESP8266 board.
    I have successfully implemented OTA to my ESP12E/ESP8266 board and my OTA uploads work quite right !
    I still have an issue, though.
    I understand that the serial monitor can NOT work over the air on the same port that the one that has been used for OTA (well, ESP8266 is not supported this way within the Arduino/IDE).
    However, monitoring my program is mandatory for me and I would like to be able to monitor it via Wifi when it runs.
    I saw in your video that you’re using Putty to monitor it on COM13 !
    How did you manage to establish a link between COMxx and the WiFi connection to the ESP (192.168.100.xx in my case)
    I have tried many other options to no avail (Telnet, SSH …)

    1. Hallo Andreas,
      es macht gut (ich meine ‘Lopes_RemoteDebug’) !

      However, a few remarks (maybe I am doing something wrong) :
      #1 Telnet has to be closed then reopened again everytime the ESP is RESET, otherwise a Telnet network error window pops up
      #2 RemoteDebug’s Telnet session is VERY slow to startup, meaning that any debug.print statement in the void setup() section is definitely lost (I use to monitor scrupulously the initialization of the WiFi connection, and now, without the serial monitor, this info is lost … not enough time to debug.print it !)
      #3 Is there any way to speedup somewhat the Telnet baud rate, it looks like a 300bauds TTY back in the 70’s !

      Thanks again for your precious hints.

    2. 1. Yes, it resets
      2. If I need this info, i put a delay(5000) at the beginning of the setup. This gives me time to start the telnet. But somethings I still debug with Serial. remotedebug is more for production environments and monitoring
      3. I do not know about the speed. Sometimes it is quite fast, sometimes not. I have no clue about telnet, I just use it 😉

  3. Hi Andrea,

    #1 Just for my understanding : where is stored the OTA info in the ESP memory and how does it work (roughly) ?
    I am asking you so because I can understand that OTA still works quite well as long as the ESP is within reach of the router it has ***INITIALLY*** signed and connected to (by ways of ‘ESP_BasicOTA.ino’) … but what happens if I switch to another router and still want to OTA my ESP ?
    Do I have to run once again the ‘ESP_BasicOTA.ino’ with the new credentials to force the ESP to memorize these in its memory ?

    #2 Just a (kinda) cosmetic question : how comes that, after a ***successful*** OTA upload, the IDE bottom window displays 2 error lines like below :

    Uploading ………………………………………………………
    19:17:29 [ERROR]: No Result!
    19:17:29 [ERROR]: No Result!

    Have you seen these error messages on your side and if so, do I really have to worry about it (I confirm again that the uploading ended successfully) ?

    Thanks again for your work.

    1. +Yann M I only use webupdate, not the normal Arduino OTA. So, I cannot answer your questions. I just guess, that your ESP has to have a connection to the WiFi to do OTA. This is independent from OTA. To connect to any WiFI, it needs the credentials. Otherwise, the access point will not connect.

  4. thumbs up a good tutor of OTA…. u may be interested by this Ai personal home robot, U.S. garage companies are coming up, California garage company CAMinux successfully use their Ai-robot to make surveillance and car dashboard cameras at labor-free-cost, HD 1080p price as low as from $20. Search “CAMinux” at Youtube, or the link

    1. I am not in cameras. And I think, 4 k and Raspby is probably not a very performing combination, if you want recognize something…

    1. +Artur Z No, i do not think so. There are Tutorials around and since I work with the ESPi never used a combination of both. So, I have no know-how

  5. Hello,
    I am using Arduino IDE 1.6.8 and esp8266 board version 2.3.0,
    but under File->Example->ESP8266mDNS I do not find your OTA example?

    Do you know why?

    1. This is a quite old video and I did not play with this functionality. I changed completely to webupdate (see my newest video). I think, you find examples under “Arduino OTA”, but I am not sure

    2. Thanks for your reply.
      I have seen your videos about IoTAppStory and an update is definitely better.
      I would prefer to wait for some time prior to try it.
      I am not very good as an early adopter…

  6. Can i do the OTA from anywhere in the world?
    For Ex :Programmer in US and ESP8266 or node MCU in INDIA.IS it possible with the above

    1. Sorry for my bad english. Scheduled tasks in the module, for example, I set up the day and time, when this time is reached, some action takes place. As it is implemented for example in sonoff, the scheduled task is configured at a certain time, in the application, and then written to the module. The task is executed regardless of whether the module is connected to the Internet or not. Independent scheduler in the module.

    2. You find a similar thing in video #7. But it does not work properly without internet connection, because the ESP8266 has no internal RTC.

    3. Do you mean #71? In this video is just what I need, but there’s one task is configured at a specific time. How to do multiple tasks with the ability to set the time and day, e.g. for MQTT. So for example in the application, you configure the timer task, but the task is recorded in the device itself and does not work in your application and sends a command to the device. Sorry if I was not clear explain.

  7. Hi partner…have you tried (or are aware of) this awesome module? they claim an incredible 100 kmtrs range!! (that supouses a 16 mtrs height antenna, however)…
    btw it’s built in your country….
    they did not reply me if they sell online or thru aliexpress or any other thing…
    perhaps its a few blocks frm your house! lol

    1. I think, they are business to business. If you want, you can also watch my videos about LoRa. If I remember right, this is the same technology they use

  8. hello,

    i am new to use node mcu. i am trying to write interrupt handler to receive data through uart.
    when node mcu receives any data on uart it shud go in the interrupt handler.
    please help me out with this.

    thanks in advance.

  9. Hello sir, I am following your videos and so far, i have re-achieved most of them. You are really good mentor for the humanity of course!. I do my master thesis, this year. Last semester i have graduated and my thesis about ” Smart Home Automation on Esp8266 Wireless Sensors “. This year i am developing that project and i stuck at OTA problem, which causes ” wdt reset ” and requeries manuel reset. Sadly, as result i couldn’t find any solution. Can you show me a way, please?

    1. Remote diagnostics for hard problems is not easy/possible. And I assume, your problem is hard.
      Maybe you are aware of my videos about, which takes a different approach to OTA. I suggest to try them out if not done yet.

    2. Are you using deep sleep? If so, you might not be generating the interrupt correctly or you might be using your boot configuration pins ( 0, 2, 15 ) for something else and the chip is resetting.

  10. I had problem with the Wifi port not showing even if I restart my Arduino IDE. Solution:
    1. make sure your PC is on same wifi network as on which you configured your boot loader program.
    2. if still doesn’t works, go to preference > Network and turn off proxy , restart IDE.
    3. if still doesn’t works, make sure your Wifi network is not blocking some contents from Firewall (usually happens in Universities or restricted Wifi networks)

  11. Hallo Andreas, ich habe vor kurzem angefangen mich mit den ESP8266 Teilen zu beschäftigen und bin dadurch auch auf Deinen Kanal gestoßen. Hat mir sehr geholfen. Bei OTA hänge ich jetzt aber und ich hoffe Du kannst mir helfen.
    Ich habe 2 unterschiedliche ESP8266 Module gekauft, um mal zu testen, was mir am meisten zu sagt. Eines ist ESP8266-F mitz 4M flash ohne USB Anschluss und eines ist das NodeMcu Lua ESP-12E WIFI Development Board. Bei letzterem funktioniert alles wunderbar. Beim ersten kann ich zwar per FTDI Adapter die Software flashen, aber per OTA klappt nichts. Irgendwie kann keine Verbindung aufgebaut werden, obwohl das ESP8266 im WIFI angemeldet ist. Ich kann sogar per MQTT die interne LED ein und aus schalten. Nur OTA funktioniert halt nicht, obwohl ich das gleiche script drauf habe, wie beim Development Board. Woran könnte das liegen? Vielleicht hast Du eine Idee. Würde mich freuen.
    73 de OE4HDS

    1. Hallo Andreas, nachdem ich heute Nachmittag Stunden damit verbracht habe, das Problem zu lösen, konnte ich es gleich, nachdem ich Dich hier um Hilfe gebeten hatte selber lösen. Ich musste einfach die Verbindung von GPIO0 zu GND kappen. Ich bilde mir ein, dass ich das heute Nachmittag aber schon ohne Erfolg gemacht hatte, aber nach alledem weiß ich jetzt nicht mehr sicher, ob das stimmt. Jedenfalls funktioniert es jetzt wunderbar.
      Ich habe aber in meiner loop() den kompletten code ohne Bedingung drinnen, also ArduinoOTA.handle(); und den normalen Programmcode. Da wird immer alles ausgeführt. Funktioniert und man muss beim OTA keine Buttons drücken oder sonstwas machen. Keine Ahnung, ob das einen unerwünschten Sideeffect hat. Mal sehen.

    1. I do not know. Usually, the time to transfer our small data is very short compared to all other things like establishing the connection or connect to Wi-Fi

  12. When I upload the bootloader code to the esp12e, I dont find my device in the port section. I restart the IDE and I added arduino to the softwares allowed in the firewall but I still get nothing. Any help please?

  13. Hi! I have an ESP32. I’m using the library httpUpdate for OTA Updates. What is the difference between httpUpdate and ArduinoOTA? Thanks

  14. Hi Andreas! Good video, congratulations! I would like to ask you if there is a way to do the same but over the internet. I will appreciate your response. Thanks for sharing all your knowledge with us!

  15. Are there new information for the esp8266-01 module? I often use them and it would be much easier to flash them ota.


Your email address will not be published. Required fields are marked *