A real-time and high precision ultrasonic ranging method is proposed here. Ultrasonic ranging system based on MCU was established, which is composed of MCU, ultrasonic sending and receiving circuit, temperature compensate circuit, alarm, key and display circuit. Counting pulse method was used to measure the ultrasonic transmission time, and then the distance is calculated. In order to improve the ranging accuracy, temperature compensation was used in this system. Preliminary experiment showed that the system meet the requirements. This system has advantages such as low price, small volume, reliable operation, high accuracy, and can be employed in car backing, obstacle avoiding of robots, industrial logging, reservoir level measuring etc.