Knowledge Center - Robotics

IR Sensor vs. Ultrasonic Sensor: What is the difference?

Are you looking for a way to measure distances? If you’re looking for a new sensor and you’re not sure which one to purchase, you might be considering the Infrared sensor (IR sensor) vs. the ultrasonic sensor. Choosing a sensor for a certain application, can be a challenge for any project, your system may depend greatly on the sensor you choose.

In this article, we’ll take a look at the IR sensor vs. the Ultrasonic Sensor.

When choosing the sensor, there are a lot of things to take in consideration, so that you can determine the right way to go.

  • Accuracy – How close the reading is to the true distance.

  • Resolution – The smallest reading or change in readings that can be reported.

  • Precision – The smallest reading that can be taken repeatedly and reliably.

  • External factors - Like sunlight that affects IR sensors, or sound absorving materials that give an hard time to ultrasonic sensors.

The biggest difference between IR sensor vs. ultrasonic sensors is the way in which the sensor works. Ultrasonic sensors use sound waves (echolocation) to measure how far away you are from an object. On the other hand, IR sensors use Infrared light to determine whether or not an object is present.

Accuracy and reliability are also big differentiators in these sensors. Most often, ultrasonic sensors will provide you more reliable and accurate data than IR sensors. If you want an accurate, numerical representation of distance for your project, I’d almost always choose an Ultrasonic sensor.

However, if you only need to know if an object is present or not, then an IR sensor is easier to implement. Now, let’s talk a little bit more about both of these sensors and their technical specifications.

How ultrasonic Sensors Work

Ultrasonic sensors work on the principle of reflected sound waves and are used to measure distance. One sensor can detect others operating nearby. Sound waves are emitted by the ultrasonic sensor and they’re reflected back if there is an object in front of it. The sensor detects these waves and measures the time it takes between transmitting and receiving those sound waves. Distance is then estimated by the time interval between sensor and object.

Ultrasonic sensors use soundwaves to transmit and receive information over a duration. The duration is then converted to a distance measurement based on the Speed of Sound (340 m/s). There are ultrasonic sensors at every price point. If you’re looking for something affordable for your hobby project, I recommend the HC-SR04. Here’s a close-up of an ultrasonic sensor module.

Ultrasonic sensors are, for the most part, completely insensitive to hindering factors like:

  • Light
  • Dust
  • Smoke
  • Mist
  • Vapor
  • Lint
  • Etc.

Ultrasonics aren’t as good as Infrared at defining edges of an area.

Applications for Ultrasonic Sensors

Mobile Robot Object Avoidance Ultrasonic sensors are often used on mobile robots to avoid objects. You can use an array of HC-SR04 sensors and determine which way to move depending on which sensor has the highest distance reading. This will tell you that objects are farther away and it’s therefore, safer to move in that direction.

Distance or Height Calculations The HC-SR04 is great for measuring levels. For example, you can determine how much snow is on the ground or the level of a tank.

Ultrasonic Sensors Pros and Cons


Detection without physical contact

An ultrasonic sensor measures the distance and detects the presence of an object without making physical contact. It produces and monitors an ultrasonic echo. Depending on the sensor and object properties, the effective range in air is between a few centimeters up to several meters. The ultrasonic sensor generates and emits ultrasonic pulses that are reflected towards the sensor by an object that is within the field of view of the sensor.

Compact size and low cost

They are generally of small size that makes them easier to use especially in a robotic application and give in real-time a measure. They do not use much electricity, are simple in design, and are relatively inexpensive.

High sensitivity

Ultrasonic sensors can be used to solve even the most complex tasks involving object detection or level measurement with millimeter precision because their measuring method works reliably under almost all conditions. Ultrasonic sensors detect objects without touching them, they do not scratch the sensing objects.


They can withstand even the toughest conditions, such as the leak test up to IP 69, or unrealistic tough conditions such as sandblasting.

Large measuring range

The newly developed sonic sensors enable large measuring ranges up to 600cm. This enlarges the application range.

Variety of object detection

Ultrasonic sensors can detect a variety of materials, regardless of shape, transparency, or color. The only requirement for ultrasonic sensing is that the target material is solid or liquid. This enables contactless detection of metal, plastic, glass, wood, rocks, sand, water. These materials can reflect sound towards the sensor through the air.

For example, optical sensors have limitations in detecting clear materials like glass or water. Light passes through these materials, whereas ultrasonic bounces off.

Dust and dirt resistance

Ultrasonic sensors are relatively dust and dirt insensitive. The highly robust housing eliminates any potential weak points that could cause damage in harsh environments. Besides, dark environments do not affect an ultrasonic sensor’s detection ability.

Wide application areas

Ultrasonic sensors have proven their reliability and endurance in virtually all industrial sectors. These sectors include:

  • Mechanical engineering/machine tool
  • Food and beverage
  • Woodworking and furniture
  • Building materials
  • Agriculture
  • Construction
  • Pulp and paper
  • Material handling
  • Level measurement

Short blind zone

The extremely short blind zone ensures maximum downward compatibility. This enables the reliable detection of objects close to the sensor and optimum adaption of mounting depths. As the blind zone has to be kept free to exclude signal errors, a short blind zone also improves the possibilities for mounting an effective object detection.

Level monitoring

Liquids are a very good reflector of ultrasonic waves if they do not form any foam. Ultrasonic sensors are therefore ideal for monitoring the level of liquid containers. Spray and droplets do not affect the sensor and it even cleans itself through the movement of the sonic transducer.


They do not require so much maintenance. They have a long lifespan.


Atmospheric movements

Atmospheric movements disturb the measurement and can reduce the range. Working can be disturbed by noise (industrial for example) which induces detection errors.


The collection of measurements may be affected by the sensor (movement of a manipulator’s arm or mobile robot). For precision measurement or high-speed robot displacement, it is necessary to take the displacement into account.

Low angular measurement

Due to the acoustical beamwidth of the transducers, the angular accuracy of the measurements is low (in the order of 10 to 20 degrees).

Slow acoustic measurement

Acoustic measurement is slow compared to light due to the lower speed of acoustic signals.

Difficult to manipulate acoustic beams

Due to the high wavelength, it’s more difficult to manipulate acoustic beams (focusing, collimating). The wavelength of the acoustic beam for a 50 kHz transducer is ±7 mm, which is much larger than the roughness of most indoor surfaces. As a result, the reflection of ultrasonic beams off the smooth surface can reflect away from the sensors and become invisible or create multiple reflections.

Slow reaction

They react slowly. Optical-based sensing technologies have a similar principle to ultrasonic technology. Instead of using sound waves, however, optical technology uses LEDs to emit light waves and detect the time of flight, which can then convert based on the speed of light principle. The speed of light is much faster than the speed of sound, therefore optical-based sensing is faster than ultrasonic.

Cannot detect sound-absorbing materials

They cannot detect sound-absorbing materials. Certain objects can be more difficult to detect, like angled surfaces that direct the echo away from the sensor, or permeable targets like a sponge, foam, and soft clothing. These absorb more reflected ultrasonic energy.

Temperature changes sensing accuracy

Ultrasonic sensors are very sensitive to variations in temperature. To avoid this problem, you need to use temperature compensated models.