Home - peno64/ArduinoOTAwiki GitHub Wiki

Welcome to the ArduinoOTAwiki wiki!

To be able to upload a new sketch to the arduino 'over the air' (OTA), the first thing that must be done is replace the default bootloader with the Optiboot bootloader. The bootloader in the arduino is a piece of code that is run when the arduino boots up and it determines if the sketch is run or if a new sketch must be uploaded. The standard arduino bootloader does not allow to update a sketch via OTA. Therefore it must be replaced by the Optiboot bootloader which does make it possible. This is a one-time thing. Once the bootloader is replaced, you are done with that part.

Replacing this bootloader is not done the same way as a sketch is uploaded. You need a 'programmer' to be able to do that. That is some hardware between your computer and the arduino. There is specific hardware to do that, but it can also be done via another arduino. I did this via an arduino Nano and the arduino that I want to have OTA is an arduino Mega.

The first thing that must be done is upload a sketch to the arduino Nano, which will then acts as programmer for the Mega. The Nano is then a ISP (In-System Programmer). Don't worry, afterwards you can upload another sketch again to the Nano and it can be used again as a regular Nano.

This process is described in Replacing the Bootloader of an Arduino Mega Using an Arduino Nano. Note that at this point, the Nano is connected to the USB port of your computer and the Mega is connected to the Nano.

Once this is done, the Nano is no longer needed so disconnect everything and connect the Mega via USB to your computer. Now to install the Optiboot bootloader, follow the following instructions: Install new Optiboot bootloader.

So now you have a Mega with a new bootloader that is able to do OTA. So everything here above must only be done once.

The next thing is upload sketches. That can still be done via USB but now also via OTA. However OTA can only be done if there is some specific code in your sketch. So the first time after burning the new Optiboot bootload or after writing a standard skets without the OTA code, you cannot upload a sketch via OTA. That can be the demo sketch or you can put that code immediately in your sketch and upload it via USB. All this is described in Upload sketch with OTA. There is an important remark in there and I repeat it here again. While you are uploading a sketch OTA, Make sure that Serial Monitor is closed!!! If not there is a chance that the arduino is reset too soon and as result a corrupted sketch is flashed.. In that case you must upload your sketch again via USB.