With the development of aerospace business and the popularization of automobile and yacht, navigation has been an important part of people’s life. And in the area of navigation, obtaining of yaw angle appears especially important. This paper designed a electronic compass with angle compensation used magnetoresistive sensor and accelerometer, which has certain reference value to yaw angle calculation of navigation system.