Attitude determination is one of the most important subsystems in spacecraft, satellite, or scientific balloon mission s, since it can be combined with actuators to provide rate stabilization and pointing accuracy for payloads. In this paper, a low-cost attitude determination system with a precision in the order of arc-seconds that uses low-cost commercial sensors is presented including a set of uncorrelated MEMS gyroscopes, two clinometers, and a magnetometer in a hierarchical manner. The faster and less precise sensors are updated by the slower, but more precise ones through an Extended Kalman Filter (EKF)-based data fusion algorithm. A revision of the EKF algorithm fundamentals and its implementation to the current application, are presented along with an analysis of sensors noise. Finally, the results from the data fusion algorithm implementation are discussed in detail.