# What is an Ultrasonic Sensor?

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

## Basic Understanding

An Ultrasonic sensor is a device that can measure the distance to one of more objects by using sound waves. It measures the distance my sending out a sound wave at a specific frequency, and listening for that sound wave to bounce back. By measuring the time for the sound wave to bounce back, it is possible to calculate the distance the sound wave traveled and thus the distance to the object.

diagram of the basic ultrasonic sensor operation.

Since it is known that sound travels through air at about 344 m/s (1129 ft/s), if you take the time for the sound wave to return and multiply it by 344 meters or 1129 feet, and you will find the total round-trip distance of the sound wave. We say round trip because the measured time is for the sound wave to go out, hit the object then come all the way back. This means that the sound wave traveled 2 times the distance to the object before it was detected by the sensor. So to find the distance to the object, we just divide the round-trip distance by 2.

NOTE: The accuracy of Ultrasonic sensors can be affected by the temperature and humidity of the air they are being used in. However, for these tutorials and just about any project you will be using these sensors in, this change in accuracy will be negligible.

It is important to understand that some objects might not be detected by ultrasonic sensors. This is because some objects might be shaped or positioned such that the sound wave bounces off the object, but instead of heading back to the sensor, the bounce away from the object. It is also possible for the object to be too small, and thus, does not reflect enough of the sound wave back to the sensor to be detected. Other objects can absorb the sound wave all together, which means that there is no way for the sensor to detect them. These are important factors to consider when designing and programming a robot.