Skip to content

Commit

Permalink
Structure update 4
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmchris committed Jan 2, 2025
1 parent 68462bf commit 203d57a
Showing 1 changed file with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,9 @@ To deploy a trained Edge Impulse model, go to the `Deployment` tab in the Edge I

![Opta™ Deployment](assets/edge-impulse-deploy.png)

After the deployment, it was possible to create the code that integrates Bluetooth Low Energy (BLE) functionality with Edge Impulse's machine learning inferencing framework to classify accelerometer data in real-time. It starts by initializing BLE communication and scanning for a specific peripheral device broadcasting a service with a known UUID. Once the device is found, it connects, discovers its attributes, and accesses a characteristic that provides accelerometer data. The code continuously reads 6 bytes of accelerometer data (representing the X, Y, and Z axes) from the BLE characteristic, processes it, and stores it in a buffer. This data is then transformed into a signal format compatible with Edge Impulse's inferencing engine. Using the pre-trained machine learning model deployed as a custom library generated by Edge Impulse's deployment feature, the code classifies accelerometer data, specifically vibration data, to detect anomalies. If the BLE connection is lost, the program automatically attempts to reconnect. Throughout the process, debug information and classification results are printed to the Serial monitor for real-time feedback.
After the deployment, it was possible to create the code that integrates Bluetooth Low Energy (BLE) functionality with Edge Impulse's machine learning inferencing framework to classify accelerometer data in real-time. It starts by initializing BLE communication and scanning for a specific peripheral device broadcasting a service with a known UUID. Once the device is found, it connects, discovers its attributes, and accesses a characteristic that provides accelerometer data.

The code continuously reads 6 bytes of accelerometer data (representing the X, Y, and Z axes) from the BLE characteristic, processes it, and stores it in a buffer. This data is then transformed into a signal format compatible with Edge Impulse's inferencing engine. Using the pre-trained machine learning model deployed as a custom library generated by Edge Impulse's deployment feature, the code classifies accelerometer data, specifically vibration data, to detect anomalies. If the BLE connection is lost, the program automatically attempts to reconnect. Throughout the process, debug information and classification results are printed to the Serial monitor for real-time feedback.

The code is divided into four parts for better understanding, similar to what was done previously.

Expand All @@ -447,7 +449,7 @@ BLECharacteristic sensorCharacteristic; // BLE characteristic object to interact
bool connectToPeripheral();
```

The second part of the code, begins by establishing Serial communication at a baud rate of 115,200 and waits for the connection to ensure debugging output is displayed correctly. A message indicating the start of Edge Impulse inferencing is printed to the Serial monitor. The function then initializes the BLE stack using the `BLE.begin()` method, and if BLE fails to initialize, it halts execution and reports an error. Finally, it validates the Edge Impulse classifier configuration to ensure the raw sample frame matches the expected format of three axes (X, Y, Z). If the configuration is invalid, an error message is printed, and the function stops further execution.
The second part of the code, begins by establishing Serial communication at a baud rate of `115,200` and waits for the connection to ensure debugging output is displayed correctly. A message indicating the start of Edge Impulse inferencing is printed to the Serial monitor. The function then initializes the BLE stack using the `BLE.begin()` method, and if BLE fails to initialize, it halts execution and reports an error. Finally, it validates the Edge Impulse classifier configuration to ensure the raw sample frame matches the expected format of three axes (X, Y, Z). If the configuration is invalid, an error message is printed, and the function stops further execution.

```arduino
void setup() {
Expand Down Expand Up @@ -615,12 +617,13 @@ bool connectToPeripheral() {

## Full Motor Anomaly Detection Example

All the necessary files to replicate this application notes can be found below:
All the necessary files to replicate this application notes can be found [here](assets/Nicla_Opta_ML_Vibration_Anomaly_Detection.zip):

This file contains the following codes: Nicla Sense ME firmware, Opta™ training firmware and Opta™ deployment firmware.

- You can download a compressed file containing all the necessary codes [here](assets/Nicla_Opta_ML_Vibration_Anomaly_Detection.zip). This file contains the following codes: Nicla Sense ME Firmware, Opta™ Firmware, and Opta™ Deployment Firmware.
- **Nicla Sense ME Firmware:** This code configures the Nicla Sense ME as a BLE peripheral to collect vibration data from the motor and transmit it wirelessly via Bluetooth® Low Energy (BLE).
- **Opta™ Firmware:** This code sets up the Opta™ as a BLE central device to receive vibration data from the Nicla Sense ME and forward it to the connected computer via serial communication.
- **Opta™ Deployment Firmware:** This code embeds the trained machine learning model into the Opta™ for real-time motor anomaly detection, allowing it to process vibration data and identify anomalies locally.
- **Nicla Sense ME firmware:** This code configures the Nicla Sense ME as a BLE peripheral to collect vibration data from the motor and transmit it wirelessly via Bluetooth® Low Energy (BLE).
- **Opta™ training firmware:** This code sets up the Opta™ as a BLE central device to receive vibration data from the Nicla Sense ME and forward it to the connected computer via serial communication.
- **Opta™ deployment firmware:** This code embeds the trained machine learning model into the Opta™ for real-time motor anomaly detection, allowing it to process vibration data and identify anomalies locally.
- The Machine Learning Tools project is public [here](https://studio.edgeimpulse.com/public/580971/live) so you can clone it and modify it to adapt it to your needs by improving the dataset or model architecture for a custom deployment.

## Conclusion
Expand Down

0 comments on commit 203d57a

Please sign in to comment.