My edge impulse code for Nicla Sense Me doesn't work

Question/Issue: I already downloaded and installed the .zip from edge impulse project. When I upload the code in my Nicla Sense Me it says:
ERR: Nicla sensors don’t match the sensors required in the model
Following sensors are required: X + Y + Z
But I know the xyz sensor works because a did a simpler code to test it.”

Project ID: 163129

Context/Use case: The serial monitor says me this message. The code still be the same, without changes. I don’t know what is happening. Do you have some advise for that?

Hello @Pablo9815,

Can you change your axis names on the nicla_sensor array as follow:

/** Used sensors value function connected to label name */
eiSensors nicla_sensors[] =
{
    "X", &get_accX,
    "Y", &get_accY,
    "Z", &get_accZ,
    "gyrX", &get_gyrX,
    "gyrY", &get_gyrY,
    "gyrZ", &get_gyrZ,
    "heading", &get_oriHeading,
    "pitch", &get_oriPitch,
    "roll", &get_oriRoll,
    "rotX", &get_rotX,
    "rotY", &get_rotY,
    "rotZ", &get_rotZ,
    "rotW", &get_rotW,
    "temperature", &get_temperature,
    "barometer", &get_barrometric_pressure,
    "humidity", &get_humidity,
    "gas", &get_gas,
};

I renamed the accX, accY, accZ to X, Y, Z.

For the explanation, when you collected your data, your axis names were set to X, Y, Z. In our examples, we usually use accX, accY, accZ.

