ardupilot sensor setup airspeed optical flow

ArduPilot Sensor Setup: Airspeed, Optical Flow and Compass

Khalid Hesham Updated 5 min read

Quick Answer

Airspeed, optical flow, and compass sensors each need care. Wire each one to the right port. Turn it on in ArduPilot's settings. Then calibrate it on the ground before you trust it in the air. Do this right, and ArduPilot gets clear speed, position, and heading data. That data is the base for safe auto flight.

Why Sensor Setup Deserves Its Own Checklist

Basic ArduPilot setup covers firmware, frame type, and radio checks. Every aircraft needs these. But many builds add extra sensors on top. This might be an airspeed sensor for a plane, an optical flow sensor for GPS-free hold, or a second compass for backup.

Each sensor has its own wiring, its own setting to turn on, and its own check. Skip or rush any of these, and you get a drone that flies fine in Stabilize but acts up in a GPS mode.

Connecting an Airspeed Sensor

Airspeed sensors connect over I2C or DroneCAN, based on the model. Digital DroneCAN sensors are easier to wire. They share the same bus as other DroneCAN parts, like GPS and power modules.

Once wired, turn on the airspeed sensor type in Mission Planner. Match it to your exact model. Then run the ground check with no wind hitting the tube. This sets a true zero reading. For more on how these sensors work, see airspeed sensors explained.

Checks to run after wiring:

  • Check the sensor reads near zero with no wind and no motion.
  • Blow gently across the tube and check the reading goes up.
  • Set the sensor as your main airspeed source in the settings.

Connecting an Optical Flow Sensor

An optical flow sensor watches the ground below. It tracks how the picture moves. This lets ArduPilot guess how far the drone moved without GPS. This helps most for indoor flying or GPS-free position hold.

Optical flow sensors almost always need a paired rangefinder. The flow sensor must know the height above ground to scale its guess right. Mount both sensors facing straight down. Keep them away from vibration. Give them a clear view of a textured surface. A plain surface, like clean tile or water, gives poor results. The sensor has nothing to track.

In ArduPilot, turn on the flow driver that matches your sensor. Set the rangefinder type it will pair with. The check often means a short hand-held test. Move the aircraft a known distance and compare it to the sensor's reading. Adjust a scale setting until the two match. For more on how this works, see optical flow sensors explained.

Connecting and Calibrating a Compass

Most GPS modules have a compass built in. It connects on the same GPS cable, or over DroneCAN. Some builds add a second, outside compass for backup. This helps most on large aircraft, where the main compass sits closer to power wires.

To calibrate:

  1. Open the compass check screen in Mission Planner.
  2. Move the aircraft slowly through many angles. Stay away from metal desks, cars, or large steel parts.
  3. Let Mission Planner gather enough points. Check the calibration ends with a low error score.
  4. If you have more than one compass, set the main one. Keep the others turned on as backups, not off.

A poor compass check, or a compass too close to a power cable, often shows up as circling or drift in GPS modes. This can happen even when the aircraft flies fine in Stabilize.

Key Parameters to Check

Exact names can shift a bit between ArduPilot versions. Still, check these for each sensor type:

SensorWhat to check
AirspeedSensor type, main source setting, ratio after a test flight
Optical flowDriver type, paired rangefinder, scale after a test
CompassMain compass pick, mount direction setting, error score

Getting the mount direction wrong is a common but easy-to-miss mistake. This means the sensor sits in a direction ArduPilot does not expect. Always match this setting to how you mounted the part.

Testing Before You Trust a Sensor

Never trust a sensor just because it shows a number. Run a quick check on each one first:

  • Airspeed: blow across the tube. Check the number moves the right way.
  • Optical flow: move the aircraft by hand a known distance. Check the reading is close.
  • Compass: turn the aircraft. Check the heading in Mission Planner moves smoothly, with no jumps.

These simple checks catch most wiring and setup mistakes before they cause a bad flight. For the full setup order from firmware onward, see ArduPilot setup: first configuration step by step.

When a Sensor Still Misbehaves

If a sensor still reads wrong after a check, look at the mount first. Vibration, a wrong mount direction, and noise from nearby wires cause more sensor problems than a real fault. Reseating plugs and checking firm, correct crimps often fixes issues that look like a sensor fault.

FAQ

Do I need optical flow if I already have GPS?
Not always, but it helps near buildings, indoors, or under heavy trees, where GPS can get weak.
Can I run two compasses at once?
Yes. ArduPilot can use extra compasses as backups, or to cross-check each other for better trust.
Why does my optical flow sensor work indoors but not outdoors?
Check the rangefinder's range limit. Some rangefinders struggle in bright sun or at higher heights above ground.
How often should I recheck these sensors?
Recheck after any change to mounting, wiring, or a hardware swap. A good check should hold for the life of the sensor otherwise.
What is the biggest mistake people make here?
Skipping the quick ground test and trusting the first reading. A short manual test catches most wiring and mount mistakes early.