When sensors perform measurements, certain errors can occur. In the process of oil pipe welding, inaccurate temperature measurements can severely affect the quality of the welded pipes and may even lead to the scrapping of raw materials. To eliminate the impact of reference end temperature on the input-output characteristics of the sensor, we can apply the Whale Optimization Algorithm (WOA) to improve the connection weights and thresholds of the BP neural network, thereby developing a WOA-BP neural network model. By using data such as the distance between the sensor and the measured object, and the sensor measurement values as inputs to the WOA-BP neural network prediction model, and comparing the prediction results with those of the traditional BP neural network, The results indicate that, compared to the traditional BP neural network model, the BP neural network model optimized by the WOA algorithm shows significant improvements. The Mean Absolute Error (MAE) decreased from 0.7521 to 0.255, the Mean Absolute Percentage Error (MAPE) decreased from 0.8642 to 0.194, and the correlation coefficient increased from 0.9471 to 0.9825. There for this improvement can effectively enhance the prediction accuracy of the temperature sensor.