I'm using an embedded device with a simple 3-axis Magnetometer on it. I have it currently displaying the X Y Z values in micro Teslas but how do I convert these into a compass heading? I have tried looking it up on Google but everything I find seems extremely complicated/poorly explained.
If possible I'd like to know how to do it both tilt-compensated and also without compensating for tilt.
The values I'm currently getting on a flat surface for X, Y, Z are 70,0.8 and 34.1 respectively in case that somehow helps.
P.S In case it helps here is a snippet of the code I'm using for the magnetometer:
mSensor.enable();
while(true){
wait(1);
mSensor.getAxis(mData);
lcd.cls();
lcd.locate(0,3);
lcd.printf("X=%4.1f micro-Tesla\n\rY=%4.1f micro-Tesla\n\rZ=%4.1f micro-Tesla", mData.x, mData.y, mData.z);