> ## Documentation Index
> Fetch the complete documentation index at: https://docs.edgeimpulse.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Industrial HMI Copilot with Edge Impulse

> An Edge Impulse powered HMI that can enable operators to understand events such as assembly operations and even describe failures

Created By: Solomon Githu

Public Edge Impulse projects:

GitHub repository: [https://github.com/SolomonGithu/industrial-hmi-copilot](https://github.com/SolomonGithu/industrial-hmi-copilot)

![Industrial HMI Copilot](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/cover_image.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=3f9c346fcc8737f089d05efc8e899e91)

## Project description

On an assembly line, a Human-Machine Interface (HMI) displays process values, actuator states, and similar signals. This information is valuable but it requires a skilled operator to interpret it and decide what needs to be done. A few years ago, AI in such industrial systems was mostly used for classifications and anomaly detection. Generative AI models let us go further by giving us richer context about production. Therefore a GenAI-powered HMI can enable operators to understand events such as assembly operations and even describe failures.

However, running generative models can be challenging because industrial systems with similar computational power such as an Arduino UNO Q. Devices like that are constrained edge devices. Two innovations can make this possible:

1. Using Small Language Models (SLMs) such as Gemma, Qwen, SmolLM, Llama, among others.
2. Model cascading whereby multiple lightweight models handle specific tasks and the larger model such as Gemma is run on demand.

This project explores how we can use modern hardware and software technologies to advance HMI systems. The goal was simple: add generative AI to a HMI and demonstrate with a prototype. The demo is an interface that tracks the assembly process of an electrical box. An operator can see their workflow while a local Qwen language model gives feedback on operations. Additionally, there is a chat box so the operator can ask the model questions such as "Why did assembly 3 fail?".

![Project workflow](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img2_project_workflow.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=b985f73385450c707bc33e1fa0a3f4ab)

## Hardware and Software Requirements

### Hardware

* [Arduino® UNO Q](https://store.arduino.cc/products/uno-q): either the 2GB or 4GB variant.
* [Modulino™ Movement](https://store.arduino.cc/products/modulino-movement?utm_source=google\&utm_medium=cpc\&utm_campaign=EU-Pmax\&gad_source=1\&gad_campaignid=22591755262\&gbraid=0AAAAACbEa85hxdB3kAAu0AWABIGsQ7cho\&gclid=Cj0KCQiAnsvXBhCqARIsAHKgGNaDKxcnxiUP3Iy78bAwQOq4JV62D1lHMytPYidTJN2m2eiVb9wo4wAaAgP6EALw_wcB)
* USB-C® cable
* Personal computer with Internet access
* 3D printed [tool support](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/CAD-designs/Modulino-on-allen-support.stl) for the Modulino™ movement module

### Software

* [Edge Impulse Studio](https://edgeimp.com/community26)
* Arduino App Lab
* Small Language Models available locally through App Lab:  Qwen, Llama, Gemma

Qwen 3.5 0.8B was used for this project.

## Step 1: Assemble the tool support

The setup process for this demonstration is simple. First download this [CAD design](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/CAD-designs/Modulino-on-allen-support.stl) and 3D print it. This is a simple holder that carries the Modulino™ Movement module and has a slot into which a tool can be inserted. In my case, I used an Allen key as the tightening tool and because my electrical box had Phillips cross head screws, I added a simple 3D printed [flat end socket](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/CAD-designs/Screw-end.stl) that fits onto one end of the Allen key and lets it grip the Phillips screws.

![3D printed parts](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img4_3d_printed_parts.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=d1ddfc3645386d5415ea7e261a6b1421)

Place the modulino module in the carrier and attach your Allen key with the hole at the bottom. Afterwards, attach the Phillips socket to the free end of your Allen key. Finally, connect the modulino module to a UNO Q board with a Qwiic cable.

![Assembly](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img5_assembly.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=596489d10d6a29d605d3b16093d18dcb)

## Step 2: Set up your Arduino UNO Q

Before working with the Arduino UNO Q for the first time, we need to set up its Linux system through the App Lab. Arduino has documented the necessary steps in the [user manual](https://docs.arduino.cc/tutorials/uno-q/user-manual/).

![Arduino UNO Q](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img3_hardware_setup.jpg?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=156d33cecd1ce1d5757398af5163766c)

## Step 3: Train a motion classification model with Edge Impulse

### 3.1: Collect tool motion data

Upload this [sketch](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/Arduino-sketches/UNO_Q_modulino_movement_capture/UNO_Q_modulino_movement_capture.ino) to your UNO Q. It reads accelerometer values and prints the three axes (X, Y, Z) to Serial. You can use App Lab or the [Arduino IDE](https://docs.arduino.cc/tutorials/uno-q/user-manual/#arduino-ide-beta) to upload the sketch to the STM32 brain of your UNO Q.

![Motion data](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img6_motion_data.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=c1069fdc0bf1106c1ab85615c73e6338)

After uploading the sketch, ensure that your UNO Q is connected to your computer with a USB cable and there are no Serial Monitors holding the UNO's COM port. Then install and/or start the [Edge Impulse CLI](https://docs.edgeimpulse.com/tools/clis/edge-impulse-cli.md) in a terminal. This is a highly advanced software that is used to control local devices, act as a proxy to synchronize data for devices that don't have an internet connection, and to upload and convert local files. In this project, we will use the [edge-impulse-data-forwarder](https://docs.edgeimpulse.com/tools/clis/edge-impulse-cli/data-forwarder.md) tool of the CLI to capture Serial data from the UNO Q board and automatically upload them to an Edge Impulse project. Head to [Edge Impulse Studio](https://studio.edgeimpulse.com/login) and create a new project. Once the project has been created, ensure your PC has internet access and run the command below on a CLI to start the data forwarder:

```
edge-impulse-data-forwarder
```

You will be requested to enter your [Edge Impulse](https://edgeimp.com/community26) account credentials and select the project that should receive the accelerometer data. Enter `Ax, Ay, Az` as the sensor axes.

![EI data forwarder](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img7_ei_data_forwarder.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=ba6bb279d5a1d71c851fa98d9eeb9ff0)

When we go to 'Data acquisition' in our Edge Impulse project, we will see that the UNO Q board has been connected.

![UNO Q connected](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img8_ei_uno_q_connected.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=e79d64d6485249b6d0d6130f09564214)

We can now start sampling motion data about assembly activities. In the 'Collect data' section, we need to first set the label for the class that we are collecting data. We can also configure the duration of sampling data using the 'Sample length (ms.)' setting. I used 10-second samples and planned three classes: idle, tightening and moving. Click 'Start sampling' and the Edge Impulse Studio will automatically instruct the data forwarder running on your PC to start sampling IMU data via Serial and upload them to the project.

I first started with the idle tool state. This is simple since there is no motion that we are carrying out. However, it is important to note that for a richer dataset ensure the modulino movement module is oriented differently when sampling. The image below shows raw accelerometer data for different orientations of the idling tool.

![Idle state](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img9_ei_idle_state.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=b87828788695f2974953f24d154ab47f)

Next I sampled motion data of screw tightening activity. Below is a clip of the tightening action and graphed IMU data.

![Tightening screws](https://mintlify.s3.us-west-1.amazonaws.com/edgeimpulse/.assets/images/industrial-hmi-copilot/gif_tightening_screws_data.gif)

Finally, I recorded tool movements such as carrying the tool from the table to the assembly, or from one screw hole to the next.

![Tool movements](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/gif_tool_movements.gif?s=416962fc00b10942f68e3224816b85f1)

Looking at the IMU data, we can observe that each motion has a different pattern. This tells us that an AI model is capable of analyzing the trends and learning the motions. In total, I collected 5.5 minutes of data and splitting it into 1-second segments gave me 330 data points. To split the samples, click the three-dot vertical menu on each sample then choose 'Split Sample'.

![Split sample](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img10_ei_split_samples.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=b24be22b84ea894be11edcaf067b857d)

Click '+Add Segment', then click the graph to create a segment. Repeat this until the whole graph has been segmented. Finally, click 'Split' and you will see 1 second samples (or as configured by 'Set segment length (ms.)').

![Segmenting sample](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img11_ei_segment_sample.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=e842b74430f2d5c9a6df64dd72d9e8df)

The last data preparation step is to split our dataset for training and testing. A popular rule is 80/20 split whereby 80% of the dataset is used for model training while 20% is used for model testing. In Edge Impulse Studio project, we can click the red triangle with exclamation mark (as shown in the image below) and this will open an interface that suggests splitting our dataset. Follow the steps on the interface to confirm the split operation.

![Split dataset](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img12_ei_split_dataset.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=9d7b4902f64fc51cf8209b2c1cffaf94)

### 3.2: Train a motion classifier

Before training the motion classifier, we need to set up an [Impulse](https://docs.edgeimpulse.com/docs/edge-impulse-studio/impulse-design-and-experiments.md) which is a configuration that defines the input data type, pre-processing algorithm, and the Machine Learning model.

Click 'Create Impulse' and choose your processing settings. I set the input data to a window size of 1000ms (1 second) and a window increase of 500ms. The sampling frequency of 44Hz is automatically set by the UNO Q's connection. I used Spectral Analysis for feature extraction because the algorithm is great for analyzing repetitive motion, such as data from accelerometers. It extracts the frequency and power characteristics of a signal over time. Save the impulse configuration and open the Spectral features section.

![Impulse design](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img13_ei_impulse_design.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=2377debf12f9f522623fcc67f9b2b9e7)

There, we extract features for every sample and they are plotted. A good rule is that you want to see clusters for each class and this should be visually detectable as shown below.

![Features](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img14_ei_features.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=161de2da5074dee12d4a67278d15ff29)

We can now train a neural network, an algorithm that is inspired by the brain and is great for recognizing patterns. After various experiments with the neural network settings, I trained the model for 50 epochs and enabled the learned optimizer for updating model parameters based on gradients and history. The resulting model had an accuracy of 100%, based on the training data.

![Model trained](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img15_ei_model_trained.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=2c5f8d5d27e60e8a21203ad2034e0f22)

Testing the model on unseen data showed good results with 100% accuracy. This was good enough for me to proceed with deploying the model to an Arduino UNO Q.

![Model testing](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img16_ei_model_testing.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=9e681a3a9d1ba597919a02005f529b9f)

You can explore my resulting project here: [Tool motion classification - UNO Q](https://studio.edgeimpulse.com/public/1160907/latest).

### 3.3: Deploy motion classifier to UNO Q

We will deploy the model as an [Arduino library](https://docs.edgeimpulse.com/docs/run-inference/arduino-library.md) - a single package containing all the steps for sampling IMU data for 1 second, processing the data and feeding the features to the classifier. You can include this library in your own sketches to run the impulse locally on microcontrollers such as the STM32 on the UNO Q. Technically no programming is needed to deploy the Impulse as the Edge Impulse platform generates all the required source code and example sketches as well. Awesome!

![Deploy model](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img17_deploy_model.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=57bdd8414cc6ed242498b65ffcc627e2)

Once the library is built, it will be downloaded to your PC as a zip file. Add it to the Arduino IDE, then open the `model_metadata.h` file in the Arduino library folder (Tool\_motion\_classification\_-\_UNO\_Q\_inferencing\src\model-parameters) and change the value of `EI_CLASSIFIER_SENSOR` from `EI_CLASSIFIER_SENSOR_FUSION` to `EI_CLASSIFIER_SENSOR_ACCELEROMETER`.

Once the file has been updated, upload this example [sketch](https://github.com/SolomonGithu/industrial-hmi-copilot/tree/main/Arduino-sketches/UNO_Q_EI_motion_classification) to the STM32 MCU for continuous motion classification. Open a Serial Monitor and you should see the model's predictions being logged.

![Motion classification](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img18_ei_motion_classification.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=94b2951e6921a80ba1fe9789467d872c)

For the HMI application, we will use this [sketch](https://github.com/SolomonGithu/industrial-hmi-copilot/tree/main/Arduino-sketches/UNO_Q_EI_motion_classification_Linux). It uses the [Router bridge](https://docs.arduino.cc/tutorials/uno-q/routerbridge-multilanguage/) to pass motion classifications to the Linux brain, where they are further analyzed and explained by the Qwen language model. After verifying the basic motion classification with the previous sketch, upload this router enabled sketch to the STM32.

## Step 4: Download the HMI Copilot

Installing the HMI application on an Arduino UNO Q is simple. SSH into the board and clone this GitHub repository into the `/home/arduino/ArduinoApps/` directory.

```
git clone https://github.com/SolomonGithu/industrial-hmi-copilot.git
```

Once the repo has been cloned, you should see the project in the 'Apps' section of App Lab.

![App installed](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img19_new_app.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=908c71bdd9daa17d75a1a56d713273d0)

## Step 5: Install a Small Language Model

Recall our pipeline had two cascaded models: a perception model (motion classification), and a Small Language Model. Technically, developing the first model takes the most time because SLMs are already trained for general language based tasks.

Open the HMI Copilot project in App Lab, click the 'Large Language Model (LLM)' brick and navigate to the 'AI models' tab. Download and select one of the available models. I used Qwen 3.5 0.8B because it is relatively small and can generate a response more quickly. Other supported models such as Gemma 3 1B can be used depending on your hardware and use case.

![LLM](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img20_LLM_brick.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=bb051f59294dbd70d921bf7ff33a7ca2)

## Step 6: Run the HMI Copilot

![Run application](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img21_run_app.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=7d0ace8cf5424b6a788c10f88b873667)

Launch the HMI Copilot by clicking the 'Run' button. Running the application for the first time may take some seconds since the system needs to download the necessary Docker images. Once this is finished the application container will be started and the Web UI will automatically open in a browser. You can also open the Web UI manually in a browser by setting URL to the local IP address of your Arduino UNO Q and port 7000.

![App started](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img22_app_started.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=ee316405f2a0b86227763c068c79f823)

### Workflow visualizer

The first section of the Web UI-based HMI is a workflow visualizer. It shows assembly progress in real time: the tool moving to a screw, tightening it, and putting the tool down (idle). An assembly is marked as successful when 4 screws are tightened.

A state machine (run by [main.py](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/python/main.py)) handles the realities of assembly workflow. When an operator picks the next electrical box for assembly, the tool goes idle, and the state machine infers that the previous assembly work has been finished and a new one is about to start. The idea is that sometimes an operator may tighten say 2 out of 4 screws and the unit will be recorded as defective.

![Assembly visualizer](https://mintlify.s3.us-west-1.amazonaws.com/edgeimpulse/.assets/images/industrial-hmi-copilot/gif_assembly_visualizer.gif)

### Assembly counters

The interface keeps running counts of both successful and defective assemblies. The Qwen language model is run periodically (interval set by the `PERIODIC_LLM_FEEDBACK_INTERVAL_S` variable in [main.py](https://github.com/SolomonGithu/industrial-hmi-copilot/blob/main/python/main.py)) to notify the operator about defective assemblies and to describe how the last assembly went.

![App demo](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img23_app_demo.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=8ec6ed800600e04178bb41b14fc0d922)

### Copilot chat

A chat box lets the operator ask the language model questions about the assembly. In the example below, I asked the model to summarize various assemblies and it gave an impressive response. The model however failed to respond about assembly 14 and this is one of the limitations of small language models. Sometimes they hallucinate, or do not follow instructions well because they are built with limited training data and a small model size.

![App demo](https://mintcdn.com/edgeimpulse/3ctCZEGODDf5M71Q/.assets/images/industrial-hmi-copilot/img24_app_demo2.png?fit=max\&auto=format\&n=3ctCZEGODDf5M71Q\&q=85\&s=8f034b1f2523417a6d2cc92c9a2f080a)

## Conclusion

The capabilities of advanced hardware such as the Arduino UNO Q, combined with software updates such as Small Language Models are opening up possibilities of advanced edge use cases. Previously, Machine Learning models could allow us to track motions and classify them. With generative AI models, the system can narrate an assembly, point out why a unit was rejected and answer follow-up questions.

The cascading architecture makes this feasible on a small device. A lightweight classifier handles the continuous perception, while the language model adds understanding on demand.

I hope that this project will inspire you to build your own edge-AI-powered HMI!
