<div style='text-align:justify;'> Due to the influence of processing technology and environmental factors, there are errors in attitude measurement with the three-axis magnetometer, and the change of parameters during the operation of the magnetometer in orbit will have a great impact on the measurement accuracy. This paper studies the calibration method of magnetometer based on BP neural network, which reduces the influence of model error on calibration accuracy. Firstly, the error model of the magnetometer and the structural characteristics of the BP neural network are analyzed. Secondly, the number of hidden layers and hidden nodes is optimized. To avoid the problem of slow convergence and low accuracy of basic BP algorithm, this paper uses the Levenberg Marquardt backpropagation training method to improve the training speed and prediction accuracy and realizes the on-orbit calibration of magnetometer through online training of the neural network. Finally, the effectiveness of the method is verified by numerical simulation. The results show that the neural network designed in this paper can effectively reduce the measurement error of magnetometer, while the online training can effectively reduce the error caused by the change of magnetometer parameters, and reduce the measurement error of magnetometer to less than 10 nT. </div>