HMC5883L Compass, Formulas requested

Has anybody formulas to calculate the tilt and inclination (=heading).
Purpose: to built an inclinometer.

ArduinoStarter1:
Has anybody formulas to calculate the tilt and inclination (=heading).
Purpose: to built an inclinometer.

You'll need an accelerometer to go with your magnetometer in order to figure out your tilt and heading.

You could use the magnetometer to figure out your tilt if you could be be sure the heading of the magnetometer doesn't change.

Alternatively, you could use your magnetometer to figure out your heading if the tilt of the magnetometer doesn't change.

If both the heading and the tilt are free to change, then you'll need an accelerometer to compensate for tilt.

These sorts of calculations are frequently discussed on the forum. Have you tried forum search? Forum member "jremington" has posted links to this sort of information several times. You might want to include his screen name in your search.

IIRC jremington mentioned Adafruit has a good tutorial on calibrating a magnetometer.

Thanks!
I will study on it.

An inclinometer measures the tilt angle with respect to horizontal, for which you need only a 2 or 3 axis accelerometer. Is that what you meant?

If you meant a tilt compensated compass, this application note describes the procedure in great detail. The key is equation 22 of that document.

A simpler approach using vectors is described and C code is presented here.

As duanedegn mentioned, it is absolutely essential to calibrate the magnetometer, which is also described in the AN4248 application note.