Abstract:With the development of science and technology, sensor technology, especially magnetic sensor technology, has been more widely used in the military field. When many weapons and shells are used for longrange strikes, their own internal sensors will measure the surrounding environment variables, then the computer will control them to make more accurate strikes. In this process, the sensors will inevitably have some errors,which affects the accuracy of the military strike. Therefore,a compensation method of the thermal error based on magnetic sensor is proposed.Firstly, the thermal error drift model is designed by analyzing the thermal error of the sensor. Then the temperature sensor and the geomagnetic sensor are used measure the component data of the geomagnetism on the two sensitive axes at different temperatures, and The model derives the data for each sensitive axis after fitting the temperature drift coefficient. The simulation compares the different outputs of the magnetic sensor, and verifies that the method can effectively compensate the thermal error.