A magnetometer (often known as a compass) may be very helpful for GPS Rescue and Place Maintain in Betaflight, because it improves accuracy and total efficiency. Nonetheless, it can be fairly complicated to arrange and calibrate accurately. If a magnetometer is misconfigured or poorly calibrated, it may truly make issues worse—inflicting drifting, incorrect heading, and even flyaways.
On this information, I’ll stroll you thru magnetometer orientation, declination, calibration, and verification step-by-step to make the method simpler to know.
Disclaimer: This information displays how I personally arrange and calibrate a magnetometer. I’m not accountable for any harm ensuing from following these directions. Please check with Betaflight’s official documentation for particulars: https://www.betaflight.com/docs/wiki/guides/present/magnetometer
Take a look at my tutorials on:
What Is a Magnetometer (and Why It Issues)
The magnetometer tells the flight controller which course the quad is dealing with. This data helps the drone to:
- Keep heading in Place Maintain mode
- Enhance GPS Rescue mode accuracy
- Scale back yaw drift throughout GPS-assisted flight modes
Some GPS modules have a built-in magnetometer.
GPS Suggestions
See my GPS testing right here: https://oscarliang.com/gps-review/
High Performer: GEPRC M1025Q (With Compass)
High Performer: HGLRC M100 5883 (With Compass)
Smallest Value Having: GOKU GM10 Nano V3 (With Compass)
The best way to Join Magnetometer to Flight Controller
In case your GPS module features a compass, it ought to have two extra pads: SCL and SDA. These are for the I2C bus utilized by the magnetometer.
Wiring is straightforward:
- SDA (GPS) → SDA (FC)
- SCL (GPS) → SCL (FC)
The place to Mount Magnetometer
You need to hold the compass as distant as attainable from sources of electromagnetic interference, together with:
- ESC
- Motors
- Motor wires
- Energy cables (e.g. XT60)
- Motion cameras
Good places for mounting a GPS module embrace:
- Above the FPV digital camera
- On the rear of the drone (so long as it’s not too near the VTX antennas)
- On the battery strap
For small quadcopters (e.g. beneath 5-inch), it’s tougher to get clear compass readings just because every thing is packed so carefully collectively.
Betaflight Setup
In Betaflight Configurator:
- Go to Configuration → System Configuration
- Allow Magnetometer
- Save and reboot
After rebooting, the magnetometer icon (Magazine) on the high of the configurator ought to mild up. If it doesn’t, verify energy and wiring.
Establish Magnetometer Chip
Open the CLI and sort:
standing
This confirms whether or not the magnetometer is detected and in addition helps determine the chip. Frequent magnetometer chips utilized in GPS modules embrace HMC5883 and QMC5883.
Understanding Magnetometer Orientation
Identical to a gyro, a magnetometer has three axes: X, Y, and Z. Nonetheless, these axes are outlined by the orientation of the magnetometer chip itself, not the way it’s mounted within the drone.
In your GPS module, search for a small dot on the magnetometer chip—this marks pin 1.
Google the chip’s datasheet on-line. It ought to embrace a diagram exhibiting how the X, Y, and Z axes are oriented relative to the chip and the small dot. For the QMC5883 magnetometer I’m utilizing:
- X-axis factors down
- Y-axis factors proper
- Z-axis factors up
Betaflight expects the magnetometer to be oriented like this:
- X-axis → pointing ahead
- Y-axis → pointing left
- Z-axis → pointing up
Relying on the way you mount your GPS module, chances are you’ll want to regulate the magnetometer alignment in Betaflight settings.
Why Alignment Is Typically Wanted
When you mount the magnetometer completely parallel to the flight controller, setup could be easy. Nonetheless, on most GPS modules the magnetometer is situated on the alternative aspect of the GPS antenna. And for the reason that GPS antenna should face the sky, the magnetometer often finally ends up being the wrong way up, which implies alignment adjustments are often inevitable.
If that is your first time utilizing a compass, hold issues easy:
- Mount the GPS flat and degree relative to the body and FC
- Keep away from angled or tilted mounts
- Get it working first earlier than making an attempt customized alignment
In my setup, I saved issues easy by mounting the GPS on the entrance of the quad, degree with the body and FC (utilizing double-sided tape and zip tie).
As a result of the compass is solely flipped over on the pitch axis, I chosen “CW 0° Flip” beneath Magnetometer Alignment in Betaflight.
Right here’s a helpful cheat sheet you should utilize for frequent compass alignments.
Customized Alignment (Superior)
In case you are utilizing a GPS mount with a tilt angle, then Customized Alignment is required. This may be complicated for rookies, which is why I strongly advocate mounting the GPS flat if attainable so that you don’t should cope with this 🙂
That stated, the Alignment Software in iNav Configurator is extraordinarily useful—even for those who don’t use iNav.
The best way to use it:
- Open iNav Configurator
- Enter Demo Mode (so you may join with no FC)
- Go to Alignment Software
- Choose X, Y, Z (extra dependable than selecting magnetometer)
- Alter the X, Y, Z sliders till they match your magnetometer’s bodily orientation
- Pay attention to the ultimate Roll (X), Pitch (Y), and Yaw (Z) values
Now return to Betaflight:
- Within the Configuration tab, choose Customized beneath Magnetometer Alignment
- Enter the Roll, Pitch, and Yaw values
Alternatively, you are able to do this through the CLI:
set align_mag = customizedset mag_align_roll = Xset mag_align_pitch = Yset mag_align_yaw = Zsave
Set Magnetic Declination
Magnetic north is just not the identical as true north, and Betaflight wants your native magnetic declination worth to right this distinction.
Declination varies by location. You could find it utilizing a trusted web site reminiscent of: https://www.magnetic-declination.com/
Instance:
- For Los Angeles, USA, the magnetic declination is +11° 24′.
- Convert this to decimal (Google can do that for you): 11.4°
Enter this worth within the Configuration tab
Or enter it in CLI:
set mag_declination = 11.4save
Calibrate Magnetometer
Ideally, you must carry out compass calibration on the location the place you propose to fly. Keep properly away from something that would trigger magnetic interference, reminiscent of:
- Metallic objects
- Automobiles
- Energy strains
- Bolstered concrete
You’ll be able to provoke calibration both by clicking the Calibrate Magnetometer button in Betaflight Configurator (setup tab), or through the use of stick instructions. I personally desire stick instructions, because it permits me to unplug the USB cable and rotate the quad freely.
The best way to Calibrate Magnetometer
- Take away propellers and energy up the quad
- Provoke calibration utilizing the stick command:
- Pitch down + yaw up-right → you must hear 2 beeps
- Spin the quad shortly to start out calibration
- You’ll hear 7 quick beeps indicating calibration has begun
- You now have 30 seconds to finish calibration
- The quad will make 3 beeps when calibration is full
In case your quad doesn’t have a beeper, you may take a look at the FC LED as a substitute:
- Stable LED = calibration in progress
- Regular blinking = calibration accomplished
The best way to Transfer the Quad Throughout Calibration
In the course of the 30-second calibration window:
- Maintain the quad by the battery
- Swing your arm in a figure-8 sample
- On the identical time, yaw the quad left and proper randomly
- Slowly flip your whole physique by taking small steps. By the top of the calibration, you must have accomplished roughly a full 360° rotation.
Compass calibration often solely must be executed as soon as inside your native space. Nonetheless, for those who journey distant from residence, it’s a good suggestion to recalibrate.
Validate Heading
After calibration, confirm the heading rigorously:
- Use the Betaflight Configurator residence display screen or
- Allow the Compass Bar within the OSD
Evaluate the heading in opposition to a smartphone compass app. Make certain the app is ready to true heading, not magnetic heading.
Take a look at by dealing with completely different instructions:
- Face north → ought to learn north
- Rotate east, south, and west → confirm accuracy
If the Heading Is Incorrect
If the heading is clearly mistaken:
- Recheck compass orientation
- Attempt completely different Magazine Alignment choices in Configurator (CW0 / CW90 / CW180 / CW270)
- Redo calibration in a clear surroundings
- Re-test after each change
In some instances, the compass itself could also be defective. I examined 3 completely different GPS modules and located that one had a defective compass—so this isn’t unusual.
Ultimate Ideas
You’ll be able to fly Betaflight with no magnetometer—however if you need dependable Place Maintain and correct GPS Rescue, a correctly configured and calibrated magnetometer could make a distinction. As soon as it’s arrange accurately, you not often want to the touch it once more except you modify {hardware} or GPS placement. And don’t neglect to recalibrate for those who fly distant out of your regular location.
