Compass calibration

On this page 7

Compass calibration is the procedure that measures the magnetic distortions caused by the aircraft itself and stores correction values so that the magnetometer reports an accurate heading. In drones, it is a core part of navigation & sensors, because the flight controller combines the compass heading with GNSS position and inertial data to hold position, fly waypoints and return home.

A miscalibrated compass rarely causes an immediate crash. Instead, it produces subtle heading errors that grow into circling drift, poor position hold or, in severe cases, a fly-away. Understanding what the calibration actually corrects, and what it cannot correct, is therefore essential for any pilot or technician.

What a drone compass measures and why it needs correcting

A drone compass is a three-axis magnetometer that measures the local magnetic field vector, typically in microtesla. The flight controller projects that vector onto the horizontal plane, using attitude from the IMU, to derive magnetic heading, and then applies the magnetic declination for the current location to obtain true heading.

The raw reading is never clean. Steel screws, motor magnets, battery currents and wiring all add their own fields that rotate with the airframe. These contributions fall into two classic categories, hard-iron and soft-iron distortion, and the calibration routine exists to estimate both.

The table below summarizes the error sources a calibration addresses and those it does not.

Error sourceTypical causeCorrected by calibration
Hard-iron offsetPermanent magnets, magnetized steel partsYes, as a constant bias per axis
Soft-iron distortionFerrous material that bends the Earth fieldYes, as a scaling and cross-axis matrix
Current-induced fieldHigh battery and motor current near the sensorOnly with a separate motor or current compensation
External interferenceRebar, vehicles, power lines, metal decksNo, it changes with location
Sensor misalignmentCompass mounted at an angle to the airframePartly, larger errors need an orientation setting
Magnetic error sources on a drone

How the calibration routine works

During calibration, the pilot rotates the aircraft through as many orientations as possible, usually a horizontal spin followed by a vertical spin with the nose pointing down. The Earth field stays constant while the airframe rotates, so an ideal sensor would trace a perfect sphere centered on zero when its samples are plotted in three dimensions.

In practice, hard-iron offsets shift the center of the sphere, and soft-iron effects stretch it into an ellipsoid. The firmware fits an ellipsoid to the samples, then computes an offset vector and a correction matrix that map it back to a centered sphere. Open-source autopilots such as ArduPilot and PX4 report a fitness value that expresses the residual error; commercial systems simply show success or failure.

The steps and their purpose differ slightly between platforms, but the logic is the same.

StepPilot actionPurpose
1. PrepareRemove metal objects, move away from vehiclesEnsure only the Earth field and the airframe are measured
2. Horizontal rotationTurn the drone 360 degrees levelSample the horizontal axes
3. Vertical rotationTurn 360 degrees with the nose downSample the vertical axis
4. Fit and storeWait for confirmationSave offsets and the correction matrix
5. VerifyCompare heading with a known directionConfirm the result before flight
Typical calibration sequence

Calibration quality depends on sample coverage. A routine that only sees a narrow band of orientations produces an ellipsoid fit with large uncertainty, which is why some autopilots require rotation about every axis before they accept a result.

Compass calibration is often confused with other sensor setup tasks and with the in-flight symptoms of a bad heading. Each one addresses a different error, and performing the wrong procedure wastes time without fixing the fault.

Procedure or conceptWhat it addressesRelation to compass calibration
IMU calibrationGyroscope and accelerometer biasSeparate task; a poor IMU degrades heading projection
Motor compensationField from motor and battery currentComplements calibration on high-current builds
Magnetic declinationAngle between magnetic and true northApplied after calibration, usually from a world model
Magnetic interference warningDisturbance at the current locationIndicates a site problem, not a calibration problem
Toilet bowl effectCircling drift during position holdClassic symptom of a heading error
Related procedures and concepts

Modern flight controllers also fuse heading from GNSS velocity and dual-antenna GNSS where available. These sources reduce dependence on the magnetometer, but at hover and low speed the compass usually remains the primary heading reference.

When to calibrate and when not to

Manufacturers of consumer drones now advise calibrating only when the app requests it or after hardware changes, rather than before every flight. Recalibrating in a disturbed environment can store wrong offsets and make an accurate compass worse.

SituationRecommended actionReason
First flight of a new aircraftCalibrate in an open fieldEstablish a baseline for that airframe
Hardware change near the sensorRecalibrateNew parts alter hard-iron and soft-iron terms
Travel of several hundred kilometersCalibrate if promptedField strength and inclination differ
Warning on a parking lot or roofMove to a clean site firstLocal steel, not the airframe, is the cause
Normal flight at a familiar siteDo not recalibrateA good stored result is better than a risky new one
Decision guide for compass calibration

A clean calibration site is open ground at least several meters from cars, reinforced concrete, metal fences, buried pipes and power lines. Pilots should also remove phones, keys and watches from their hands, because a magnet near the sensor during the spin directly corrupts the hard-iron estimate.

Limitations, failure modes and common mistakes

Calibration corrects only distortions that rotate with the aircraft. Fields fixed in the environment cannot be removed, and the firmware cannot tell them apart from the airframe during the spin. This is the most common reason a drone flies well at one site and drifts at another.

  • Calibrating next to a vehicle bakes the car’s field into the offsets, producing a heading error at every other location.
  • Takeoff from a steel surface can disturb the initial heading; the drone may then begin a toilet bowl pattern after lifting off.
  • Ignoring a large offset value hides a magnetized part or a misplaced cable that should be fixed physically.
  • Repeated calibration as a ritual increases the chance of storing a bad result without adding accuracy.
  • Dismissing an interference warning and switching to ATTI mode without preparation can leave the pilot with no position hold.

Even a perfect calibration leaves a residual heading error of about one to three degrees on typical consumer hardware. That is acceptable for position hold, but survey and mapping work relies on RTK and better sensor fusion rather than on the magnetometer alone.

Explained without jargon

A drone has a small digital compass that tells it which way it is facing. The problem is that the drone itself contains magnets and metal, and these push the needle slightly off, a bit like a hiking compass held next to a belt buckle.

Compass calibration is a short routine in which you turn the drone around in several directions. The drone notices how its own parts bend the reading and remembers how to cancel that effect. The key point is simple: calibrate in a clean, open place, because the drone cannot tell its own metal apart from a nearby car.

A typical use case

An inspection technician replaces the gimbal and a landing leg on a mid-size quadcopter used for roof surveys. On the first test hover in the company yard, the aircraft slowly circles instead of holding position, and the app shows a heading warning. The yard has parked vans and a steel container nearby.

The technician carries the drone to a grass field about 50 meters from any vehicle, removes a phone and keys from the pockets, and performs the horizontal and vertical rotation. The app accepts the result, and a comparison with a hand compass shows less than two degrees of difference. The next hover is steady, and the circling disappears.

The lesson the team records is that the new hardware changed the airframe field, and that the recalibration had to happen away from the vans to be valid.