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 to do so here. In this tutorial, we’ll guide you through deploying updated impulses over-the-air (OTA) to the ESP32 using Edge Impulse. We’ll build on Espressif’s end-to-end OTA firmware update workflow, incorporating Edge Impulse’s API to check for updates and download the latest build. We will modify the Edge Impulse C++ example for ESP32, and combine it with the OTA example from the ESP IDF repository. This will allow us to check for updates to your project on the server side of the IDF example and download the latest build. We will then modify the C++ example to incorporate the OTA functionality and update the device with the latest build. Finally we will add calls back to our ingestion service to monitor the performance of the updated impulse, and gather data. Closing the loop on our active learning cycle. Let’s get started!Key Features of Espressif OTA Updates:
Prerequisites
- Edge Impulse Account: If you haven’t got one, sign up here.
- Trained Impulse: If you’re new, follow one of our end-to-end tutorials
- Knowledge of the ESP IDF development framework and C++ for ESP32
- Installation of required software as detailed in the tutorial
Preparation
Begin by setting up your device for OTA updates following Espressif’s OTA firmware update workflow. Use the built binary from the C++ example and modify it to incorporate OTA functionality. Let’s get started!On your Espressif ESP-EYE (ESP32) development board
We created an example repository which contains a small application for Espressif ESP32, which takes the raw features as an argument, and prints out the final classification. Download the application as a .zip, or import this repository using Git:ESP IDF OTA
We are going to use the ESP IDF OTA example as a starting point. Running a python server to check for updates and download the latest build from edge impulse. This detemines if there is a new build available and downloads it to the device.You could add more advanced checking for model performance and versioning to this process. This example will only download the latest build if there is a new build available based on date to save lengthy code examples. This example is available in the ESP IDF repository. You can find the example in:Step 1: Copy the IDF OTA example and clone a fresh version of the edge impulse example C++ inferencing repository
Now we will set up the Server Side components of the OTA update process
1. Python Server Side OTA
Modify the ESP OTA example python server to check for updates to your project, we will use the date to determine when a new update should be performed to keep things simple. You could add more advanced checking for model performance and versioning to this process. This example will only download the latest build if there is a new build available based on date to save lengthy code examples.2.
Building the firmware to deploy to our device in the field. We will use the IDF build system to build the firmware. This would be automated but again to save time and complexity we will do this manually.3. Updating the Device
Compare the model’s timestamp or hash with the stored version. If it’s different or newer, call the download_model() function.4. Monitoring and Repeating the Process
Monitor the device to ensure the new impulse performs as expected and repeat the update process as needed. Here we would make calls back to our ingestion service to monitor the performance of the updated impulse, and gather data. Closing the loop on our active learning cycle.Device Side of the OTA Update Process
Now lets modify the C++ example to incorporate the device side of the OTA functionality and update our edge impulse project with the device side data. We will add the OTA functionality to the C++ example and update the device with the latest build.Step 1: Include Necessary Headers
Include the necessary headers and components in your main ESP32 C++ based edge impulse project. There are a number of components that are required for the OTA update process:Components
1. Non-Volatile Storage (NVS)
2. HTTP Client
3. OTA Operations
4. FreeRTOS Task
http://192.168.1.10/your-ota-firmware.bin
with the actual URL where your firmware binary is hosted.
Step 4: App Main Here’s how the app_main function should look like:
http://192.168.1.10.com/your-ota-firmware.bin
with the actual URL where your new firmware binary is hosted. Make sure that your ESP32 is connected to the internet to access this URL. Also, always test OTA functionality thoroughly before deploying it in a production environment.