Thursday, August 27, 2026

How to Setup and Calibrate Magnetometer (Compass) in Betaflight FPV Drone

A magnetometer (also known as a compass) can be very useful for GPS Rescue and Position Hold in Betaflight, as it improves accuracy and overall performance. However, it can also be quite complex to set up and calibrate correctly. If a magnetometer is misconfigured or poorly calibrated, it can actually make things worse—causing drifting, incorrect heading, or even flyaways.

sponsor-banner

Some of the links on this page are affiliate links. I receive a commission (at no extra cost to you) if you make a purchase after clicking on one of these affiliate links. This helps support the free content for the community on this website. Please read our Affiliate Link Policy for more information.

In this guide, I’ll walk you through magnetometer orientation, declination, calibration, and verification step by step to make the process easier to understand.

Disclaimer: This guide reflects how I personally set up and calibrate a magnetometer. I am not responsible for any damage resulting from following these instructions. Please refer to Betaflight’s official documentation for details: https://www.betaflight.com/docs/wiki/guides/current/magnetometer

Check out my tutorials on:

What Is a Magnetometer (and Why It Matters)

The magnetometer tells the flight controller which direction the quad is facing. This information helps the drone to:

  • Maintain heading in Position Hold mode
  • Improve GPS Rescue mode accuracy
  • Reduce yaw drift during GPS-assisted flight modes

Some GPS modules have a built-in magnetometer.

Gps Module Magnetometer Compass 5883 Chip

GPS Recommendations

See my GPS testing here: https://oscarliang.com/gps-review/

Top Performer: GEPRC M1025Q (With Compass)

Top Performer: HGLRC M100 5883 (With Compass)

Smallest Worth Having: GOKU GM10 Nano V3 (With Compass)

How to Connect Magnetometer to Flight Controller

If your GPS module includes a compass, it should have two additional pads: SCL and SDA. These are for the I2C bus used by the magnetometer.

Wiring is easy:

  • SDA (GPS) → SDA (FC)
  • SCL (GPS) → SCL (FC)

Where to Mount Magnetometer

You should keep the compass as far away as possible from sources of electromagnetic interference, including:

  • ESC
  • Motors
  • Motor wires
  • Power cables (e.g. XT60)
  • Action cameras

Good locations for mounting a GPS module include:

  • Above the FPV camera
  • At the rear of the drone (as long as it’s not too close to the VTX antennas)
  • On the battery strap

For small quadcopters (e.g. under 5-inch), it’s harder to get clean compass readings simply because everything is packed so closely together.

Betaflight Setup

In Betaflight Configurator:

  • Go to Configuration → System Configuration
  • Enable Magnetometer
  • Save and reboot

Betaflight Configurator Configuration Accelerometer Barometer Magnetometer

After rebooting, the magnetometer icon (Mag) at the top of the configurator should light up. If it doesn’t, check power and wiring.

Betaflight Configurator Top Bar Gyro Accel Mag Baro Gps Icons

Identify Magnetometer Chip

Open the CLI and type:

status

This confirms whether the magnetometer is detected and also helps identify the chip. Common magnetometer chips used in GPS modules include HMC5883 and QMC5883.

Betaflight Configurator Cli Status Magnetometer Icon

Understanding Magnetometer Orientation

Just like a gyro, a magnetometer has three axes: X, Y, and Z. However, these axes are defined by the orientation of the magnetometer chip itself, not how it’s mounted in the drone.

On your GPS module, look for a small dot on the magnetometer chip—this marks pin 1.

Gps Module Magnetometer Compass 5883 Chip

Google the chip’s datasheet online. It should include a diagram showing how the X, Y, and Z axes are oriented relative to the chip and the small dot. For the QMC5883 magnetometer I am using:

  • X-axis points down
  • Y-axis points right
  • Z-axis points up

Qmc5883 Orientation X Y Z Alignment Arrow Direction

Betaflight expects the magnetometer to be oriented like this:

  • X-axis → pointing forward
  • Y-axis → pointing left
  • Z-axis → pointing up

Depending on how you mount your GPS module, you may need to adjust the magnetometer alignment in Betaflight settings.

Magnetometer Axes Orientation Betaflight Drone

Why Alignment Is Often Needed

If you mount the magnetometer perfectly parallel to the flight controller, setup would be simple. However, on most GPS modules the magnetometer is located on the opposite side of the GPS antenna. And since the GPS antenna must face the sky, the magnetometer usually ends up being upside down, which means alignment changes are usually inevitable.

If this is your first time using a compass, keep things simple:

  • Mount the GPS flat and level relative to the frame and FC
  • Avoid angled or tilted mounts
  • Get it working first before attempting custom alignment

In my setup, I kept things simple by mounting the GPS at the front of the quad, level with the frame and FC (using double-sided tape and zip tie).

