MPU9250 IMU, how to get the X angle out of it?

How do I get the angle out of the MPU9250?
I installed it and connected it to the IC2 and all seems fine.

I tought the IMU.getGyroX_rads() will give me the angle, (inclination) of the IMU, but instead I get angular acceleration,

I moved it from flat to 45deg and it went back to zero. So I am assuming it showed the accel, not the final angle.

Here is my serial print code

Serial.print(IMU.getGyroX_rads(),6);
Serial.print (" DEG ");
float Angle = degrees (IMU.getGyroX_rads());
Serial.println (Angle,2);

My serial read:

0.008125 DEG 0.47. -- IMU was flat
0.016115 DEG 0.92
0.027167 DEG 1.56
0.286963 DEG 16.44
0.264858 DEG 15.18
0.246615 DEG 14.13. --- while in motion
0.214790 DEG 12.31
0.076037 DEG 4.36
0.132497 DEG 7.59
0.105998 DEG 6.07
-0.047669 DEG -2.73
0.022906 DEG 1.31
0.029298 DEG 1.68
-0.015977 DEG -0.92. -- was at 45 deg, static

my code is standard, the Basic_I2C file,

Please help,

Thank you.

Mitch

Hi,

I used the words "arduino angle accelerometer" in my favorite search engine to get a whole cht load of results. Such as:

The gyro reports the rate of rotation about each axis, not the angle.

There are two ways to get angles: (1) use the accelerometer with code to estimate static tilt angles or (2) use all the sensors with AHRS (Attitude and Heading Reference System) code to estimate 3D orientation.

Great, how do I do that?

(1) use the accelerometer with code to estimate static tilt angles or (2) use all the sensors with AHRS (Attitude and Heading Reference System) code to estimate 3D orientation.

Previous reply gave me a link to another MPU (6250). I dont have that.

Thanks

You can use the attached programs (one is a compass, the other an AHRS), but they won't work properly if you do not carefully calibrate both the accelerometer and the magnetometer.

Follow the instructions in this tutorial to perform the calibration (also described within the code).

The program package includes a short program to collect data for the calibration. I use an Excel spreadsheet to convert data formats between programs.

New_MPU9250.zip (137 KB)