In my project I need to calculate the pitch and the yaw using a chip with magnetometer and accelerometer (FXOS8700CQ), I get the raw values which are integers with a resolution of 16 bits (0-65535). The chip has auto-calibration i know this by the datasheet (http://www.nxp.com/assets/documents/data/en/data-sheets/FXOS8700CQ.pdf).

I can calculate the pitch knowing the raw values of accelerometer is 3 axis (Ax,Ay,Az) and with the formula:

pitch=atan2(Ax,sqrt(Ay*Ay+Az*Az))*(180/PI);

I don't have a clue how to get the yaw with the raw values of accelerometer (Ax,Ay,Az) and magnetometer (Mx,My,Mz).

The yaw is on degrees and is 0º when magnetometer is pointing to north.

Sorry for the long description, please some help.

Greetings,

Nuno Tavares