The new IoT Cloud brings a lot of new things, and one of them is the OTA (over-the-air) feature. This feature allows you to upload programs wirelessly to your Arduino boards. This way, as soon as you have a compatible board connected to a WiFi network and configured to work with OTA, you won’t need to physically connect the board to the computer in order to upload new sketches to it. Instead, everything will work over-the-air.
Over-the-air update is now available through Arduino IoT Cloud and the Arduino Web Editor, which is an always up-to-date online IDE that stores sketches in the Cloud. It also allows you to wirelessly upload sketches from a browser, to any board that is connected to that computer.
This tutorial will guide you through the necessary steps to configure your board to work with the OTA feature.
Below is a list of all boards that supports OTA through the Arduino Cloud.
In order to configure the feature, we will need to create a project in the IoT Cloud following the next steps.
1. Go to the IoT Cloud by opening the grid menu in any Arduino Site.
Note: You will need to have an Arduino account to be able to use both the Web editor and IoT Cloud features.
2. Once you are logged in the IoT Cloud, you need to create a new thing and name it “smart_led”. Inside the thing let’s include a boolean variable called
, activate the interaction Modify from dashboard API and select the on change variable update. Once we have these characteristics set, click on add variable.
Note: If you want to know more about how to get started with the Arduino IoT Cloud, visit the getting started tutorial.
3. Once you have added the variable, you’ll need to associate your device (Arduino MKR WiFi 1010 or Arduino Nano 33 IoT) to this new thing and add your network credentials.
Note: If it is the first time you configure the MKR WiFi 1010 or the Nano 33 IoT board to the IoT Cloud, you will need to have the latest version of the WiFi Nina firmware installed. The configuration process updates it automatically. However, if you get any error during the configuration process, you can manually update the FW version of the Nina module following these instructions.
4. Next step is to create a dashboard with a Switch widget, linked to the lights variable that you created before. Once it is set, click on the use dashboard button and go to things > smart_led > Sketch
5. It is time now to edit the sketch. Let’s create a program that turns ON/OFF the
embedded on your board. To do so, you will need to add just four lines of code to the auto generated sketch:
the boolean variable
at the beginning of the program.
pin of the board in the
pin with the
variable in the
function. To do so, let’s use the
led_status = !led_status
auto generated function.
Check the highlighted lines in the following code to see what required changes are.
6. Once the sketch has uploaded to your board, let’s check that everything is working as it should. To do so, go back to the IoT Cloud and once in there, go to the smart_led dashboard we created before. Now, when you turn the light widget in the dashboard ON or OFF, the LED in your board should also turn ON or OFF.
Now that we have checked that everything is working as it should, let’s go back to the Things > smart_led > Sketch tab in the IoT Cloud, and see what has happened there.
Once in the sketch tab, let’s open the board's drop down menu. There, a new option to connect our board should be available. The name of the board configured for the cloud will appear, followed by the Over-the-Air option.
If you select this option, you should be able to upload sketches to your board wirelessly. Let’s learn how to do it, by following the next steps.
1. Let’s modify the program in order to blink the LED each second when we click the button ON, and switch it Off when the button OFF is pressed. To do it, you will need to modify the
function by adding the highlighted lines shown in the following sketch.
2. Power your board from a different power supplier than your computer's USB cable. Powering it through a phone charger's USB should be enough.
3. Once you have powered the board from a power source other than your computer, you should only see the Over-the-Air option. Select it, and upload the program to the board.
Note: This option will take a bit longer than usual, since the process of compiling and uploading the program to the board over-the-air is a longer process.
4. Now, if you switch the widget on the IoT Cloud dashboard ON and OFF, the LED will either blink every second or go off.
An IoT Cloud sketch is generated by the IoT Cloud application, it leverages the Arduino IoT Cloud and Arduino Connection Handler libraries to give your sketch IoT powers.
When uploading a sketch over-the-air:
In order to upload sketches Over-the-Air to your Arduino board you need:
If you want to continue learning about amazing IoT features or projects you can check:
You can find more tutorials in the Arduino IoT Cloud documentation page.