Orientation from magnetometer data

Dear Experts!

I saw lot of topics with the same title but answers are different.

I have a magnetometer in my phone which give me the components of magnetic field in direction of X, Y, Z.

Which of the following angles can be determined using datas of magnetometer? Roll, pitch, yaw? And how?

Thank you, Robert

yaw_angle=atan2(magy,magx); //if magnetometer is held level, with Z straight up or down. angle in radians to magnetic North.

It is essential to calibrate the magnetometer, as described here: https://thecavepearlproject.org/2015/05 … r-arduino/

jremington:
yaw_angle=atan2(magy,magx); //if magnetometer is held level, with Z straight up or down. angle in radians to magnetic North.

It is essential to calibrate the magnetometer, as described here: https://thecavepearlproject.org/2015/05 … r-arduino/

Dear Jremington!

Thank you for your reply. Estimation of roll and yaw angle is impossible just from the magnetometer?

The magnetometer makes three measurements, so you can get two 3D orientation angles, related to the local magnetic field direction (which points into the ground in the Northern hemisphere). Yaw can be one of the angles. What you call the other is up to you.

Using the same method, you can get standard pitch and roll angles from an accelerometer, as described here: https://www.dfrobot.com/wiki/index.php/ … lt_Sensing