I tried to implement the autoCalibrateAccelerometerOffset()
function, through the code below on Arduino Genuino 101.
In a static test, without any stress or noise, I read the three axis value.
When I see the data on the serial monitor or on my file created with processing, the Z acceleration values changes from 1~0,99 to 0,00 g.
I think there is an error in my code.
#include "SoftwareSerial.h"
#include "CurieIMU.h"
float sensorVals[] = {0,0,0};
void setup() {
Serial.begin(9600);
while (!Serial);
Serial.println("Inizializzazione del device...");
CurieIMU.begin();
CurieIMU.setAccelerometerRange(2);
CurieIMU.autoCalibrateAccelerometerOffset(X_AXIS,0);
CurieIMU.autoCalibrateAccelerometerOffset(Y_AXIS,0);
CurieIMU.autoCalibrateAccelerometerOffset(Z_AXIS,1);
}
void loop() {
sensorVals[0] = CurieIMU.readAccelerometerScaled(0);
sensorVals[1] = CurieIMU.readAccelerometerScaled(1);
sensorVals[2] = CurieIMU.readAccelerometerScaled(2);
Serial.print(sensorVals[0]);
Serial.print(",");
Serial.print(sensorVals[1]);
Serial.print(",");
Serial.println(sensorVals[2]);
delay(100);
}