SparkFun Forums 

Where electronics enthusiasts find answers.

General project discussion / help
Did you make a robotic coffee pot which implements HTCPCP and decafs unauthorized users? Show it off here!
By radirobi97
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
By radirobi97
jremington wrote: Tue Oct 02, 2018 10:02 am 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: ... r-arduino/
Dear Jremington!

Thank you for your reply. Estimation of roll and yaw angle is impossible just from the magnetometer?
By jremington
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: ... lt_Sensing