Incorrect readings if mag tilted [True?]

Hello dear members,

Is it true that a 3 axis magnetometer outputs the wrong values if you tilt the sensor, and the more you tilt it the worse it gets?

The reason of why Im asking this is because Im in need of a correct yaw value, since the gyroscope doesn't output the correct value. So the question is if I need to combine a magnetometer with a gyroscope to read the correct yaw value.

Any help would be appreciated, especially links with equations to solve this problem.


Yes, it's true. Many pages have been written about it. A tilt compensated compass is what you need.

It is because the direction of the magnetism is not pointing to the horizon, but it could be pointing down into the ground with 60 degrees. Click on this map on your location. The "Inclination" is how much it is pointing down. 0 degrees is to the horizon, 90 degrees is straight down. If the number is negative it is pointing up.,152529.0.html

Hello dear Erdin,

The negative part with the algorithm provided by loveelectronics is that you are limited to 45 degrees tilt. Would quaternion support a tilt upto 360 degrees?

Thanks for taking your time Cheers

Edit: Isn't it just possibly to combine a gyroscope with a magnetometer instead of an accelerometer?

I have little understanding of quaternion, but that should be able to handle 360 all around. I have not heard of a gyro and magnetometer combination. The gyro MEMS sensors drift, so you would never know what is up and what is down.

In Europe the inclination is about 65 degrees down into the ground. Once I knew that, it really opened my eyes to understand the values of the magnetometer.