How to read rotation of device with magnetometer

Hi,

I have magnetometer HMC5883L. I need to read rotation angles of device (azimuth and elevation) comparing to true north.

I see there is geometry library available which probably I can use but I am not sure how to use it.
Anyone knows or is in possesion of such example?

BR
Marcin

You can use the HMC5883L as a magnetic compass to read azimuth. Google "hmc5883L compass" for lots of tutorials.

The sensor will need to be calibrated in place, at the very least to correct for magnetometer X and Y offsets, or the compass readings will probably be useless.

A MEMS compasss / magnetometer knows nothing about true north, only magnetic north.

Are you wanting to correct for the magnetic declination?

I need to know how much whole device has been rotated. It must not be relative to true north. Magnetic north is good enough (readings from compass)

I need to find library (probably geometry library will be able to deal with this) and find out how to use it.

Once I will find function I can apply corrections by myself

See reply #1.

Yep. Three days I am not doing anything else than reading tutorials. Most of them is answering the same questions. I was reading about Euler rotation matrices trying to create function by myself.
Either google did not answer how to calculate rotation angles not my own calculations did not produce any good results.