I will now explain how I perform gyro drift compensation in the pitch and roll directions using the output of an accelerometer. In a future post I will discuss using a magnetometer to counter gyro drift in the yaw direction. Before going into the theory and math, here's a quick overview of what an accelerometer is.