Using Edge Impulse with the nRF Connect SDK¶
Edge Impulse is a development platform that can be used to enable embedded machine learning on nRF Connect SDK devices. You can use this platform to collect data from sensors, train machine learning model, and then deploy it to your Nordic Semiconductor’s device.
Support for Edge Impulse in the nRF Connect SDK is centered around the Edge Impulse wrapper, which is used for integrating the Edge Impulse machine learning model into an nRF Connect SDK application. The usage of the wrapper is demonstrated by the Edge Impulse: Wrapper sample, while the nRF Machine Learning application demonstrates the complete out of the box reference design.
Before integrating the Edge Impulse machine learning model to an nRF Connect SDK application, you must prepare and deploy the machine learning model for your embedded device. This model is prepared using the Edge Impulse studio external web tool. It relies on sensor data that can be provided by different sources, for example data forwarder. Check the Edge Impulse: Data forwarder sample for a demonstration of how you can send sensor data to Edge Impulse studio using Edge Impulse’s data forwarder.
The machine learning model is distributed as a single
zip archive that includes C++ library sources.
This file is used by the nRF Connect SDK build system to build the Edge Impulse library.
See the following section for steps required to generate this archive and add it to the build system.
To prepare the machine learning model, use Edge Impulse studio and follow one of the tutorials described in Edge Impulse getting started guide. For example, you can try the Continuous motion recognition tutorial. This tutorial will guide you through the following steps:
Collecting data from sensors and uploading the data to Edge Impulse studio.
You can use one of the development boards supported directly by Edge Impulse or your mobile phone to collect the data. You can also modify the Edge Impulse: Data forwarder sample or nRF Machine Learning application and use it to forward data from a sensor that is connected to any board available in the nRF Connect SDK.
Designing your machine learning model (an impulse).
Deploying the machine learning model to use it on an embedded device. As part of this step, you must select the C++ library to generate the required
zipfile that contains the source files for building the Edge Impulse library in nRF Connect SDK.
After preparing the
zip archive, you can use the nRF Connect SDK build system to build the C++ library with the machine learning model.
Complete the following steps to configure the building process:
Make sure that the following Kconfig options are enabled:
Enable and specify the Uniform Resource Identifier (URI) in the
CONFIG_EDGE_IMPULSE_URIKconfig option. You can set it to one of the following values:
An absolute path to a file in the local file system. For this variant, you must download the
zipfile manually and place it under path defined by the Kconfig option.
Any downloadable URI supported by CMake’s
file(DOWNLOAD)command. For this variant, the nRF Connect SDK build system will download the
zipfile automatically during build. The
zipfile is downloaded into your application’s
If the URI requires providing an additional API key, you can provide it using the following CMake definition:
EI_API_KEY_HEADER. The API key is provided using a format in which key_name is followed by key_value. For example,
aaaabbbbccccddddis a sample key_value. See Providing CMake options for more information about defining CMake options for command line builds and SEGGER Embedded studio.
Downloading model directly from Edge Impulse studio¶
As an example of downloadable URI, you can configure the nRF Connect SDK build system to download your model directly from the Edge Impulse studio. Complete the following steps to do this:
CONFIG_EDGE_IMPULSE_URIto the URI from Edge Impulse studio:
The XXXXX must be set to the project ID of your Edge Impulse project. You can check the project ID of your project in the Project info panel under Dashboard.
EI_API_KEY_HEADERCMake option as
x-api-key:aaaabbbbccccddddto provide the x-api-key associated with yout Edge Impulse project. You can access your API keys under the Keys tab in the Edge Impulse project dashboard.