Thus, when you generated the Arduino Library, we kept your axis names (see #define EI_CLASSIFIER_FUSION_AXES_STRING "X + Y + Z" in your model_metadata.h file in your Downloaded Library->src->model-parameters

Best,

Louis

FYI, I just updated our documentation to provide more clarity on this, thanks for the feedback.

Best,

Louis

Thank you so much for this clarification. I already changed the axis names, but now the nicla sense me only does the void setup() again and again.
I did some tests removing the called of ei_connect_fusion_list(EI_CLASSIFIER_FUSION_AXES_STRING) in order to see the affectation of it, the result was, without this funtion, the code continues to the void loop(), but obviously with issues.
The serial monitor doesn’t show anything, only repeats Edge Impulse Sensor Fusion Inference because it’s a print on the setup.
Also, I tried to put the entire funtion inside void setup(), the result was the same.

I know that the void setup() is always completly done because I put some Serial.prints in the begining and end.

I think the simplest thing to do is to start a new Edge Impulse Studio project, collect new data, and deploy the library.

If you want to dig into this further, then in your deployed library find model_metadata.h and see the value for #define EI_CLASSIFIER_FUSION_AXES_STRING.

The default Nicla value deployed as an Arduino library is

#define EI_CLASSIFIER_FUSION_AXES_STRING "accel.x + accel.y + accel.z + gyro.x + gyro.y + gyro.z + ori.heading + ori.pitch + ori.roll + rotation.x + rotation.y + rotation.z + rotation.w"

I did it again. Now, it doesn’t show the previous problem, because I put the correct axis name.
But now I have problems with the MbedOS, it sends this message:
++ MbedOS Fault Handler ++

FaultType: HardFault

Context:
R 0: 00000060
R 1: 00000000
R 2: 20003410
R 3: 2000042C
R 4: 00006E1B
R 5: 00006E1B
R 6: 00006E1B
R 7: 00006E1B
R 8: 00006E1B
R 9: 00006E1B
R 10: 00006E1B
R 11: 00006E1B
R 12: 200025A8
SP : 2000FFC0
LR : FFFFFF00
PC : FFFFFF00
xPSR : 600F000F
PSP : 00000060
MSP : 2000FF58
CPUID: 410FC241
HFSR : 40000000
MMFSR: 00000001
BFSR : 00000000
UFSR : 00000000
DFSR : 00000000
AFSR : 00000000
Mode : Handler
Priv : Privileged
Stack: MSP

– MbedOS Fault Handler –

++ MbedOS Error Info ++
Error Status: 0x80FF013D Code: 317 Module: 255
Error Message: Fault exception
Location: 0xFFFFFF00
Error Value: 0x20009F6C
Current Thread: Id: 0x20003410 Entry: 0x0 StackSize: 0x0 StackMem: 0x0 SP: 0x2000FFC0
For more info, visit: mbedos-error
– MbedOS Error Info –

Have you checked with this post?

Hi MMarcial.
I just tried the code in this post with the correction of axis’ name, it works correctly. I didn’t have any problem with this code.
So, I’m sure that my nicla sense me works correctly with Edge Impulse projects, but not with projects that I did.
I collected data from my nicla sense me to train the system

Ok, I already discovered the problem. I was taking a lot of data. I had accX, accY, accZ, gyrX, gyrY and gyrZ, at 500 Hz.
Maybe you can tell me wich is the maximun quantity of data that I allow to have.

Hello @Pablo9815,

I am not sure about your use case but do you need 500Hz? Feel free to tell us about your use case :slight_smile:
I am not even sure the accelero and the gyro on the nicla (BHI260AP if I remember correctly) can sample at 500Hz?

I’d start with something between 50 and 100Hz to see if you have good results. In that case, you’ll have 5x to 10x less data in one window.

It might be worth to collect more data if you if see a drop the accuracy.

Best,

Louis

I want to use Edge Impulse to do predictive maintenance, mainly on vibrations.
So my idea is to have the highest frequency of measure in order to detect high vibrations

It makes more sense on machinery vibration :smiley:
Thanks for sharing

Hello, it’s me again
I was using this video in order to use custom DSP blocks, but after training the model and trying to upload the code to the nicla sense me it says:

sketch\objs.a(nicla_sense_fusion.ino.cpp.o):(.data.ei_dsp_blocks+0x4): undefined reference to `extract_psd_bands_features(ei::ei_signal_t*, ei::ei_matrix*, void*, float)’
collect2.exe: error: ld returned 1 exit status
exit status 1
Error compilando para la tarjeta Nicla Sense ME.

I don’t know what is happening, do you have some advise or solution?

Hola Pablo,

I believe you already checked that resource but I’m putting it here just in case:

From what I can understand, in your custom dsp block, you should have set the
"cppType": "psd_bands", in the parameters.json correct?

Have you also implemented the cpp version of your block in an extract_psd_bands_features(ei::ei_signal_t*, ei::ei_matrix*, void*, float) function?

This one can go in your main.cpp (or I guess in your .ino sketch it also works).

Best,

Louis

Oh thank you and sorry it was my fault, I didn’t copy “block.cpp” into my arduino code.
I’m testing the custom processing blocks because the results on the Nicla Sense Me weren’t good. I mean, the results on the platform were good (live classification) but when I upload the code on the Nicla Sense Me the results are very different (in comparison with live classification) and also their are wrong

These are the results from live classification, as you can see without movent the anomaly is 0, and with movent the result is 1000

But in this case the results from nicla sense me are very different, without movent the anomaly is 0.014, and with movement (the same movent than the live classification) the anomaly is around 0.006 - 0.009

That is odd,

Could you try to run the float32 model on your device to see if it changes anything?
The studio live classification uses the unoptimized models.
Also can you make sure you have the same “calibration” parameters both in your ingestion sketch and inference sketches?

Could you share your project ID so I can check on my side?

Best,

Louis

Man you’re right. I’m really sorry, I have had too many issues that I changed some parts of the code to test the result, and I didn’t remember that I deleted the calibration on the ingestion sketch (I did that because I was trying to get the biggest quantity of data per second, but after doing that I figured out the Nicla Sense Me doesn’t endure so much data)
Ok, now I fixed the calibration in ingestion sketch, also I changed the data to training it again with the correct calibration (the data is about vibration at 80 Hz and not movement). Now the Nicla Sense Me shows a anomaly close to 0 when it doesn’t move, but with the vibration it shows 1000 anomaly (the same anomaly when I do a huge movement)

This is the project ID 176147