Boss lady
Boss lady
DIIDevHeads IoT Integration Server
Created by Enthernet Code on 6/27/2024 in #middleware-and-os
Can i use Edge Impulse to collect data, train a model and deploy it on an Arduino Nano 33 BLE Sense
Yea, @Enthernet Code after applying this changes and modifications your code should look like
#include <Arduino_LSM9DS1.h> // Include the library for the accelerometer
#include <edge-impulse-sdk/classifier/ei_run_classifier.h> // Include Edge Impulse SDK

#define THRESHOLD 0.5 // Define the threshold for anomaly detection

// Function to initialize the Edge Impulse model
void initializeModel() {
// Initialize the Edge Impulse model
if (ei_impulse_init() != EI_IMPULSE_OK) {
Serial.println("Failed to initialize Edge Impulse model");
while (1); // Stop execution if initialization fails
}
}

void setup() {
// Start serial communication
Serial.begin(9600);

// Initialize Edge Impulse model
initializeModel();

// Initialize the accelerometer
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}

// Set built-in LED pin as output
pinMode(LED_BUILTIN, OUTPUT);
}

void collectData(ei::signal_t* signal) {
float x, y, z;
static float features[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE] = { 0 };
static int feature_index = 0;

// Read data from the accelerometer
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);

// Fill the feature array with the collected data
features[feature_index++] = x;
features[feature_index++] = y;
features[feature_index++] = z;

// Reset the index if it exceeds the frame size
if (feature_index >= EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {
feature_index = 0;
}

#include <Arduino_LSM9DS1.h> // Include the library for the accelerometer
#include <edge-impulse-sdk/classifier/ei_run_classifier.h> // Include Edge Impulse SDK

#define THRESHOLD 0.5 // Define the threshold for anomaly detection

// Function to initialize the Edge Impulse model
void initializeModel() {
// Initialize the Edge Impulse model
if (ei_impulse_init() != EI_IMPULSE_OK) {
Serial.println("Failed to initialize Edge Impulse model");
while (1); // Stop execution if initialization fails
}
}

void setup() {
// Start serial communication
Serial.begin(9600);

// Initialize Edge Impulse model
initializeModel();

// Initialize the accelerometer
if (!IMU.begin()) {
Serial.println("Failed to initialize IMU!");
while (1);
}

// Set built-in LED pin as output
pinMode(LED_BUILTIN, OUTPUT);
}

void collectData(ei::signal_t* signal) {
float x, y, z;
static float features[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE] = { 0 };
static int feature_index = 0;

// Read data from the accelerometer
if (IMU.accelerationAvailable()) {
IMU.readAcceleration(x, y, z);

// Fill the feature array with the collected data
features[feature_index++] = x;
features[feature_index++] = y;
features[feature_index++] = z;

// Reset the index if it exceeds the frame size
if (feature_index >= EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {
feature_index = 0;
}

15 replies