True Vs Magnetic North in Heading

Trying to figure out if there is a way to show the direction of travel heading with reference to Magnetic North, 

Normally i would use the on position event to get the heading from GPS, but would like to provide the option to calculate the heading relative to magnetic north and consequently magnetic compass heading to the next waypoint.

Sensor.getInfo().heading returns the compass orientation of the watch but i actually want the directional heading in magnetic north reference, reading the documentation this also mentions true north not magnetic north so this doesnt seem to be the solution.

Am i missing something simple to calculate a heading in magnetic vs true

If not i'll probably just add an option for people to add magnetic declination for their area as a local setting, i could do it via a web request to get it from a site but not keen on sending location data.

Thanks in advance if anyone has any thoughts or suggestions on this one.

  • I am currently working on integrating a compass into my app and I would like to seek clarification.

    Regarding the difference between true north and magnetic north (magnetic declination), contrary to other commenters here it can actually be quite large. Where I am in the world, it currently hovers around 16 degrees. So even watches need to have some value for mag dec to calculate a reasonable true north value from the magnetometer.

    According to information elsewhere on Garmin's website, mag dec is calculated based on position automatically using NOAA World Magnetic Model for GPS devices. For watches it's unclear.

    Another possibility for calculating mag dec is to look at the difference between magnetometer vs. GPS data when available. It can then be stored for later use when only magnetometer data is available. This is probably what's going on when you "calibrate" the compass app.

    Two questions for Garmin:
    - What value for mag dec is being used when I access Position.Info.heading and I only have magnetometer data (no GPS available)? Can I access this value directly in my app for display to users?
    - Is it possible to manually set the mag dec used?

    These would both be highly valuable features to my users. Thanks.

  • Also, is there a way to get the raw bearing to magnetic north through the Sensor API?

  • If it was a way, the API documentation would have mentioned it. 

    These devices really only use the magnetic compass when GPS doesn’t work (that is, when the device isn’t moving). That is, the compass is used to determine orientation when not moving (something GPS can’t do). This lets the map be displayed at a reasonable orientation (rather than randomly).

    There are likely too many forms of interference to expect good numbers from the compass. Declination is likely the least of your problems. 

  • Another possibility for calculating mag dec is to look at the difference between magnetometer vs. GPS data when available. It can then be stored for later use when only magnetometer data is available. This is probably what's going on when you "calibrate" the compass app

    Probably not. (I suspect GPS is not used at all.)

    The idea (apparently) is to calibrate “once”. Not regularly like you’d need to deal with local differences. 

  • If it's of any use or interest, I've published a widget/app that shows the up-to-date Magnetic Declination for your current position. apps.garmin.com/.../9869a30a-8da7-41b5-99b4-3f11e6c7089a

    It calculates this using the NOAA/BGS World Magnetic Model coefficients file, WMM.COF. The file is updated every 5 years or more frequently if necessary. The most recent was released 10 days ago and will come into effect on 1st January 2025. I'll update the app as soon possible after 31st December.

  • Very interesting, thanks! Have you published the source code anywhere?

  • To answer my own question, here is a quick solution I put together to get magnetic north from the sensor in case it helps anyone: https://github.com/bostonrwalker/navutils/blob/main/source/navutils.mc#L56

  • Yes, it's on github, follow the link on the app's web page. It's an old version but the calculation code is the same. I now use JSON to include the coefficients. If you follow the links in the app description you can find more info. Feel free to use the Contact Developer link if you'd like more details.