A magnetometer measures the local magnetic field. Inside a phone or consumer IMU the sensor is typically based on the Hall effect (a current flows through a semiconductor, a perpendicular magnetic field produces a transverse voltage proportional to field strength) or on the magnetoresistive effect (the resistance of a thin ferromagnetic film changes with the applied field). Higher-precision instruments use fluxgate magnetometers, which are roughly four orders of magnitude more sensitive than smartphone Hall sensors but much larger. Field strength is reported in tesla (T) in SI units, or in gauss (1 G = T) in older literature; Earth’s surface field is about 25-65 μT. A 3-axis magnetometer reports the field along three perpendicular axes.

In an IMU the magnetometer’s job is to sense magnetic north, which (combined with the Accelerometer’s sensing of gravity) provides an absolute orientation reference that anchors the Gyroscope’s drift. The fusion is called Sensor fusion.

The magnetometer is the most fragile of the three IMU sensors, in the sense that it’s easily disturbed by the environment. Nearby iron, other magnets, current-carrying wires, motors, magnetized tools, even the steel frame of a desk — anything magnetic shifts the reading. Indoor environments are notoriously hostile for magnetometers because they’re full of disturbances. Outdoor magnetometer readings are much cleaner.

A practical consequence: when calibrating a phone’s compass, the user is often asked to rotate the device through several orientations in a figure-eight motion. This lets the device characterize the local magnetic disturbance — the iron in the case, in the user’s pocket — and subtract it out, leaving a cleaner estimate of true magnetic north.