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.

If my phone lays on a table the 'z' axis points up. (see the picture below). The values of magnetometer are: ~15 microT in X direction, ~8 microT in Y direction and ~-55 microT in Z direction. axis

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

Thank you, Robert

  • 1
    $\begingroup$ Welcome to Robotics, Róbert Rádi. Could you please provide a diagram or drawing of your setup? Please include the orientation of the sensor/phone, showing which directions the axes are pointing; your definition of what roll, pitch, and yaw are; and in which plane the magnetic field exists. This diagram should be enough for you to answer your own question, but please do edit your question to include the diagram if it's not. I don't know if your phone's z-axis points up when the phone is held upright, like on a call, or if z is up when the phone is laid on its back, or something else. $\endgroup$ – Chuck Oct 1 '18 at 13:11
  • $\begingroup$ Dear Chuck, I have edited my post. I hope this helps you all to understand my problem! $\endgroup$ – Róbert Rádi Oct 3 '18 at 12:58

Usually the magnetometer is used to find the yaw. It acts as a digital compass in this case. To calculate roll and pitch you need an accelerometer. But there are some techniques that can be used to calculate the roll and pitch using the magnetometer. For that you need to place a magnet close to the mobile phone and observe the sensor values. Using these values you can calculate the roll and pitch with respect to the position of the magnet. You may find the necessary equations from the following link.


  • $\begingroup$ Dear Tharindu Suraj! Thank you for your answer. But as I see, the link you suggested gives just information about how to calculate roll, pitch using an accelerometer. Do you have any ideas where could I find the description of method you mentioned? $\endgroup$ – Róbert Rádi Oct 10 '18 at 7:55
  • $\begingroup$ I assume that you understand the basic principle which is used to calculate the roll and pitch. Basically it uses the gravitational acceleration measurements on x,y and z axes to calculate the rotation from the neutral position where Az = 9.8ms-2. Using the same principle, taking the magnetic field into account you can calculate the roll and pitch. I couldn't find any sources related to this. This is just an idea I came up before. $\endgroup$ – Tharindu Suraj Oct 11 '18 at 10:18

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.