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() {

    while (!Serial);    

    Serial.println("Inizializzazione del device...");


void loop() {

    sensorVals[0] = CurieIMU.readAccelerometerScaled(0);
    sensorVals[1] = CurieIMU.readAccelerometerScaled(1);
    sensorVals[2] = CurieIMU.readAccelerometerScaled(2);

  • What happens if you add CurieIMU.autoCalibrateGyroOffset(); right after CurieIMU.begin(); ?
    – VE7JRO
    Oct 15, 2017 at 21:46
  • Do you know you have Z oriented as expected?
    – Dave X
    Nov 15, 2017 at 4:21
  • 1
    I'm voting to close this old abandoned question as information to make it answerable has never been provided. The obvious way to debug this is to print out both the raw and calibrated values. That would show if it is a reading error, or the more likely case of the calibration "calibrating out" gravity. Jun 13, 2018 at 2:13
  • If it is calibrating out gravity, why does it flip between values? I would be interested to see it calibrated, then tipped slightly in X/Y to see if the rows with "Z: 0" also have X/Y: 0 (they shouldnt), and if they do, then it's likely an issue with the sensor or reading too quickly from the sensor, or similar. I just dont see how calibrating out the Z would flip between 0 and 1 as per sample
    – AndrewP
    Jun 13, 2018 at 2:29
  • @SDsolar because is a specific function of CURIE IMU library compatible only with Arduino and Genuino 101 only Jun 22, 2018 at 13:31

1 Answer 1


Assuming you aren't jumping up and down while this is happening then it could be:

  • A loose wire
  • A dodgy power supply
  • A bad earth connection
  • A fault sensor
  • A weird magnetic field/flux thing

Check you wiring, make sure all the connections are secure, etc. I bet you have done that already.

I have no idea how to check a power supply, but if you have a different one you could switch that in. Also look into smoothing the power supply with decoupling capacitors (?)

A bad earth, all sorts of weird [stuff] happens when you haven't earthed things properly. Different power supplies need to share earths, but I suspect that doesn't apply here.

A faulty sensor - again, unless you have a duplicate you might not know.

Weird flux. I think the sensor is a magnetic sensor and so it could be the natural eddies and flows of magnetic flux have conspired against you. Move the sensor away from power supplies, electrical things and specifically anything you are hacking. Also rotate the sensor through 90 degrees and see if it still happens (With RF it will polarise the fields in a different way, and school was a long time ago and I can't remember if that works with magnetic fields too)

  • If i don't use the autoCalibrateAccelerometerOffset(), and i get the raw data the values are not calibrated but stable, so i think i can exclude: Fault sensor, Power Supply, Loose Wire, Faulty Sensor, a weird magnetic field :) Thanks Feb 18, 2017 at 8:49
  • An accelerometer has nothing to do with magnetic fields, unless the fields are strong enough to physically move the device. Jan 14, 2018 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.