Arduino Example for Data Forwarder

I think the Arduino example for the Data Forwarder may have a mistake in it. The Arduino LSM9DS1 provides accelerometer data in Gs. I believe that Edge Impulse is expecting the data to be in Meters/Second2 though. The conversion in the Arduino sample simply multiplies the sensor values by 10. It should instead be multiplying them by the constant for gravity: 9.80665. That is at least what is happening when you run inference. Not sure if it matters, but probably good to get right.

#include <Arduino_LSM9DS1.h>

void setup() {
    Serial.begin(115200);
    Serial.println("Started");

    if (!IMU.begin()) {
        Serial.println("Failed to initialize IMU!");
        while (1);
    }
}

void loop() {
    float x, y, z;

    if (IMU.accelerationAvailable()) {
        IMU.readAcceleration(x, y, z);

        Serial.print(x * 10);
        Serial.print('\t');
        Serial.print(y * 10);
        Serial.print('\t');
        Serial.println(z * 10);
    }
}
1 Like

Hi @Robotastic,

Good point there’s definitely a mistake in the data forwarder example, we’ll fix it right away.
Thanks a lot for your feedback!

Aurelien

1 Like