Trained library continuous example project is broken

I’m trying to follow this post:

Couple of things I noticed - the data I had previously used was no good because the sampling frequency didn’t match. I’m sure this could be fixed with a bit of digging, but I just deleted it all and started again.

Setting the frequency in the data forwarder example seems to result in a different frequency being detected. For example setting to 62.5 ends up with detecting as 64hz.

After training a model I can download the library. Nice idea including example projects in the library, but they should work. This is the error I get when trying the nano_ble33_sense_accelerometer_continuous.ino example:

That was just the warning, here’s the error:

I’ve tried again:

  • train a model
  • download the library and install:
  • mkdir test
  • cd test; pio project init --board nano33ble
  • pio lib install ~/Downloads/
  • cp .pio/libdeps/nano33ble/laura_skirt\ Inferencing\ -\ Edge\ Impulse/examples/nano_ble33_sense_accelerometer_continuous/nano_ble33_sense_accelerometer_continuous.ino src/
  • pio run

this always seems to fail with this error:

OK, that error seems to be because the downloaded lib must be trained with 3 axis. I had improved the model testing by using only one axis (to detect jumping).

Enabling the other 2 axis corrects that.

Then I’ve found that the only way to rebuild the firmware without linker errors is to completely wipe the platformio project directory and start from scratch everytime.

@mattvenn as you found out the sketch expects to classify 3-axis accelerometer data. if you’re only using a single axis you can modify the sketch to only feed data from a single axis in, e.g. via:

    // Allocate a buffer here for the values we'll read from the IMU
    float buffer[EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE] = { 0 };

    for (size_t ix = 0; ix < EI_CLASSIFIER_DSP_INPUT_FRAME_SIZE; ix += 1) {
        // Determine the next tick (and then sleep later)
        uint64_t next_tick = micros() + (EI_CLASSIFIER_INTERVAL_MS * 1000);

        float x, y, z;
        IMU.readAcceleration(&x, &y, &z);

        buffer[ix] = x * CONVERT_G_TO_MS2;

        delayMicroseconds(next_tick - micros());

And then remove the #error call at the bottom of the sketch.

1 Like

Thanks @janjongboom

I’m still running into the issue with not being able to update the trained library without starting from scratch with platformio. I’ll try to work out what’s going on and post back.

Are there any docs on how to hook into the framework to do something with the inference?

So for example I can now run my model on the Arduino nano and see it printing the labels.
I can just put a case statement in there and do something based on the results of

ei_classifier_smooth_update(&smooth, &result);

As it seems to be built around an rtos, is there a preferred way of hooking into the results and doing them in another thread?

In particular I’m updating a string of ws2812 leds to run an animation, so it would be nice to not interrupt the thread doing inferencing.


@mattvenn I don’t know enough about to do something with that, but re your other question: just treat the data in result like you would with any other driver. E.g. write it to a variable and check that in your control loop. For the Nano I put the inferencing loop in a different thread already, but this is not a requirement. E.g. on audio we use DMA to get new audio, then inference in main thread - so up to how you currently write the software (the Edge Impulse inferencing SDK runs on basically any platform under the sun, so we can’t rely on RTOS to be there).

1 Like