Magnetometer Easy Calibration

For heavy vehicles, 2D calibration of the magnetometer and heading calculation using atan2() works fine, but you still need to rotate the vehicle+mounted magnetometer 360 degrees about the Z axis to obtain the calibration data. Tilt compensation is not needed if tilt is less than about 10 degrees.

Ellipse fitting code for offset removal and scale factor normalization, using either Matlab/GNU Octave or Python, is posted here.