Hello everyone. First post.
I've recently been working with the MPU9250 and a library given by jremington in the post here. As stated by the code I need to use the Magneto 1.2 calibration program to properly calibrate the sensor. However after obtaining the values, I'm at a loss for how to actually match them into my code:

// vvvvvvvvvvvvvvvvvv VERY VERY IMPORTANT vvvvvvvvvvvvvvvvvvvvvvvvvvvvv
//These are the previously determined offsets and scale factors for accelerometer and magnetometer, using MPU9250_cal and Magneto 1.2
//
//The scale constants should *approximately* normalize the vector magnitude for accel and mag to 1.0
//The AHRS will NOT work well or at all if these are not correct
MPU9250 accelgyro;
I2Cdev I2C_M;
float A_cal[6] = {515.0, 279.0, 751.0, 5.96e-5, 6.26e-5, 6.06e-5}; // 0..2 offset xyz, 3..5 scale xyz
float M_cal[6] = {28.585708, 33.453226, -36.173858, 0.01403, 0.01414, 0.01387}; // can make both 3x3 to handle off-diagonal corrections
float G_off[3] = { -310.4, 135.7, 278.0}; //raw offsets
// ^^^^^^^^^^^^^^^^^^^ VERY VERY IMPORTANT ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Your magnetometer has only small off-diagonal corrections, so you would replace the above line with the 3 offsets (already correct) and the 3 diagonal matrix terms from Magneto, as follows:

`float M_cal[6] = {28.585708, 33.453226, -36.173858, 1.039585, 1.045893, 1.053133}; // can make

Other examples on my Github site show how to include the full 9 term matrix, but what you have above is already a significant improvement.

Thanks! With this correction it seems 0 would be East/West now. However I have noticed something peculiar. Below is a snippet of the result of the (Yaw, Pitch, Roll):

It seems to cap at 197 and -163 rather than 180 like what I would expect. Is this normal?
This also seems to be the case for my previous off-diagonal values too

Hello again, i've been continuing my conquest for the MPU9250. I've reached the calibration phase and I'm using the Magneto 1.2 as suggested. However upon looking at your library, I saw the example files listed below:
mag.txt
mag3_out.txt
and mag3_raw.csv

Which one am I to use for the input of the Magneto 1.2?
if it's the mag3_raw.csv, how would I get those values? it seems with the calibration.ino all of the possible numbers I get are similar to the mag.txt

The first one. The comment on the second one explains that it is for comparison with the results of a different program, referenced on the sailboatinstruments web page.

In any case, to be sure you are doing things correctly, you need to apply the transformation to the test data and run Magneto again with the resulting, corrected data.

If everything was done properly, the new offsets will be about zero and the matrix will have 1.0000 for the diagonal terms, and zeros elsewhere.

I saw on the post here: that the diagonal (if the matrix was ordered
1 2 3
4 5 6
7 8 9
)
that 1 5 9 should be as close to one as possible. Didn't say anything about the others though.

The optimal numbers are the ones that transform your elliptical cloud of data points into a spherical cloud, centered on the origin, as shown in this example.

I tend to use commercial programs, like Matlab or Mathematica, for making 3D scatter plots like those shown.

Gnu Octave is a free replacement for Matlab, and Python with Matplotlib/pyplot (also free) will also produce such plots. There may be other free programs, or even websites that do so. There are plenty of tutorials, examples and instruction on line for their use.