Infrared Distance Sensor

Infrared distance sensors measure the distance to the closest obstacle in a straight, narrow beam of light. These sensors work by emitting a pulse of light (wavelength range of 850nm +/-70nm) which is then reflected (or not reflected at all). When the light returns, it comes back at an angle that is dependent on the distance of the reflecting object. By knowing the angle, distance can then be determined. These sensors are commonly used to prevent robots from driving into walls and general object avoidance. Please note that accuracy will usually be reduced when used outdoors due to interactions with sunlight.

Sensor Overview

Obstacle Detection: Detects obstacles in a straight, narrow beam of light. IR sensors have a decent detection range (maybe 10-15 ft max).

Ideal operating conditions: IR sensors can become erratic when exposed to sunlight interference. Some sensors will work perfectly outside while others may be fine with ambient sunlight and have problems only when pointed towards the sun. The rest range from slightly noisy to completely unusable outside.

Sensor Pros:

  • Data is easily processed, allowing the use of cheaper microcontrollers
  • Less expensive than 1D/2D Lidar
  • Good detection range and update rate
  • Can be used for 1D positioning or following applications

Sensor Cons:

  • IR sensors often have discontinuous, nonlinear, and/or noisy output.
  • Only detects obstacles in a narrow beam. If these are the primary obstacle detection sensors on a robot then several of them are required and there will still be big gaps in the detection zone – between the beams and above/below them.
  • You may be tempted to sweep the sensor using an RC servo or something, but this generally doesn’t work very well. You’re better off buying a cheap 2D lidar at that point.
  • These sensors can be vulnerable to dirt/dust and scratches.


Sharp GP2Y0A60SZLF IR Sensor with Carrier
Sharp GP2Y0A21YK0F Analog Distance Sensor 10-80cm
Sharp GP2Y0A02YK0F Analog Distance Sensor 20-150cm