Compass Tilt Compensation

BerryIMU Python Code now Includes Tilt Compensation

The python code for BerryIMU now includes tilt compensation for the compass heading.


Git repository here
The code can be pulled down to your Raspberry Pi with;

pi@raspberrypi ~ $ git clone


BerryIMU Raspberry Pi Gyroscope Accelerometer

Tilt Compensation

Without tilt compensation the heading (magnetometer reading) will be skewed when the IMU is tilted.

The below graph below shows a magnetometer (or 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.

Compass Tilt Compensation

More information about tilt compensation can be found in this post



Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.