How can I clean and print the sensor data to the monitor before loading it onto the model

I finally was able to to integrate the model into my ESP32 firmware

#include <Arduino.h>
#include "generated_model.h" // Include the generated model header

void setup() {
  Serial.begin(115200);
}

void loop() {
  // Simulated input data from sensors
  float input_data[4] = {1, 2, 3, 4};

  // Perform inference
  float prediction = predict(input_data);

  // Print the prediction
  Serial.print("Prediction: ");
  Serial.println(prediction);

  // Add a delay for readability
  delay(1000);
}

float predict(float *input_data) {
  return your_model_predict(input_data); // Use the actual function name from the generated code
}

How can I clean and print the sensor data to the monitor before loading it onto the model
@Middleware & OS
@Helper
Solution
Add a function to print the sensor data before using it for prediction:

void printSensorData(float *input_data) {
  Serial.print("Sensor Data: ");
  for (int i = 0; i < 4; i++) {
    Serial.print(input_data[i]);
    Serial.print(" ");
  }
  Serial.println();
}


Call this function in your loop() function before calling predict():

printSensorData(input_data);
Was this page helpful?