with Arduino IoT Cloud
Introduction
This page is part of the Lifecycle Management with Edge Impulse tutorial series. If you haven't read the introduction yet, we recommend you do so here.
In this tutorial, we'll guide you through deploying updated impulses over-the-air (OTA) to Arduino using the Arduino IoT Cloud and Edge Impulse.
Let's get started!
Prerequisites:
Edge Impulse Account: Sign up here.
Trained Impulse: If you're new, follow our data acquisition and impulse design guides.
Key Features of Arduino OTA Updates:
Remote Update: Update your Arduino board firmware remotely.
Integration with Edge Impulse: Seamlessly incorporate machine learning models.
OTA Code
Here’s an example Arduino sketch for implementing OTA updates with Edge Impulse:
To expand the Arduino sketch to work with the Edge Impulse API, you'll need to add functionality to fetch the latest model updates from Edge Impulse and apply them to your device. Below is an extended version of the loop()
, connectToWiFi()
, and onOTAEvent()
functions, integrating Edge Impulse API interactions:
loop()
Function
loop()
FunctionThe
loop()
function regularly checks for updates from the Edge Impulse API.
connectToWiFi()
Function
connectToWiFi()
FunctionThe
connectToWiFi()
function includes a maximum number of attempts to connect to WiFi.
onOTAEvent()
Function
onOTAEvent()
FunctionThe
onOTAEvent()
function is triggered when a new update is available, downloading and applying the update.
This sketch sets up the Arduino to connect to the Arduino IoT Cloud and listens for OTA update notifications. When an OTA update is available, the onOTAEvent
function is called, where you can implement the logic to download and update the firmware.
Preparing for OTA Updates
Setup Arduino IoT Cloud: Configure your device and variables in the Arduino IoT Cloud.
Connect your device: Ensure your Arduino board is connected to the internet.
Integrate with Edge Impulse: Export your trained impulse from Edge Impulse as an Arduino library.
Steps to Deploy Impulse to Arduino
Update Sketch: Incorporate the Edge Impulse library into your Arduino sketch.
Listen for OTA Updates: Use the Arduino IoT Cloud to push OTA updates to your device.
Test and Monitor: After deploying the update, monitor your device's performance and ensure the new impulse is functioning correctly.
Components
ArduinoIoTCloud: Manages cloud connectivity and OTA updates.
WiFiNINA: Handles WiFi connections for compatible boards.
Conclusion
This tutorial provides a basic guide for implementing OTA updates on Arduino boards using the Arduino IoT Cloud and integrating with Edge Impulse. Expand and develop this example to suit your project's needs. Remember, testing is crucial before deploying updates in a live environment. Happy coding!
Last updated