Problem with Running the impulse in the terminal using ESP32

I am getting this response when I deployed my model on ESP32 dev module kit with an accelerometer connected to the board… Should I only use a board with in-built inertial sensor to deploy it? or is there any possibility that I can run it directly though ESP32…

Thanks!!

My project ID is 97146

Hello @18U221,

I am not sure the ready-to-use firmware works with Gyr and Mag enabled. It is possible that only accelerometer works using the LIS3DHTR module connected to I2C (SCL pin 22, SDA pin 21).
Can you make sure you have the right sensor, attached to the right pin?

Regards,

Louis

Will check again! Thanks!

I am using an ADXL345 accelerometer… Will that work?

Thanks!

:thinking: I believe it won’t.

@AIWintermuteAI can you confirm?

Regards,

Louis

No, this accelerometer is not supported.
For unsupported sensors, you can collect the data with data forwarder and then use Arduino library for inference.

I used arduino library source code based deployment option also… But even that didn’t work for ESP32…

How exactly did you use the Arduino library? And what was the problem?

I first tried uploading the source code in Arduino nano 33 BLE Sense and got the output but when I tried to upload the same code in ESP32 it showed compilation error

Yes, of course you would get a compilation error - because the code is for Arduino nano 33 BLE Sense and not for ESP32. You will need to modify it to use the ADXL345 acceleromter.

I went through the code again but I am not able to find out exactly where to make changes… Could you please suggest what possible changes can be made on the code

I am attaching the code here:

/* Edge Impulse Arduino examples

  • Copyright (c) 2021 EdgeImpulse Inc.
  • Permission is hereby granted, free of charge, to any person obtaining a copy
  • of this software and associated documentation files (the “Software”), to deal
  • in the Software without restriction, including without limitation the rights
  • to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  • copies of the Software, and to permit persons to whom the Software is
  • furnished to do so, subject to the following conditions:
  • The above copyright notice and this permission notice shall be included in
  • all copies or substantial portions of the Software.
  • THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  • IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  • FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  • AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  • LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  • OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  • SOFTWARE.
    */

/* Includes ---------------------------------------------------------------- */
#include <Inertial_second_review_inferencing.h>

static const float features[] = {

};

/**

  • @brief Copy raw feature data in out_ptr
  •         Function called by inference library
    
  • @param[in] offset The offset
  • @param[in] length The length
  • @param out_ptr The out pointer
  • @return 0
    */
    int raw_feature_get_data(size_t offset, size_t length, float *out_ptr) {
    memcpy(out_ptr, features + offset, length * sizeof(float));
    return 0;
    }

/**

  • @brief Arduino setup function
    */
    void setup()
    {
    // put your setup code here, to run once:
    Serial.begin(115200);

    Serial.println(“Edge Impulse Inferencing Demo”);
    }

/**

  • @brief Arduino main function
    */
    void loop()
    {
    ei_printf(“Edge Impulse standalone inferencing (Arduino)\n”);

    if (sizeof(features) / sizeof(float) != EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE) {
    ei_printf(“The size of your ‘features’ array is not correct. Expected %lu items, but had %lu\n”,
    EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE, sizeof(features) / sizeof(float));
    delay(1000);
    return;
    }

    ei_impulse_result_t result = { 0 };

    // the features are stored into flash, and we don’t want to load everything into RAM
    signal_t features_signal;
    features_signal.total_length = sizeof(features) / sizeof(features[0]);
    features_signal.get_data = &raw_feature_get_data;

    // invoke the impulse
    EI_IMPULSE_ERROR res = run_classifier(&features_signal, &result, false /* debug */);
    ei_printf(“run_classifier returned: %d\n”, res);

    if (res != 0) return;

    // print the predictions
    ei_printf(“Predictions “);
    ei_printf(”(DSP: %d ms., Classification: %d ms., Anomaly: %d ms.)”,
    result.timing.dsp, result.timing.classification, result.timing.anomaly);
    ei_printf(": \n");
    ei_printf("[");
    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    ei_printf("%.5f", result.classification[ix].value);
    #if EI_CLASSIFIER_HAS_ANOMALY == 1
    ei_printf(", “);
    #else
    if (ix != EI_CLASSIFIER_LABEL_COUNT - 1) {
    ei_printf(”, “);
    }
    #endif
    }
    #if EI_CLASSIFIER_HAS_ANOMALY == 1
    ei_printf(”%.3f", result.anomaly);
    #endif
    ei_printf("]\n");

    // human-readable predictions
    for (size_t ix = 0; ix < EI_CLASSIFIER_LABEL_COUNT; ix++) {
    ei_printf(" %s: %.5f\n", result.classification[ix].label, result.classification[ix].value);
    }
    #if EI_CLASSIFIER_HAS_ANOMALY == 1
    ei_printf(" anomaly score: %.3f\n", result.anomaly);
    #endif

    delay(1000);
    }

Thanks!