Upload a Sketch to a Broken Arduino Using a Working One
Uploading sketches Over-the-Air (OTA)
The new IoT Cloud brings a lot of new things, and ane of them is the OTA (over-the-air) feature. This characteristic allows yous to upload programs wirelessly to your Arduino boards. This style, as presently as yous have a compatible board continued to a WiFi network and configured to work with OTA, you won't need to physically connect the board to the estimator in order to upload new sketches to it. Instead, everything volition work over-the-air.
Over-the-air update is at present available through Arduino IoT Cloud and the Arduino Web Editor, which is an always up-to-engagement online IDE that stores sketches in the Cloud. It also allows yous to wirelessly upload sketches from a browser, to any lath that is connected to that computer. OTA is compatible with the Arduino NANO 33 IoT and Arduino MKR WiFi 1010 boards.
This tutorial volition guide y'all through the necessary steps to configure your board to work with the OTA characteristic.
How does it work
In order to configure the characteristic, we volition demand to create a project in the IoT Cloud following the next steps.
- Go to the IoT Cloud by opening the grid menu in any Arduino Site.
Note: Y'all will demand to accept an Arduino account to be able to use both the Web editor and IoT Cloud features.
- Once you are logged in the IoT Cloud, you need to create a new thing and proper name it "smart_led". Within the thing permit's include a boolean variable called
light, activate the interaction Modify from dashboard API and select the on change variable update. Once we have these characteristics gear up, click on add together variable.
Note: If you lot want to know more about how to get started with the Arduino IoT Cloud, visit the getting started tutorial.
- One time you accept added the variable, y'all'll demand to associate your device (Arduino MKR WiFi 1010 or Arduino Nano 33 IoT) to this new matter and add together your network credentials.
Note: If information technology is the outset fourth dimension you lot configure the MKR WiFi 1010 or the Nano 33 IoT board to the IoT Deject, y'all will need to take the latest version of the WiFi Nina firmware installed. The configuration procedure updates information technology automatically. However, if you lot get any error during the configuration procedure, you can manually update the FW version of the Nina module following these instructions.
- Adjacent pace is to create a dashboard with a Switch widget, linked to the lights variable that you created before. Once it is gear up, click on the use dashboard button and become to things > smart_led > Sketch
- Information technology is time now to edit the sketch. Allow's create a program that turns ON/OFF the
LED_BUILTINembedded on your lath. To do so, you volition need to add only four lines of code to the auto generated sketch:- Initialise as
falsethe boolean variableled_statusat the first of the plan. - Set every bit
OUTPUTtheLED_BUILTINpin of the lath in thesetup()office. - Modify the state of the
LED_BUILTINpin with theled_statusvariable in theloop()function. To do so, let's employ thedigitalWrite()statement. - Add the statement
led_status = !led_statusinside theonLightChange()auto generated part.
- Initialise as
Cheque the highlighted lines in the following code to come across what required changes are.
- Once the sketch has uploaded to your lath, let's cheque that everything is working equally it should. To do so, go back to the IoT Cloud and once in there, go to the smart_led dashboard nosotros created before. Now, when you turn the light widget in the dashboard ON or OFF, the LED in your lath should also plough ON or OFF.
Now that we have checked that everything is working every bit it should, let'southward go back to the Things > smart_led > Sketch tab in the IoT Deject, and see what has happened at that place.
In one case in the sketch tab, let's open the board'south drop down bill of fare. In that location, a new selection to connect our lath should be available. The proper name of the board configured for the deject 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'southward learn how to do it, by following the next steps.
- Allow'southward modify the program in order to blink the LED each second when nosotros click the push ON, and switch it Off when the push OFF is pressed. To do it, you volition demand to modify the
loop()function by calculation the highlighted lines shown in the following sketch.
- Power your board from a unlike power supplier than your computer'south USB cablevision. Powering information technology through a telephone charger's USB should be enough.
- In one case you take powered the board from a power source other than your computer, y'all should simply run into the Over-the-Air option. Select it, and upload the plan to the lath.
Note: This option will accept a chip longer than usual, since the process of compiling and uploading the program to the board over-the-air is a longer process.
- At present, if y'all switch the widget on the IoT Cloud dashboard ON and OFF, the LED will either blink every second or go off.
Just how does it piece of work, inside?
An IoT Cloud sketch is generated by the IoT Cloud application, it leverages the Arduino IoT Cloud and Arduino Connection Handler libraries to requite your sketch IoT powers.
When uploading a sketch over-the-air:
- The sketch is compiled for the selected board blazon.
- The compiled file is stored in a AWS S3 saucepan.
- OTA file url location is associated with the target device.
- OTA_REQ flag set to truthful to instruct the board to start the OTA file download.
- OTA file length/CRC is verified.
- Updated sketch is flashed on the board.
Conclusion
In order to upload sketches Over-the-Air to your Arduino lath you lot need:
- An Arduino NANO 33 IoT or Arduino MKR WiFi 1010 lath.
- NINA firmware on the board, updated to version one.4.1 or after.
- An IoT Sketch to be uploaded.
Next steps
If you desire to continue learning about amazing IoT features or projects you can bank check:
- Oplà IoT Kit
- Other IoT tutorials
- Cheque projects in project hub
Author: José García
Reviewed by: Nefeli Alushi
Appointment: [11/12/20]
Source: https://www.arduino.cc/en/Tutorial/ota-getting-started/
0 Response to "Upload a Sketch to a Broken Arduino Using a Working One"
Post a Comment