SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By TonyMS
#7572
Can anyone point me to an algorithm for a tilt-compensated heading? I have a Vector 2x compass to give me a raw heading, and an ADXL202JE to give me tilt measurement, so I have all the raw data.

I'm working on an autopilot for a boat, which, of course, is not a stable platform.
By shobble
#10017
You could have a look at application note AN2272 from Cypress Microsystems.
(I'd post a link, but they use some goddawful sessions based thing which means links expire after an hour or two)

search the title above at www.cypress.com and it should turn up.

It covers building it from scratch with discrete magnetometers and an accelerometer, but if you can follow the maths, you should be able to adapt it to use the raw data from your compass module.