Example application code for running a SensiML Knowledge Pack on Arduino boards, for the Nano33 BLE Sense
In order to run a Knowledge Pack, you must first have a model generated via SensiML Analytics Studio.
When downloading a model, you will need to select Arduino Cortex M4 ARM GCC 8.2.1
from the target device.
This will give you the option to build a library configured properly for a Cortex-M4 based Arduino device.
Unzip the download to a location of your choosing. In the folder, you will find the following directories:
- knowledgepack/
- knowledgepack_project/
- libsensiml/
Copy the files from libsensiml
to lib/sensiml. It is ok to overwrite these, but do not commit them in a pull request. The files provided in this repository are for examples only.
Copy the files from knowledgepack_project
to src/
This should be sml_recognition_run.cpp
, which will contain the necessary model running code to enable recognition on the device.
Build/upload the firmware.
If you wish to run the IMU at a different frequency (default for data capture and this example is 119 Hz), modify the ACCEL_GYRO_DEFAULT_ODR
in include/sensor_config.h
As the Data Capture Lab of the SensiML Toolkit does not actively configure the device, a capture configuration isn't generated when creating the model code.
For Serial output, simply connect to your Nano33 via any serial monitoring application. You should see an output similar to this:
{"ModelNumber":0,"Classification":2,"FeatureLength":33,"FeatureVector":["2","0","253","252","93","217","0","0","0","0","0","0","205","221","255","183","0","0","0","1","1","0","0","1","0","1","0","0","2","0","4","145","19"]}
When running a model built using TensorFlow Lite in a SensiML Knowledge Pack, another environment is provided in the code base.
The environment env:nano33ble_with_tensorflow
will automatically link TensorFlow from a model download into the application