@Joseph_O I solved the problem. Today, while driving in the car, the phone 1 compass was not giving accurate results, so I tried it with another phone to see if a magnetic field was affecting it, but that phone gave the correct result, so I downloaded a magnetic field meter and took a tour in the car, and then I realized that some points were seriously affecting the magnetic field. I took the phone 1 in my hand in the position where the magnetic field was low and tested it by another phone. The other phone was giving the correct result, but the phone 1 was making a very serious deviation in a very small magnetic field. Even though there was a very low field of approximately 180 degrees, there was a very serious deviation. . I came home and tested it again at a point where there was no magnetic field. This time I got almost 98 percent correct results. Maybe the phone is really sensitive or I think a software adjustment is needed because other phones give correct results, but phone 1 is very much affected by a very small field.