Calculate yaw with magnetometer and accelerometer

Thread Starter

Nuno Tavares 1

Joined Mar 21, 2017
Hello everyone, can anyone help me with a doubt about physics and magnetometers ?
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 (
I can calculate the pitch knowing the raw values of accelerometer is 3 axis (Ax,Ay,Az) and with the formula:

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.

Nuno Tavares

John P

Joined Oct 14, 2008
Try dropping your title, <Calculate yaw with magnetometer and accelerometer> into Google, and see what you get.