"heading" variable in MMC5983 magnetometer: Arduino library examples

In MMC5983 magnetometer (Arduino library example 3) it says:

“// Magnetic north is oriented with the Y axis // Convert the X and Y fields into heading using atan2 (Arc Tangent 2) heading = atan2(scaledX, 0 - scaledY);”.

–From the code in example 3, it looks like there is no correction for magnetic declination, so do we always have to subtract magnetic declination regardless of its sign??

–Is there a write up on how the Arduino library examples were developed?? I mean a paper covering the physics and programming used in the examples.

Thanks. AA

The sign of the declination correction is critically important. Choose add or subtract as needed to produce the correct answer in your location.

Magnetometers need to be calibrated before use as a compass. This overview is a good guide: https://thecavepearlproject.org/2015/05 … r-arduino/

I read https://thecavepearlproject.org/2015/05 … r-arduino/ , it’s recommended in the the Arduino library examples. Is there another reference you can recommend??