# OTA: Firmware Over-The-Air updates

Blynk offers an interface to easily update your devices over-the-air. It's called Blynk.Air

{% hint style="info" %}
OTA works only with ESP32, ESP8266, Seeed WiO Terminal, Arduino MKR1010, Arduino Nano 33IoT, and Texas Instruments CC3220. Raspberry Pi will be supported soon.

Currently, OTA can only work over WiFi
{% endhint %}

## Overview

The process of updating the device firmware over the air looks like this:

1. Prepare your board to accept firmware over the air from Blynk
2. Compile a binary file from your sketch using Arduino IDE
3. Create new firmware shipping and update device

## 1. Prepare your device for OTA updates

First, we need to prepare your device to work with Blynk.Air service. Follow the steps below to make it work

In Arduino IDE open the Blynk.Edgent example sketch for your board.

![image](https://user-images.githubusercontent.com/65705128/115250112-f0c76180-a131-11eb-96b3-8f3156c7a136.png)

Double-check that `Template ID` is defined in the sketch. You can always find the `TemplateID` in Blynk.Console →Template → General Settings

![image](https://user-images.githubusercontent.com/65705128/115251088-dcd02f80-a132-11eb-9ae6-c657c429b4a1.png)

![Replace these lines with your TemplateID](https://user-images.githubusercontent.com/65705128/115254884-75b47a00-a136-11eb-8fc4-e4305b7f68b3.png)

Upload this sketch to your device and make sure it shows up online in Blynk.Console and Blynk.Apps.

## 2. Compile a Firmware binary file

At this stage your device is ready to accept firmware over the air with Blynk. Now you can write your own code and deliver it wirelessly.

First of all, you need to change the Firmware version. Otherwise, your device will not know this is a new firmware and will ignore it.

In the code find the firmware version and increment it. For example, if it was `0.1.0`, change it to `0.1.1`. You should do it every time you plan to update your device with new version of code.

```cpp
define BLYNK_FIRMWARE_VERSION "0.1.1"
```

Now we need to export your code as a binary (.bin) file.

First of all, go to Arduino -> File -> Save

![image](https://user-images.githubusercontent.com/65705128/115255420-ebb8e100-a136-11eb-8fff-ab3e901f59f2.png)

Now go to Sketch -> Export compiled Binary

![image](https://user-images.githubusercontent.com/65705128/115255779-46523d00-a137-11eb-8420-1ab24f465265.png)

The `.bin` file is now in the same sketch folder with other files.

![image](https://user-images.githubusercontent.com/65705128/115256352-d09aa100-a137-11eb-91f5-cb8024c17222.png)

Now you are ready to ship it.

## 3. Create Shipping

1. Go to *Developer Zone* -> **Blynk.Air (OTA)** in Left Menu
2. Click **New Shipping** button
3. Specify Target Selection&#x20;

![](https://1839001309-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBFTVMf7L6S67HOuqVC%2F-MZNcoDabGjrZYKWxYUr%2F-MZNg5uhy2-1of9-Pn7_%2FTarget%20selection.PNG?alt=media\&token=624a00a5-1735-4006-a496-4fba1921d093)

4\. Select a **Template** available in the dropdown menu  \
5\. Select Devices available in the **Devices list** if you want to update certain devices.\
If you leave the selection empty, all of the devices made from this Template will be updated. \
6\. **Upload** **Firmware** file. Click the area with cloud pictogram and select .bin, .tar binary file in your PC file explorer. Drag'n'drop is supported.\
7\. Check **Firmware info**

![](https://1839001309-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBFTVMf7L6S67HOuqVC%2F-MZNcoDabGjrZYKWxYUr%2F-MZNguOjbrn7WU9m02-C%2Ffirmware.PNG?alt=media\&token=9991517c-f84f-456a-8bb3-3c2825f9c8aa)

8\. Check for **Optional Settings** under Template selection field and in \_\*\*\_Review and start area\
9\. Press **Start Shipping**

![](https://1839001309-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBFTVMf7L6S67HOuqVC%2F-MZNcoDabGjrZYKWxYUr%2F-MZNhJr4Qtnurm0Y4IAN%2Freview_and_start.PNG?alt=media\&token=62431894-b0e9-47ac-afdb-18fccfc51b98)

Now you are all set. The shipping has started.

You will see the progress of the shipping. You can close it, the shipping will continue working.

![](https://1839001309-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBFTVMf7L6S67HOuqVC%2F-MZNcoDabGjrZYKWxYUr%2F-MZNi4dHJlPFGI-eP-YT%2FShipping_in_Progress.PNG?alt=media\&token=657273e9-a48e-4833-b264-8bd90f855988)

You can always check your Shippings status and progress by accessing list of all OTA updates.

![](https://1839001309-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MBFTVMf7L6S67HOuqVC%2F-MZNcoDabGjrZYKWxYUr%2F-MZNigKjKaMV3mU-3i02%2FShipments_tab.PNG?alt=media\&token=c1451dc7-54ca-423d-9953-254fdee9bb9e)
