“This instructable explains how to make a tilt compensated compass using an Arduino UNO R3, an LCD display, and an IvenSense MPU-9250 multi-chip-module that contains an MPU-6050 accelerometer / gyro and an AK8963 magnetometer within the same package.
The LCD simultaneously displays the Heading, (P)itch, and (R)oll.
The heading accuracy is within 2 degrees depending on how well the compass has been calibrated.
Without tilt compensation the compass headings vary significantly … sometimes by as much as 100 degrees.
When stabilised, the tilted compass headings only vary by one or two degrees … the improvement is amazing.
The tilt stabilization may be disabled by placing a jumper wire between Arduino pins A0 and GND.”