Skip to main content
This tutorial shows how to run IMU-based Edge Impulse models on Zephyr RTOS using the Edge Impulse Zephyr Module. Drop in your model > build > flash > get real-time motion inference.
Reference code: https://github.com/edgeimpulse/ei-zephyr-imu-inference

Overview

This tutorial walks through running IMU (accelerometer/gyro) inference on Zephyr using the Edge Impulse Zephyr Module. The example supports any IMU accessible via Zephyr’s sensor API and can run on 850+ Zephyr-supported development boards.

Key Features

  • Real-time IMU sampling via Zephyr’s sensor framework
  • Circular buffer + continuous inference
  • Works with accelerometer-only or accel+gyro models
  • Compatible with any IMU driver supported by Zephyr

Prerequisites

Before starting, ensure you have:
  • Edge Impulse Zephyr Module workspace
  • A trained IMU model
  • A Zephyr-supported development board
  • Development tools
    • Zephyr SDK 0.17.4+
    • West 1.5.0+

Supported Sensors (IMU Drivers)

Any IMU supported in Zephyr should work, the example included uses a ST sensor hat. If you want to modify this example to use another board with an integrated IMU like the nicla vision. First comment out the CMAKE declaration for the shield in ei-zephyr-imu-inference/CMakeLists.txt:
Also you will need to set the board to:
see your associated boards Zephyr guide for more Your board’s IMU must appear in Zephyr’s device tree under I²C/SPI.

1. Initialize the Repository

This fetches:
  • Zephyr RTOS
  • The Edge Impulse Zephyr Module
  • All dependencies

2. Deploy Your Model

In Edge Impulse Studio:
  1. Go to Deployment
  2. Select Zephyr library
  3. Click Build
  4. Download the model .zip
Extract into model/:

Copy model files into the model/ directory

Ensure model/ contains:
  • CMakeLists.txt
  • edge-impulse-sdk/
  • model-parameters/
  • tflite-model/

3. Build

Select your board:

Build the project for your selected board

Or specify in .west/config:
Then build:

4. Flash

Or specify a flash runner:

5. Monitor Output

Expected output:

How It Works

  1. Initialization – IMU and inference engine start
  2. Sampling – Sensor data collected at the model’s sample rate
  3. Buffering – Samples stored in a circular buffer
  4. Inference – Classifier runs when a full window is available
  5. Results – Predictions printed to the console

Project Structure

Customizing the Example

Use a different IMU

Enable its driver in prj.conf:

Increase memory for larger models

Add logging

Troubleshooting

SDK not found

Run:

Sensor not detected

Enable debug logs:

Inference inaccurate

  • Ensure sample rate matches your training data
  • Verify sensor axis order
  • Test with raw features from Edge Impulse Studio

Summary

You have successfully deployed an IMU-based Edge Impulse model on Zephyr RTOS! You can now extend this example by:

Next Steps

For more advanced usage, consider:
  • Porting the project to a new board
  • Adding anomaly detection
For more examples and tutorials, see the Zephyr series overview for more in-depth tutorials on working with sensors and peripherals in Zephyr projects as we continue to expand this series!