Arduino nano rp2040 deployment issues as arduino library

Question/Issue:
Problems when using Arduino library of deployment
Project ID:

Context/Use case:
When i run audio classification directly as firmware flashed into the arduino nano rp2040 connect it works properly.

However when i try to implement it as an arduino library, the microphone continuos version, two things happen:

An #endif without an #if appears on end of code, in

ei_printf(“Predictions:\r\n”);

for (uint16_t i = 0; i < EI_CLASSIFIER_LABEL_COUNT; i++) {

    ei_printf("  %s: ", ei_classifier_inferencing_categories[i]);

    ei_printf("%.5f\r\n", result.classification[i].value);

}

//#endif

// Print anomaly result (if it exists)

#if EI_CLASSIFIER_HAS_ANOMALY == 1

ei_printf("Anomaly prediction: %.3f\r\n", result.anomaly);

#endif

}

#if !defined(EI_CLASSIFIER_SENSOR) || EI_CLASSIFIER_SENSOR != EI_CLASSIFIER_SENSOR_MICROPHONE

#error “Invalid model for current sensor.”

#endif

In the code provided, the #endif is commented to prevent that error, when commented what happens is the sample buffer seems to be overruned, it runs but it constantly gives:

16:46:29:991 → Error sample buffer overrun. Decrease the number of slices per model window EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW is currently set to 3
16:46:29:991 → ERR: Failed to record audio…
16:46:31:061 → Error sample buffer overrun. Decrease the number of slices per model window EI_CLASSIFIER_SLICES_PER_MODEL_WINDOW is currently set to 3

I tried decreasing the slices per model windows to 1 but it didnt help

I am having the same exact issue here as well. Can’t compile the Arduino code with the included library without the an #endif without an #if error. Wondering if its a glitch in edge impulse. I am using the Pico with the rp2040 though.

Hello @BJOHN159 @ekrov,

I can reproduce your error, I am creating an internal ticket so our embedded engineers can fix the issue.
In the meantime, just delete the line 257 containing the #endif, it should work.

Best,

Louis

1 Like

@ekrov,

I think your impulse is too big to run on the Arduino RP2040 if you have this error even while reducing the slices. Are you able to run the non continuous model?
Also, in most cases, the DSP part is the most greedy in resources on audio projects, if you need to rework your impulse, I’ll start by optimizing the DSP part.

Best

1 Like

optimizing the dsp part worked, thanks!

Hi there, I am kind of having the same issue here, what do you mean by optimizing dsp part? how exactly did you do it?