STRDC logo
0
Shop Blog Deals Documentation Support About Contact
Shop Blog Deals Documentation Support About Contact
Free shipping over $100!

Featured Products

Loading...

Loading...

Loading...
Loading

All About IMUs - Magnetometers

Mar 6, 2026

Often when people refer to Inertial Measurement Units (IMUs), they strictly mean the inertial sensors: accelerometers and gyroscopes. In our previous post, we discussed how these sensors work and how their errors cause drift. Reducing or eliminating this drift is the key challenge with using IMUs as part of a navigation solution. One segment of drift reduction, or correction often implemented is the addition of a magnetometer. Magnetometers, as the name suggests, measure the local magnetic field. Like accelerometers and gyroscopes, they’re typically fabricated in 3-axis packaging. To illustrate the usefulness of a magnetometer, let’s consider an example with a 2-axis magnetometer, simplified by a humble magnetic compass.

Vector breakdown of Earth Magnetic Field next to a compass Relation of Magnetometer Measurements to Compass Pointing

As we all know, a compass uses a magnetic needle to point towards Earth’s Magnetic North. This provides a reference for our heading at any point in time. So, if we can measure the angle between where our vehicle is pointed and the direction of Magnetic North, we can determine our heading. Simple stuff, but now let’s add some complexity.

True North vs. Magnetic North

True North is defined as the geographic North pole of Earth: latitude 90 degdegdeg, longitude 0 degdegdeg. Normally, our navigation solution would be referenced from True North (in our navigation reference frame) because True North is a fixed direction (whereas Magnetic North can change) and maps are created with True North as a reference.

Magnetic North refers to Earth’s magnetic pole in the Northern Hemisphere (which is actually the south magnetic pole). This location can vary, as well as the magnetic field the Earth’s poles produce. Since the compass can only point in the direction of Magnetic North, and True North is in a different location, the compass reading by itself cannot be used as a reference to True North. Luckily, there’s a way of compensating for this.

World Magnetic Model

The World Magnetic Model (WMM) is a map that contains the declination angle between Magnetic North and True North around the world. The WMM is updated every few years to ensure its accuracy. If we know our location on Earth (or at least a rough estimate), we can use the reading from the compass and compensate with data from the WMM to identify the direction of True North and, as a result, our heading. Naturally, the less accurate our location, the more error we add to the declination compensation, the more error results in our heading estimation. Since IMUs are often paired with absolute positioning like GNSS, we’ll often always have some prior position knowledge for use with the WMM.

So if we take a measurement and we know our location, we can determine our heading with just the compass (more on that later). But since the Earth’s magnetic field is relatively weak, any external magnetic fields or disturbances to Earth’s magnetic field at our compass will throw off our measurement.

Disturbances and Distortions

Hard Iron Distortions

Bringing a magnet close to a compass, we very quickly see how our measurement gets thrown off. The needle rotates toward the magnet and introduces error. This error is referred to as Hard Iron Distortion: An offset or bias in the local magnetic field caused by nearby objects that produce a magnetic field.

Simple drawing of undistorted compass measurement next to another measurement distorted by a nearby magnetic field Conceptual Example of Error Due to a Nearby Magnetic Field

Soft Iron Distortions

We know that ferromagnetic materials warp the local magnetic fields, even if they have no residual magnetic field from previous magnetization. Naturally then, the presence of ferromagnetic materials near our compass will affect our measurement. Unlike Hard Iron Distortions, Soft Iron Distortions will be relative to the material’s orientation relative to Earth’s magnetic field.

Internal vs. External Disturbance

Distortions can be categorized as internal or external disturbances. Internal disturbances are caused by objects that are fixed relative to the magnetometer. External disturbances are caused by objects that float relative to the magnetometer (e.g. a passing object not attached to the vehicle).

Because internal disturbances are fixed relative to our compass, we can often calibrate for these. We typically can’t calibrate for external disturbances because their effect is normally not predictable. So how can we calibrate for internal disturbances?

Hard Iron Soft Iron Calibration (HSI)

Assume we have a two-axis magnetometer and a permanent magnet rigidly attached to a rotary table.

Conceptual drawing of a rotary table with a magnetometer in the presence of Earth's magnetic field Example of a Calibration Setup

If we rotate the table and take samples of the measured magnetic field, we’d obtain the following result.

Conceptual measurement from magnetometer during calibration, Y-axis vs. X-axis Time Lapse Measurement from 2-Axis Magnetometer During Calibration

Hard Iron Calibration

Now let’s consider a hard iron distortion. Assume we add a permanent magnet to the rotary table.

Conceptual drawing of a rotary table with a magnetometer and permanent magnet in the presence of Earth's magnetic field Example Calibration Setup with Introduced Hard Iron Distortion

