Calibration of magnetometer for precise yaw
May be the magnetometer is influenced by iron or steel parts nearby. The compass of large steel ships was compensated against the influence of the steel hull. There were flag signals given: I am regulating my compass.