External Compass Orientation
Almost every GPS module for drones has a magnetometer — a compass — built into it. The autopilot needs that compass to know which way the aircraft is facing, which is what makes position hold, return-to-home and waypoint navigation work rather than drift in circles.
There is a catch. The compass chip is soldered onto the module at whatever angle the board designer chose, and the module is then bolted onto your airframe at whatever angle your build allows. The firmware has no way to discover either angle on its own, so you have to tell it — and that is what the orientation parameter does.
Get it wrong and nothing looks broken. Calibration completes, the compass reports a heading, no error appears. The heading is simply wrong by a fixed amount, and the aircraft flies toward the wrong place in an auto mode.
Then none of this applies. Leave the orientation parameter at its default and just run a compass calibration. This page is about an external compass — the one inside a GPS or RTK module.
The reference orientation
Everything below is defined against one standard way of mounting the module: seen from above with the nose pointing away from you, the module's printed label reads normally and its connector faces the tail.
If that is how your module sits, take the value straight from the tables. If you had to rotate it to fit the frame, add the rotation:
| Module rotated (viewed from above) | Value to use |
|---|---|
| Reference — connector to the tail | the table value |
| 90° clockwise — connector to the left | table value + 90° |
| 180° — connector to the nose | table value + 180° |
| 270° clockwise — connector to the right | table value + 270° |
Values wrap at 360°. On ArduPilot, a module whose table value is YAW270, mounted 90° clockwise, needs 270 + 90 = 360 → NONE, not YAW360.
What each firmware calls it
ArduPilot
The parameter is COMPASS_ORIENT.
ArduPilot tries to work this out for you: automatic orientation detection is on by default, and during a compass calibration it compares the external compass against a working internal compass to deduce the external one's rotation. When the flight controller has a usable internal compass, this generally just works.
When it does not have one — an AIO board, or a board whose internal compass you have disabled — there is nothing to compare against, and you must turn auto-detection off and set COMPASS_ORIENT by hand.
PX4
The parameter is CAL_MAGx_ROT, where x is the magnetometer instance number. Most aircraft carry a single external compass, so find the instance that corresponds to it and set that one.
PX4 has an equivalent auto-detection option, SENS_MAG_AUTOROT, with the same limitation: on a board with no internal magnetometer it typically cannot arrive at the right answer even when enabled. On an AIO board running PX4, set CAL_MAGx_ROT manually from the tables.
INAV and Betaflight
These two work differently, and there is a step before the parameter.
Both ship two builds per board:
intmag— for a board with an internal magnetometerextmag— for a board using an external one
A GPS or RTK module's compass is only used by an extmag build. Flash intmag and the compass will not appear at all, whatever you do in the configurator — this is the first thing to check when INAV or Betaflight refuses to see a compass that is definitely wired correctly.
Neither firmware auto-detects orientation on an extmag build, so the alignment always has to be set by hand from the tables.
Orientation values
Values are for the reference orientation described above. For a rotated mount, add 90° per clockwise step.
GPS modules with a patch antenna
| Firmware | MG-A01 | M10G-5883 | MG-902 | MG-903 |
|---|---|---|---|---|
ArduPilot COMPASS_ORIENT | YAW90 | YAW270 | YAW90 | YAW270 |
PX4 CAL_MAGx_ROT | ROTATION_PITCH_180 | ROTATION_ROLL_180 | ROTATION_PITCH_180 | ROTATION_ROLL_180_YAW_90 |
| INAV | CW 0° flip | CW 180° flip | CW 0° flip | CW 270° flip |
| Betaflight | CW 0° flip | CW 180° flip | CW 0° flip | CW 270° flip |
Specifications and wiring for these four: GPS Module User Manual.
Dual-band GNSS and RTK modules
The MG-F10 series and the whole MA-RTK family share one set of values:
| Firmware | MG-F10-A · MG-F10-C · MA-RTK-AIR-626 · MA-RTK-AIR-F9P · MA-RTK-AIR-982 |
|---|---|
ArduPilot COMPASS_ORIENT | ROLL180_YAW270 |
PX4 CAL_MAGx_ROT | ROTATION_YAW_90 |
| INAV | CW 90° |
| Betaflight | CW 90° |
Rotated mounts follow the same rule — on ArduPilot the roll component stays and the yaw advances: ROLL180_YAW270 → ROLL180 → ROLL180_YAW90 → ROLL180_YAW180 for each further 90° clockwise.
Betaflight builds from December 2025 onward include the driver for the compass in the MG-903, MG-F10 and MA-RTK modules. Earlier builds will not detect them regardless of wiring or alignment.
AIO flight controllers need this done by hand
MicoAir's AIO boards — flight controller and ESC on one board — have no internal compass. That single fact changes the procedure, because it removes the reference that ArduPilot's and PX4's auto-detection depend on.
ArduPilot on an AIO board
- Connect the flight controller in MicoConfigurator.
- Go to Sensors → Compass.
- Turn off automatic orientation detection.
- Set
COMPASS_ORIENTby hand from the table above. - Run a compass calibration.
- Check that the heading shown in the ground station matches where the nose actually points.
PX4 on an AIO board
- Connect the flight controller in MicoConfigurator.
- Go to Sensors → Compass.
- Turn off automatic orientation detection.
- Set
CAL_MAGx_ROTby hand from the table above. - Run a full compass calibration.
- Check the heading against the real nose direction.
INAV or Betaflight on an AIO board
- Flash the
extmagbuild for your board. - Connect the INAV or Betaflight configurator.
- Confirm the external compass is detected.
- Set the alignment by hand from the table above.
- Save and reboot the flight controller.
- Run a compass calibration.
- Check the heading against the real nose direction.
In all three cases you are done when: calibration completes, the displayed heading matches the nose, and turning the aircraft moves the heading the same way.
Verify it with a phone
The quickest honest check needs nothing but the compass app already on your phone.
- Open the phone's compass.
- Hold the phone flat with its top pointing the same way as the aircraft's nose.
- Read the phone's heading, and read the heading in your ground station.
- Turn the aircraft slowly, keeping the phone aligned with the nose as you go.
The two readings should agree, and should change together in the same direction. Check near 0°, 90°, 180° and 270° rather than at one angle only — some errors only show up on part of the circle.
Only once the heading is right should you arm and fly.
Compass calibration and compass orientation fix different problems. Calibration removes the magnetic distortion caused by your airframe; orientation tells the firmware which way the sensor is facing. A perfectly calibrated compass with the wrong orientation reports a confident, stable, wrong heading — and the aircraft will fly on it.
Easily confused points
Different modules from the same maker need different values. The M10G-5883 and the MG-A01 are both u-blox M10 modules with a QMC5883L compass, and they need YAW270 and YAW90 respectively. Never copy a value from another module.
Orientation is not the same as calibration. Both are required, and each is useless without the other.
"Auto-detect" needs something to compare against. It works by checking the external compass against an internal one. No internal compass, no auto-detection — which is exactly the case on AIO boards, where people most expect it to work.
intmag and extmag are different firmware, not a setting. In INAV and Betaflight this is chosen when you flash, not in the configurator.
A 90/180/270° error is an orientation problem; a wandering heading is an interference problem. A constant offset means a wrong parameter. A heading that drifts when you push the throttle means the compass is too close to the power wiring.
The flight controller's own orientation parameter is a separate setting. ArduPilot's AHRS_ORIENTATION describes how the board is mounted. Setting that when you meant COMPASS_ORIENT breaks the whole attitude estimate, not just the heading.
Troubleshooting
| Symptom | Likely cause |
|---|---|
| Compass not detected at all | On INAV/Betaflight: intmag firmware flashed instead of extmag. On any firmware: the I2C pair (SCL/SDA) not connected or swapped. |
| Calibration will not complete | Too much magnetic interference, or the module is loose and moving relative to the airframe. |
| Heading off by exactly 90°, 180° or 270° | Wrong orientation value — recheck the table for your exact module and mounting rotation. |
| Heading turns the wrong way | The module is mounted mirrored or flipped relative to what the value assumes; re-examine which face is up. |
| Heading drifts with throttle | Magnetic interference from battery leads, ESCs or motors. Move the compass further away, then recalibrate. |
| Auto-detect sets an obviously wrong value | The board has no usable internal compass to compare against. Turn auto-detect off and set the value manually. |
Related guides
- GPS Module User Manual — M10G-5883, MG-903, MG-A01, MG-902
- MG-F10-C — Dual-Band GNSS Module
- MA-RTK Series — User Manual
- Firmware Flashing Guide — including how to flash an
extmagbuild
Written and maintained by the Robofusion engineering team.