Tag Archives: imu

Create a Digital Compass with the Raspberry Pi – Part 2 – “Tilt Compensation”

This part 2 of a multi part series on how to use a digital compass(magnetometer) with your Raspberry Pi.

Part 1 can be found here and is a prerequisite to part 2.

Code for this guide

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

pi@raspberrypi ~ $ git clone https://github.com/ozzmaker/BerryIMU.git


The code for this guide can be found under the compass_tutorial02_tilt_compensation directory.

Calculating Compass Heading

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.

Compass Tilt Compensation


Continue reading Create a Digital Compass with the Raspberry Pi – Part 2 – “Tilt Compensation”

New Kickstarter Launched – BerryIMU

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.

BerryIMU for the raspberry pi

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.

Head on over to Kickstarter.com to check it out;