Our goal is to measure the Earth’s magnetic field by compensating for the permanent magnet’s magnetic field. If we view the measurements from the setup, we will see an offset of the of the resultant magnetic field vector of the Earth by the permanent magnet.

Conceptual measurement from magnetometer during calibration with hard iron distortion, Y-axis vs. X-axis Time Lapse Measurement from 2-Axis Magnetometer During Calibration with Hard Iron Distortion

Easily enough, we can correct our measurement by compensating for the offset in both axes.

Soft Iron Calibration

Now let’s look at a soft iron distortion. Assume the same setup as before, but instead of a permanent magnet, we have a piece of ferromagnetic material.

Conceptual drawing of a rotary table with a magnetometer and ferromagnetic material in the presence of Earth's magnetic field Example Calibration Setup with Introduced Soft Iron Distortion

This material will change the Earth’s magnetic field at this location, skewing the measurement.

Conceptual measurement from magnetometer during calibration with soft iron distortion, Y-axis vs. X-axis Time Lapse Measurement from 2-Axis Magnetometer During Calibration with Soft Iron Distortion

This skew results in an ellipse that we can measure and correct back into a circle.

This simplified example illustrates the process for 2D, but the concepts remain the same in 3D. However, when we do consider the magnetic field in three dimensions, we have to contend with the non-tangential nature of Earth’s magnetic field.

From 2-Axis Compass to 3-Axis Magnetometer

Earth’s magnetic field is not completely horizontal with the surface of the Earth, it also has a vertical component (described by magnetic inclination). Since it only measures 2 axes, a handheld compass is still perfectly servicable. Assuming no pitch or roll (since we’re holding the compass flat) means we can determine our orientation since the compass isn’t measuring the vertical component. When we switch to a 3-axis magnetometer, our measurements will now record the vertical component of Earth’s magnetic field. Assuming no pitch or roll (we’re holding the magnetometer flat), we can safely ignore the Z-axis measurement and still determine our orientation. If we’re no longer holding it by hand (we don’t know if it’s flat), we can no longer assume our pitch and roll are 0 degrees, meaning we don’t know what portion of our measurement includes the vertical component.

Tilt Compensation

The strength of the Earth’s magnetic field’s vertical component highly depends on the location on Earth. For example, at the equator, the vertical component is negligible. In North America, the vertical component is larger than the horizontal component. Near the poles, the horizontal component is significantly smaller than the vertical component.

Magnetometer package held flat with measurements showing vertical and horizontal components of Earth's magnetic field along with error in estimation of magnetic north Visualization of Vertical Component of Earth’s Magnetic Field Affecting Magnetic North Estimation

Remember, our goal is to use it to measure the direction of Magnetic North (to estimate True North) - the direction tangential to the Earth towards Magnetic North. Consider a 3-axis magnetometer. As long as we know our pitch and roll angles, we can remove the vertical component from our estimation. What if we don’t know our pitch and roll angles? We won’t be able to compensate for this vertical component, adding to our estimation error.

To solve this issue, we can use a 3-axis accelerometer to determine our pitch and roll angles. Once we know our angles, we can compensate for the tilt.

Magnetometer package held at an angle with measurements showing vertical and horizontal components of Earth's magnetic field along with error in estimation of magnetic north Visualization of Orientation on Tilt Compensation

Integration into an INS

Going back to our initial thoughts, how does a magnetometer help our IMU? We know that our heading estimation will drift over time due to the nature of our inertial sensors. The magnetometer can be used to update our heading, thereby correcting for drifts in our inertial estimates. This then begs the question “Why not just navigate by magnetometer instead of gyroscope?” To which the answer is, you can – with some caveats.

Magnetometers alone, depending on the type and implementation, may only provide an accurate heading within a few degrees in ideal conditions. Additionally, using a magnetometer alone risks external magnetic disturbances disrupting the estimated heading. Depending on the application and implementation, these challenges may be insignificant or can be overcome. For most solutions, magnetometers provide additional reliability to our inertial sensor stack.

Conclusion

By now, you can see how magnetometers provide an important heading reference that can be used to correct for gyroscopic drift and, in some cases, even replace gyroscopes for heading determination. Of course there are calibration requirements and some design challenges (e.g. time-varying magnetic interference) to ensure proper operation, but their ubiquity in IMU packages indicates their importance in the holistic navigation solution.

Company

  • About Us
  • Contact Us

Support & Policy

  • Technical Support
  • Terms of Service
  • Privacy Policy
  • Return Policy

Stay Updated

Subscribe to our newsletter for the latest products and news.

Thank you!

You have successfully joined our subscriber list.

Stardust Orbital Corporation 1050K S Cypress St La Habra, CA 90631 © 2026 Stardust Orbital Incorporated. All rights reserved.