The method of interpolation was used in the process of software compensation of temperature in order to improve the environmental performance of air level posture sensor. Two algorithms including Lagrange interpolation and piecewise linear interpolation were calculated and compared in Matlab software, and then the optimization scheme could be achieved. The result showed that although the curse of Lagrange interpolation included all the given data positions, the Runge phenomenon in polynomial interpolation made the accuracy of interpolation lower. Piecewise linear interpolation reflected the relationship between environment and zero voltage more accurately. Piecewise linear interpolation not only can be used to improve the accuracy of software compensation of air level posture sensor.