Drone GPS & Compass Guide
Adding GPS to a drone is what turns it from a machine that needs constant stick input into one that can hold a position, come home on its own and fly a route you drew on a map. It is also the single most common source of "it flies fine in acro but goes mad in position hold" problems — almost always for reasons that have nothing to do with the GPS receiver itself.
This guide covers the whole job: what the two sensors in a GPS module actually do, where to put the thing, how to wire it, how to configure it on each of the four major firmwares, how to calibrate it, and how to check your work before you trust it with an aircraft.
Two sensors, two jobs
The module you bolt to a mast contains two completely different sensors that happen to share a cable.
- The GNSS receiver works out where the aircraft is — latitude, longitude, altitude — by timing signals from navigation satellites. It also knows how fast it is travelling and in which direction when it is moving.
- The magnetometer, the compass, works out which way the aircraft is facing, by measuring the Earth's magnetic field.
The second one is easy to dismiss as redundant. It is not, and the reason is worth understanding: a GNSS receiver cannot tell you heading while hovering. It knows the direction you are travelling, which is not the same thing — hover in place and there is no direction of travel to report, yet the autopilot still needs to know which way the nose points in order to decide which motor to speed up when the wind pushes it sideways.
Position hold works by pushing the aircraft back towards a point. Those pushes are aimed using the heading. If the heading is wrong by 90°, every correction goes sideways instead of back — so the aircraft circles the point in a widening spiral instead of sitting on it. The symptom looks like a GPS problem and is almost always a compass problem.
Choosing a module
For most builds, an ordinary GPS-plus-compass module is the right answer. See the GPS Module User Manual for the specifics of the M10G-5883, MG-903, MG-A01 and MG-902.
Step up from there when the job demands it:
- MG-F10-C — dual-band L1+L5, for sub-metre positioning and better resistance to reflected signals in built-up areas.
- MA-RTK series — centimetre-level RTK, when you need repeatable precision rather than just "roughly there". See What Is RTK? for whether you actually do.
Where to mount it
Almost every mounting rule exists because of the compass, not the receiver.
A magnetometer measures the Earth's magnetic field, which is weak. The current flowing through your battery leads and ESCs produces a magnetic field that is not weak, and it changes with throttle. Put the compass near that and its heading will swing every time you climb.
- Put it on a mast, above the frame and clear of the power wiring. Height buys magnetic distance more cheaply than anything else.
- Nothing above the antenna. No canopy, no carbon plate, no battery. The patch antenna needs sky.
- Away from the video transmitter and its antenna, which radiates RF close to the GNSS band.
- Rigidly fixed. A module that can rotate or wobble produces a heading that rotates and wobbles with it.
- Decide the orientation before you glue anything, because it determines the orientation parameter you will set later — see External Compass Orientation.
Wiring
The standard module has six wires on one connector: GND, 5V, Rx, Tx, SCL, SDA. Power on two, GPS data on the UART pair, compass on the I2C pair.
The one rule that catches people: Rx and Tx cross. The module's Rx goes to the flight controller's Tx, and vice versa. Using the supplied cable into a dedicated GPS port, this is already done for you.
Full pinout and a wiring diagram: GPS Module User Manual — Wiring.
Setting it up
ArduPilot
- Tell the port it is a GPS. Set the
SERIALn_PROTOCOLof the port you used to5(GPS). On a dedicated GPS port this is already the default. - Leave detection on auto.
GPS1_TYPE = 1(AUTO) lets ArduPilot identify the receiver and configure its baud rate itself. There is normally nothing else to set. - Set the compass orientation.
COMPASS_ORIENT, from the orientation tables. On a board with a working internal compass ArduPilot can usually work this out during calibration; on a board without one, set it by hand. - Calibrate the compass (below).
- Reboot, then check the heading.
Two compass parameters are easy to mix up: COMPASS_ENABLE switches the sensor on at all and needs a reboot; COMPASS_USE decides whether the heading it produces is actually used for navigation. Both must be enabled for the compass to steer anything.
PX4
- Assign the port.
GPS_1_CONFIGselects which serial port the main GPS is on —GPS1by default. - Set the rate.
SER_GPS1_BAUD, or leave it on Auto. - Set the compass orientation.
CAL_MAGx_ROT, wherexis the magnetometer instance — see the orientation tables.SENS_MAG_AUTOROTcan attempt this automatically, but not on a board with no internal magnetometer. - Calibrate the compass in QGroundControl.
- Reboot, then check the heading.
INAV
- Ports tab — set the UART the module is on to GPS, at the module's baud rate.
- Configuration tab — enable the GPS feature, set the protocol to UBLOX (
gps_provider = UBLOX, the default) and pick an SBAS mode appropriate to your region. - Flash an
extmagbuild if you have not already — INAV only uses an external compass on anextmagbuild. - Set the magnetometer alignment from the orientation tables. In the CLI this is
align_mag, taking values such asCW180_DEG_FLIP. - Calibrate the compass, then check the heading.
Betaflight
- Ports tab — set the UART to GPS at the right baud rate.
- Configuration tab — enable the GPS feature and select the u-blox protocol.
- Flash an
extmagbuild — same rule as INAV. - Set the magnetometer alignment (
align_magin the CLI) from the orientation tables. - Calibrate the compass, then check the heading.
Betaflight's GPS support is aimed at GPS Rescue rather than full waypoint navigation. If you want missions and position hold, ArduPilot or INAV is the firmware for that.
Calibrating the compass
Calibration does one specific thing: it measures the magnetic distortion produced by your airframe, so the firmware can subtract it. That has two consequences worth internalising.
Calibrate the aircraft, not the module. Do it with the aircraft fully assembled — battery in its flying position, all wiring routed, camera and gimbal fitted. A compass calibrated on a bare frame is calibrated for a machine you are not going to fly.
Recalibrate after changes. Moving the battery, rerouting power leads, adding a payload or relocating the GPS mast all change the distortion, and invalidate the old calibration.
The procedure itself is the same everywhere: start calibration in the ground station, then rotate the aircraft through all orientations — nose down, nose up, on each side, inverted — turning slowly and smoothly until it reports success. Do it outdoors, away from cars, reinforced concrete, steel benches and mains wiring, all of which distort the field you are trying to measure.
Check it before you fly
Is the heading right?
Use the compass app on your phone. Hold it with its top pointing the same way as the nose, and compare its reading with the heading in your ground station. Turn the aircraft slowly, keeping the phone aligned — the two should agree, and should move together in the same direction.
An error of exactly 90°, 180° or 270° means the orientation parameter is wrong, not the calibration.
Is the fix good enough?
Wait for the position to settle before arming. A reasonable rule for a first flight:
| Check | Target |
|---|---|
| Fix type | 3D fix or better |
| Satellites | 8–10 or more |
| HDOP | below about 1.5 |
| Position on the map | stable, not wandering |
Satellite count on its own is not a quality measure. A receiver seeing plenty of satellites can still report a poor position if the geometry is bad or the signals are reflections off a nearby building. HDOP and the reported accuracy figures tell you more than the number of satellites.
Does the heading hold under power?
With props off and the aircraft restrained, raise the throttle and watch the heading. If it swings as current rises, the compass is picking up the field from the power wiring — move it further away and recalibrate. This test takes a minute and catches a fault that otherwise appears only in flight, far away, in an auto mode.
Easily confused points
"GPS problem" usually means "compass problem." Circling, drifting and wandering in position hold are heading faults far more often than positioning faults.
Orientation and calibration fix different things. Orientation tells the firmware which way the sensor faces; calibration removes your airframe's magnetic distortion. Each is useless without the other.
COMPASS_ENABLE is not COMPASS_USE. One switches the sensor on, the other decides whether navigation trusts it.
A compass calibrated indoors is not calibrated. Reinforced concrete, steel furniture and mains wiring all distort the field.
More satellites is not the same as a better fix. Watch HDOP and accuracy.
Betaflight GPS is not INAV GPS. Betaflight's implementation targets GPS Rescue; missions and position hold live in ArduPilot and INAV.
An external compass needs extmag firmware on INAV and Betaflight. No amount of correct wiring makes an intmag build see it.
Troubleshooting
| Symptom | Where to look |
|---|---|
| No GPS detected | Rx/Tx crossed? Port set to the GPS protocol? Module actually powered? |
| Detected, but no satellites | Go outside with open sky. A first fix after long storage can take several minutes. Check nothing sits above the antenna. |
| Compass not detected | The I2C pair (SCL/SDA). On INAV/Betaflight, check you are on an extmag build. |
| Heading off by a constant 90/180/270° | Wrong orientation value for your module and mounting. |
| Heading swings with throttle | Magnetic interference — increase the distance from power wiring, then recalibrate. |
| Calibration will not complete | Interference, or the module is not rigidly mounted. Move outdoors, away from metal. |
| Circles in position hold | Heading first: orientation, then calibration, then interference. |
| Position jumps near buildings | Multipath — reflected signals. Nothing configurable fixes this; fly with more sky, or move to a dual-band or RTK module. |
Related guides
- GPS Module User Manual — specifications and wiring for each module
- External Compass Orientation — the orientation value tables
- MG-F10-C — Dual-Band GNSS Module
- What Is RTK? — when centimetre accuracy is worth it
- Firmware Flashing Guide — including flashing an
extmagbuild
Where to buy
GPS and compass modules, shipped from Canada with free Canada-wide shipping:
- M10G-5883 — the default choice, 20 × 20 mm, 7 g
- MG-903 — four constellations and an IST8310 compass
- MG-F10-C — dual-band L1+L5, sub-metre
Written and maintained by the Robofusion engineering team.