The data from i2c interface:
x:254 y:-720 z:-450
...
How to make a compass with these data like below?(xx° NW、xx° SE、 ...)

The data from i2c interface:
x:254 y:-720 z:-450
...
How to make a compass with these data like below?(xx° NW、xx° SE、 ...)

Please read this: https://cache.freescale.com/files/sensors/doc/app_note/AN4248.pdf You can buy devices like https://www.robotshop.com/de/de/neigungskompensierter-magnetkompass-cmps12.html, which are ready to use.
Or you can assume that the sensor is always leveled, then you just need some trigonometry (X,Y) --> (ANGLE,RADIUS) where you drop radius ![]()