With the development of society and economy, the number of cars on the road has exploded and caused a series of traffic problems. Only relying on the rear-view mirror has been unable to meet the safety requirements of drivers on the rear collision of cars. Based on the analysis of ultrasonic sensors and STC89C52 microcontroller, the advantages and disadvantages of various ranging principles and factors affecting the accuracy of ultrasonic ranging are studied, and the temperature compensation method is added to improve. The LCD display screen is used to display the distance between the car and the obstacle and the current temperature, and when the distance between the two is less than 5cm, a buzzer is sent to prompt. The ranging system has the advantages of simple structure, low cost, high accuracy, LCD display real-time display of changing distance, and a driving motor to make the car move, to meet the requirements of mobile ranging.