SparkFun BasicAHRS_I2C giving unstable readings.

I am using the SparkFun Arduino Sketch from here.

It is giving me these results:

X-acceleration: 91.43 mg Y-acceleration: 249.51 mg Z-acceleration: 1042.05 mg 
X-gyro rate: -0.549 degrees/sec Y-gyro rate: 0.557 degrees/sec Z-gyro rate: 1.595 degrees/sec
X-mag field: -164.35 mG Y-mag field: -240.16 mG Z-mag field: -20.73 mG
Temperature is 27.9 degrees C

and then the next result (when MPU9250 is still) is:

X-acceleration: 91.49 mg Y-acceleration: 252.75 mg Z-acceleration: 1039.49 mg 
X-gyro rate: -0.076 degrees/sec Y-gyro rate: -0.130 degrees/sec Z-gyro rate: -0.008 degrees/sec
X-mag field: -175.07 mG Y-mag field: -222.24 mG Z-mag field: -27.64 mG
Temperature is 27.9 degrees C

Notice how the temperature has remained constant, acceleration has remained constant (although im not why there is a reading if the MPU9250 is stationary) and the mag field is fairly close. However, the Gyro values are not close.

Could I have a bad MPU9250?

I am using the Mega.

Have you calibrated the gyro and the magnetometer?

The accelerometer measures g, the acceleration due to gravity, in addition to accelerations caused by other forces.

This result

X-acceleration: 91.43 mg Y-acceleration: 249.51 mg Z-acceleration: 1042.05 mg

clearly indicates that the sensor is not quite horizontal on the desk or table top (otherwise X and Y accelerations would be zero), and has Z pointing up.

Part of the gyroscope offset is the rotation of the earth. 360 degrees per siderial day (86164.2 seconds).

That's 0.004178 degrees per second! :slight_smile:

johnwasser:
Part of the gyroscope offset is the rotation of the earth. 360 degrees per siderial day (86164.2 seconds).

That's 0.004178 degrees per second! :slight_smile:

Can a complementary filter stop this?

No. The Earth's rotation is far, far below the noise and drift of a consumer grade rate gyro.

jremington:
No. The Earth's rotation is far, far below the noise and drift of a consumer grade rate gyro.

As the Earth's rotation is a constant, could you not just subtract it from the Gyro axis?

Which gyro axis? The gyro axes are almost never aligned with the Earth's rotation axis.

Homework
Calculate the result of subtracting (or adding, depending on the sign) 0.004178 degrees/sec from the gyro rates you posted earlier (reproduced below):

X-gyro rate: -0.549 degrees/sec Y-gyro rate: 0.557 degrees/sec Z-gyro rate: 1.595 degrees/sec