We have left the code as simple as it can be to make it easier to understand.
The code currently performs angle measurements using the gyroscope and accelerometer , which are fused using a complementary filter. The heading is also calculated using the magnetometer, without tilt compensation. To view pressure;
This will be a multipart series on how to use a digital compass(magnetometer) with your Raspberry Pi.
The magnetometer used in these tutorials is a LSM9DS0 which is on a BerryIMU. We will also point out where some of the information can be found in the Datasheet for the LSM9DS0. This will help you understand how the LSM9DS0 works.
The math and logic in this series can also be used with other magnetometers or IMUs.
We will also go over how to do some basic communication on the i2c bus. As well as using SDL to display the compass heading as traditional compass as shown in the video above.
Git repository here The code can be pulled down to your Raspberry Pi with;
A traditional Magnetic compass (as opposed to a gyroscopic compass) consists of a small, lightweight magnet balanced on a nearly frictionless pivot point. The magnet is generally called a needle. The Earth’s Magnetic field will cause the needle to point to the North Pole.
To be more accurate, the needle points to the Magnetic North. The angle difference between true North and the Magnetic North is called declination. Declination is different in different locations. This angle varies depending on position on the Earth’s surface, and changes over time.
The strength of the earth’s magnetic field is about 0.5 to 0.6 gauss .
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.