This paper proposes using TRIAD and Unscented Kalman Filter (UKF) algorithms in a sequential architecture as a part of a small satellite attitude estimation algorithm. This TRIAD+UKF approach can both provide accurate attitude estimates for the satellite and calibrate the magnetometers in real-time. A complete calibration model for the magnetometers, considering bias, scale factor, soft iron and nonorthogonality errors, is assumed. In the algorithm's first stage, the TRIAD uses the available vector measurements (e.g. from Sun sensor and magnetometers) to estimate a coarse attitude. In the second stage, these estimated values are used as quaternion measurements in the UKF algorithm, together with the angular rate measured by a triad of gyros. The state vector for the UKF is composed of the attitude parameters, gyro biases and the magnetometer error terms. In result, we get fine attitude estimate for the satellite by calibrating the magnetometers in real-time. Rather high computational load of the algorithm, mainly due to the additional states, is decreased by filter reconfiguration. We evaluate the algorithm for a hypothetical nanosatellite by numerical simulations. The results show that the attitude of the satellite can be estimated with accuracy better than 0.5deg and the magnetometers can be fully calibrated. (C) 2020 Elsevier Masson SAS. All rights reserved.