Part 1 covered how to get the heading from the magnetometer, however this is only reliable when the magnetometer is on a flat surface. If the magnetometer is tilted, the heading will skew and not be correct.
The chart below shows a compass being held at 200 degrees and being tilted in various directions. The blue line is the raw heading, the orange line is the heading after applying tilt compensation. As you can see, without tilt compensation the heading will change if the compass is tilted.
An accelerometer, gyroscope and magnetometer which is specifically designed for the Raspberry Pi.
What is it?
BerryIMU is an inertial measurement unit, or IMU, that measures and reports on velocity, orientation and gravitational forces, using a combination of an accelerometer, gyroscope and a magnetometer.
IMUs can be found in devices like, quad copters, smart phones, segways, Wii Remote etc.. and are used to sense movement and orientation.
Adding BerryIMU to your Pi will open up a whole new world of possibilities.
BerryIMU is specifically designed for the Raspberry Pi and is designed to take some of the complexity out of IMUs and to try and make them more enjoyable to use. BerryIMU includes the latest and greatest sensor ICs.