Home

Awesome

FogML-Zephyr-FOTA

The application is the result of research conducted jointly with the AVSystem. It demonstrated how the LwM2M protocol may support TinyMLOps on resource-constrained devices. The source code supplements the research paper submitted to the TinyML symposium. More details will be provided at a convenient time.

Code of the application is based on https://github.com/AVSystem/Anjay-zephyr-client/tree/master/demo.

TinyML lifecycle Management

MLOps

The figure shows how the LwM2M protocol enhances the Tiny ML model development process for resource-constrained devices. The proposed enhancement consists of 4 states:

To sum up, the following LwM2M Objects are supported by the application to support MLOps:

In the LwM2M_objects_def folder, XML object definitions are presented. They can be added to the AVSystem Coiote LwM2M server to visually display the object values in the GUI.

Supported hardware

The application is designed for Thingy:91 device:

Thingy:91 integrates an nRF9160 SiP that supports LTE-M and NB-IoT connectivity.

Building the project

The project can be built as in the Anjay client description. Alternatively, the default SDK installed with the nRF Connect utility can be modified to use Anjay LwM2M client. To do this, edit the file [default_sdk_folder]/ncs/v2.0.0/nrf/west.yml by adding:

  - name: Anjay-zephyr
    submodules: true
    remote: anjay
    revision: 3.1.2
    path: modules/lib/anjay

and

  - name: anjay
    url-base: https://github.com/AVSystem    

Then, according to https://nrfconnect.github.io/vscode-nrf-connect/connect/west.html :

To update a west workspace:

    Open the Command Palette and type nRF Connect: West Update
    Choose the location of your project repository and west begins to update.

Choosing the FogML MODEL

In the application, we use FogML tools to recognize device movement patterns. To simplify the process of ML model integration and selection, each ML model is stored in the seperatefolder i.e. MODEL1, MODEL2, etc. Then using Kconfig proper one can be selected and compiled with the firmware.

Choosing FogML MODEL

There are two models in the source code:

In addition, there are pre-compiled images in the binary_images directory for quick testing of applications for Thingy:91. These images can be sent to the device using FOTA.

In order to fit the ML models in Thingy:91 memory, GPS has to be switched off in Kconfig.

Controlling FogML on the device using Zephyr Shell

FogML processing pipeline can be controlled via Zephyr Shell:

ML model and firmware upgrade using FOTA

LwM2M supports FOTA process through Firmware Update (/5) object. Follow the instructions provided in the Anjay Zephyr Client and Coiote Server.

Connecting to the LwM2M Server

To connect to Coiote IoT Device Management LwM2M Server, please register at https://eu.iot.avsystem.cloud/, and then follow the instructions in Anjay-Zephyr-Client.

Click "Add your fitst device" "via the Management Server" "Put enpoint name" and "Key"

click "Add device" and configure Thingy:91 using Zephyr Shell:

uart:~$ anjay config set uri coaps://eu.iot.avsystem.cloud:5684
uart:~$ anjay config set endpoint ...
uart:~$ anjay config set psk ...
uart:~$ anjay config save
uart:~$ anjay start

NOTE: You may use any LwM2M Server compliant with LwM2M 1.0 TS, however the aforementioned LwM2M objects definition can be added in the Coiote Server.

Summary

To summarise, TinyML solutions are a milestone in developing Internet of Things systems. However, it is necessary to ensure service enablement mechanisms, over-the-air firmware updates, and secure connectivity to cloud computing services to take full advantage of this class of solutions. Furthermore, using low memory footprint ML libraries such as FogML leads to flexibility in designing more complex and connected embedded applications. Finally, requirements related to device management and data reporting can be satisfied by the LwM2M protocol, which solves many technological challenges encountered when implementing IoT solutions on a large scale, especially when connected using LPWAN technologies.