Skip to content

Drone magnetometers and compass calibration explained

Published:

A magnetometer measures the Earth's magnetic field, and from it a drone's flight controller estimates heading, the direction the aircraft is pointing. Heading is hard to get from the IMU alone, so the magnetometer plays an important role, but it is also one of the sensors most easily disturbed by the drone itself.

How a magnetometer gives heading

The Earth's magnetic field has a horizontal component that points roughly toward magnetic north. A three-axis magnetometer measures the field's direction relative to the drone; combined with the tilt estimate from the IMU, the flight controller works out which way the aircraft is facing.

Magnetic north is not the same as true north. The difference, called magnetic declination, varies by location, and flight software corrects for it.

Why the compass gets disturbed

The magnetometer cannot tell the Earth's field apart from other magnetic sources nearby:

  • Hard-iron effects: permanent magnets, such as those in motors and speakers, add a constant offset.
  • Soft-iron effects: ferrous metal on the frame bends the field and distorts the readings.
  • Current-induced fields: high current through power wires and the motors creates fields that change with throttle.
  • Environment: steel structures, reinforced concrete and power lines distort the field around the aircraft.

What compass calibration does

During calibration the drone is rotated through many orientations so the magnetometer sees the field from all directions. The software fits a model to these measurements and estimates the hard-iron offsets and soft-iron scaling, which are then subtracted from every future reading.

Calibration corrects distortions that move with the drone. It cannot fix disturbances in the environment, which is why calibrating near metal structures or cars gives poor results.

Good practice

A few habits keep heading reliable:

  • Mount the magnetometer away from power wires and motors, often on a mast or GNSS module.
  • Calibrate outdoors, away from vehicles, steel and reinforced concrete.
  • Recalibrate after changing the frame layout or moving components.
  • Let the flight controller fuse the magnetometer with gyroscope data so short disturbances do not cause sudden heading jumps.
Sensor fusion and the Kalman filter in drone navigation →

Frequently asked questions

Calibration measures and removes the magnetic distortions caused by the drone's own magnets, metal and wiring, so the magnetometer reports heading from the Earth's field rather than from the airframe.

Hard-iron interference comes from permanent magnetic sources and adds a constant offset. Soft-iron interference comes from ferrous materials that distort the field's shape. Calibration estimates and corrects both.

It can estimate heading from other sources, such as gyroscope integration over short periods, visual methods, or motion relative to GNSS when available. Without any heading reference, gyroscope-only heading drifts over time.