Converting MPU-6050 code to MPU-9250

I am using the I2Cdev library with the MPU-6050. It enables DMP (digital motion processing) and I would like to keep using that. I found out that the MPU-9250 has a built in magnetometer and have since bought a few. I plugged in the MPU-9250 and did not change any of the code from the 6050 and to my surprise it worked. I was able to get gyroscope and accelerometer data from the 9250.

I would like to be able to get the magnetometer data while still using this original library. I tried modifying the MPU6050_9Axis_MotionApps41.h file with no success. In this file it has support for the AK8975, but the MPU-9250 uses the AK8963.

Does anyone know how to modify this library to get data from the magnetometer?

MPU6050_9Axis_MotionApps41.h (47.4 KB)

There are several working libraries for the MPU9250, far advanced from and better than any library you might be using now.

This one, for example. Don’t waste your valuable time, unless you really want to do the work all over again.