I'm trying to make a quadcopter using an arduino as a base. I've read on some physics involving determining pitch, yaw and roll and it seems like I'll need a gyroscope and a accelerometer. However, it's my understanding that this only gives me my orientation relative to a "flat" base (usually the ground). What type of component is needed to determine the elevation of the copter? Would a barometer work?

Is my understanding here correct or am I way off?


2 Answers 2


One method is to fuse data from a GPS with IMU data (typically you'd use a Kalman filter).

You can also use data from a Lidar, Radar altimeter, ultrasonic measurement, barometer, but some of those are going to be prohibitively expensive for many applications. Temperature compensated barometers have come down in price, but keep in mind that only gives you the height from sea level and will not necessarily prevent your vehicle from intersecting with the ground unless you have a topographical map of where the ground is (and know where you are relative to the ground).

A compass sensor can give you orientation (which GPS alone cannot)


Their are a couple of ways to get elevation.

One is as you say, a 'barometer'. I believe that can be pretty accurate, though they need calibration. I believe I have seen claimed sensitivity of better than 0.1 metre.

Another approach is downward pointing ultrasonic distance measurement, which should give good accuracy near the ground, but are little use higher up. This might help you avoid smashing down too hard.

Some systems also have a 'magnetic compass' (magnetometer) to give absolute 'heading' w.r.t. the Earth. The orientation of the Earth's magnetic field varies with latitude; the magnetic flux lines are at different angles to the Earth's surface at different latitude. So to get the maximum out of the 'compass', you need to correct for that. The 'compass' is enough to give a heading, i.e. direction of travel. The Earth's magnetic field is being measured, so the compass is giving information w.r.t. the Earth, and not just the vehicles 'local frame of reference' which is all accelerometers and gyroscopes give.

So 3-axis accelerometers, 3-axis gyroscope, 3-axis 'compass' and a barometer is often described as 10 Degrees of Freedom (10 DoF).

InvenSense and ST both make chips which integrate many sensors (called Sensor Fusion) to give easy to use information. InvenSense have some pretty helpful videos about Sensor Fusion on YouTube.

In general, I don't believe there is enough change in 'compass' values in a short range flight to derive elevation. (I could be persuaded to believe that as some latitudes it might work, but I am not expert enough to advise.) A sensitive barometer, initially calibrated on the ground, would seem to be a simpler solution, for short, small-range flights.

If your plan is to fly across significantly different ground levels, then ground sensing, e.g. with a small ultrasonic 'radar' would seem to be essential. Elevation from barometric pressure is not going to give the distance to the ground, but only distance above or below a calibrated reference point.

If the plan is to spend a long time in the air, even over the same area, then correction for temperature change of barometric pressure will also become important.

Summary: fully autonomous vehicles require much more sophisticated sensors and algorithms than human-piloted remote control vehicles.

Using separate sensors, e.g. gyro, accelerometer and 'compass' has two issues compared to a single integrated device with built-in 'sensor fusion'. First, the sensor fusion algorithms need to be implemented, that might consume enough of an Arduino, that it might cause me to avoid that path. Second, the axis of the sensors are further apart than in an integrated device, and hence may be slightly more complex to use.

I like to support Sparkfun. I have bought Sparkfun breakout boards. I have not looked at the Sparkfun board spec in detail. However I would probably not pay about 4x more for three separate sensors than an integrated 9DoF breakout unless there is a good reason.

  • \$\begingroup\$ I've been looking at the 9DOF stick which seems very popular among copter builders and was wondering what the magnetometer was measuring. I've heard it referred to as a compass - like your post. Does that mean that stick can give me elevation readings? (Here is the board for reference: sparkfun.com/products/10724) \$\endgroup\$
    – nopcorn
    Sep 7, 2014 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.