Install Gps Magnetometer Compass Geprc M1025q Vapor Position Hold

Because the compass is simply flipped over on the pitch axis, I selected “CW 0° Flip” under Magnetometer Alignment in Betaflight.

Betaflight Configurator Configuration Magnetometer Alignment Declination

Here’s a handy cheat sheet you can use for common compass alignments.

Betaflight Magnetometer Compass Orientation Alignment Relation To Drone

Custom Alignment (Advanced)

If you are using a GPS mount with a tilt angle, then Custom Alignment is required. This can be confusing for beginners, which is why I strongly recommend mounting the GPS flat if possible so you don’t have to deal with this 🙂

Geprc Vapor Move Gps Front

That said, the Alignment Tool in iNav Configurator is extremely helpful—even if you don’t use iNav.

How to use it:

  • Open iNav Configurator
  • Enter Demo Mode (so you can connect without a FC)
  • Go to Alignment Tool
  • Select X, Y, Z (more reliable than picking magnetometer)
  • Adjust the X, Y, Z sliders until they match your magnetometer’s physical orientation
  • Take note of the final Roll (X), Pitch (Y), and Yaw (Z) values

Inav Configurator Alignment Tool Magnetometer Compass Xyz Axes Slider

Now go back to Betaflight:

  • In the Configuration tab, select Custom under Magnetometer Alignment
  • Enter the Roll, Pitch, and Yaw values

Betaflight Configurator Configuration Magnetometer Alignment Custom

Alternatively, you can do this via the CLI:

set align_mag = custom
set mag_align_roll = X
set mag_align_pitch = Y
set mag_align_yaw = Z
save

Set Magnetic Declination

Magnetic north is not the same as true north, and Betaflight needs your local magnetic declination value to correct this difference.

Declination varies by location. You can find it using a trusted website such as: https://www.magnetic-declination.com/

Example:

  • For Los Angeles, USA, the magnetic declination is +11° 24′.
  • Convert this to decimal (Google can do this for you): 11.4°

Magnetic Declination Location Usa Los Angeles

Enter this value in the Configuration tab

Betaflight Configurator Configuration Magnetometer Alignment Declination

Or enter it in CLI:

set mag_declination = 11.4
save

Calibrate Magnetometer

Ideally, you should perform compass calibration at the location where you plan to fly. Stay well away from anything that could cause magnetic interference, such as:

  • Metal objects
  • Cars
  • Power lines
  • Reinforced concrete

You can initiate calibration either by clicking the Calibrate Magnetometer button in Betaflight Configurator (setup tab), or by using stick commands. I personally prefer stick commands, as it allows me to unplug the USB cable and rotate the quad freely.

How to Calibrate Magnetometer

  1. Remove propellers and power up the quad
  2. Initiate calibration using the stick command:
    1. Pitch down + yaw up-right → you should hear 2 beeps
  3. Spin the quad quickly to start calibration
    1. You will hear 7 fast beeps indicating calibration has begun
  4. You now have 30 seconds to complete calibration
  5. The quad will make 3 beeps when calibration is complete

If your quad does not have a beeper, you can look at the FC LED instead:

  • Solid LED = calibration in progress
  • Normal blinking = calibration completed

Betaflight Stick Commands 2024 11 30

How to Move the Quad During Calibration

During the 30-second calibration window:

  • Hold the quad by the battery
  • Swing your arm in a figure-8 pattern
  • At the same time, yaw the quad left and right randomly
  • Slowly turn your entire body by taking small steps. By the end of the calibration, you should have completed roughly a full 360° rotation.

Calibrate Magnetometer Compass Figure 8 Betaflight

Compass calibration usually only needs to be done once within your local area. However, if you travel far away from home, it’s a good idea to recalibrate.

Validate Heading

After calibration, verify the heading carefully:

  • Use the Betaflight Configurator home screen or
  • Enable the Compass Bar in the OSD

Compare the heading against a smartphone compass app. Make sure the app is set to true heading, not magnetic heading.

Test by facing different directions:

  • Face north → should read north
  • Rotate east, south, and west → verify accuracy

Validate Betaflight Magnetometer Compass Heading Smartphone True North

If the Heading Is Incorrect

If the heading is clearly wrong:

  1. Recheck compass orientation
    1. Try different Mag Alignment options in Configurator (CW0 / CW90 / CW180 / CW270)
  2. Redo calibration in a clean environment
  3. Re-test after every change

In some cases, the compass itself may be faulty. I tested 3 different GPS modules and found that one had a faulty compass—so this is not uncommon.

Final Thoughts

You can fly Betaflight without a magnetometer—but if you want reliable Position Hold and accurate GPS Rescue, a properly configured and calibrated magnetometer can make a difference. Once it’s set up correctly, you rarely need to touch it again unless you change hardware or GPS placement. And don’t forget to recalibrate if you fly far away from your usual location.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles