This paper presents design and implementation of an attitude and heading reference system (AHRS) based on low-cost MEMS sensors and complementary filtering (CF). Different from traditional solutions, information fusion is performed with Euler angles directly, which is more straightforward for understanding; however it proposes many challenges for reaching a stable and accurate estimation as when these angles approach or traverse their range boundaries, estimation may get discontinuous. Thus an effective discontinuity avoiding strategy is suggested in this paper to refine the estimation. Besides, instead of extended Kalman filtering (EKF), CF is utilized for state estimation of AHRS as it features fusion of high-frequency and low-frequency signals. In order to make up for shortcomings of MEMS sensors such as multiple errors, drifts, and bad accuracy, some effective calibration and filtering algorithms are proposed to guarantee agreeable AHRS performance. Also, architecture of the MEMS IMU (inertial measurement unit) and mathematical principles for AHRS solution are explained and implemented in this paper. Meanwhile, experimental comparisons have proved feasibility and acceptable performance of this AHRS design.