Component guide · Beginner · 3 min read
IR Obstacle Avoidance Sensor Modules

LM393, HS-S02, ACEBOTT, Crowtail IR Reflective, Grove IR Distance Interrupter)
By Geekobot Learning Team · Updated 29 Oct 2026
On this page
An IR obstacle avoidance module shines infrared light and watches for it to bounce back. When something is within about 2 to 30 cm, an LM393 comparator pulls the output low and an LED lights. A trimmer sets the distance. They are the standard sensor for small obstacle-avoiding and edge-detecting robots. Some versions also give an analog output.
Key specs at a glance
- Supply
- 3.3 to 5 V
- Range
- About 2 to 30 cm (shorter on dark surfaces)
- Output
- Digital, low when an object is seen; analog on A versions
- Comparator
- LM393
- Adjust
- Trimmer for distance
- Angle
- About 35 degrees
Models in this guide
These are alternatives. Pick the one that fits your project; you only need one.
Option 1Infrared Obstacle Avoidance Sensor Module (Active Low) – LM393 Comparator, 2-30cm Range₹26
Option 2HS-S02-L Infrared Obstacle Avoidance Sensor Module – PH2.0 3P Terminal₹159
Option 3HS-S02A Infrared Obstacle Avoidance Sensor Module – Digital & Analog Output₹120
Option 4HS-S02P Infrared Obstacle Avoidance Module – Digital/Analog Output, PH2.0 3P Connector₹138
Option 5ACEBOTT Infrared Obstacle Avoidance Sensor Easy-Plug Compatible with ESP32/Arduino₹237
Option 6Elecrow Crowtail- IR Reflective Sensor 2.0 Module – 4-15mm Detection, 5V Digital Output₹219
What the IR obstacle avoidance sensor modules is
The IR obstacle avoidance sensor module uses an IR LED and receiver with an LM393 comparator to give a digital LOW when an object is within about 2 to 30 cm.
These modules use plain, unmodulated IR, so sunlight and bright lamps can trigger them. Indoors they work well.
The Crowtail IR reflective sensor and Grove IR distance interrupter have shorter ranges for line and edge detection.
IR obstacle avoidance sensor modules pinout
The pins on the IR obstacle avoidance sensor modules and what each one does.
| Pin | Function |
|---|---|
| VCC | 3.3 to 5 V |
| GND | Ground |
| OUT / DO | Digital output |
| AO | Analog output (some modules) |
- VCC
- 3.3 to 5 V
- GND
- Ground
- OUT / DO
- Digital output
- AO
- Analog output (some modules)
Wiring the IR obstacle avoidance sensor modules
Connect the IR obstacle avoidance sensor modules like this.
| IR obstacle avoidance sensor modules pin | Arduino Uno | ESP32 |
|---|---|---|
| VCC | 5 V | 3.3 V |
| GND | GND | GND |
| OUT | D2 | GPIO 27 |
| AO | A0 | GPIO 34 |
- VCC
- Arduino Uno:
- 5 V
- ESP32:
- 3.3 V
- GND
- Arduino Uno:
- GND
- ESP32:
- GND
- OUT
- Arduino Uno:
- D2
- ESP32:
- GPIO 27
- AO
- Arduino Uno:
- A0
- ESP32:
- GPIO 34
Example code
A minimal sketch to check the part works.
const int IR = 2;
void setup() { Serial.begin(115200); pinMode(IR, INPUT); }
void loop() {
if (digitalRead(IR) == LOW) Serial.println("Obstacle: stop and turn");
delay(50);
}Setup and tuning
VCC to 3.3 or 5 V, GND, and OUT to a digital pin.
OUT goes LOW and the LED lights when an obstacle is detected.
turn the blue trimmer to set the detection distance.
sunlight and lamps add IR, which reduces range; shade the sensor.
black and dark objects reflect less and are detected closer.
What you need
Shop this list10 of 11 found in our store · ₹1,870
Generic Infrared Obstacle Avoidance Sensor Module (Active Low) – LM393 Comparator, 2-30cm Range: the part this guide coversInfrared Obstacle Avoidance Sensor Module (Active Low) – LM393 Comparator, 2-30cm Range₹26
HS-S02-L Infrared Obstacle Avoidance Sensor Module – PH2.0 3P Terminal: another version this guide coversInfrared Obstacle Avoidance Sensor Module₹88
HS-S02A Infrared Obstacle Avoidance Sensor Module – Digital & Analog Output: another version this guide coversInfrared Obstacle Avoidance Sensor Module₹88
HS-S02P Infrared Obstacle Avoidance Module – Digital/Analog Output, PH2.0 3P Connector: another version this guide coversHS-S02P Infrared Obstacle Avoidance Module – Digital/Analog Output, PH2.0 3P Connector₹138
ACEBOTT Infrared Obstacle Avoidance Sensor Easy-Plug Compatible with ESP32/Arduino: another version this guide coversACEBOTT Infrared Obstacle Avoidance Sensor Easy-Plug Compatible with ESP32/Arduino₹237
Elecrow Crowtail- IR Reflective Sensor 2.0 Module – 4-15mm Detection, 5V Digital Output: another version this guide coversElecrow Crowtail- IR Reflective Sensor 2.0 Module – 4-15mm Detection, 5V Digital Output₹219
Seeed Studio Studio Grove IR Distance Interrupter v1.2 Sensor – 5V Digital Output: another version this guide coversSeeed Studio Grove IR Distance Interrupter v1.2 Sensor – 5V Digital Output₹589- Uno R3 development board: the controller used in the wiring tableFind this part
ESP32-WROOM-32 38-pin development board: for Wi-Fi logging and dashboardsESP32-WROOM-32 38-Pin Development Board₹389
Buzzer module 3.3-5 V: for an audible alarmBuzzer Module 3.3–5V₹27
HC-SR04 ultrasonic range finder: a cheap ultrasonic alternativeHC-SR04 Ultrasonic Range Finder Sensor Module for Arduino₹69
Alternatives and when to choose them
- E18-D80NK switch: longer range, works in daylight.
- TCRT5000 line sensor: line following.
- HC-SR04 ultrasonic: measures distance.
Common mistakes to avoid
- Expecting a distance value.
- Using it in bright sunlight.
- Leaving sensitivity at maximum.
- Powering it at 5 V into a 3.3 V board.
Frequently asked questions
Why does the IR sensor always show an obstacle?
The trimmer sensitivity is too high or the sensor sees the floor.
Does it measure distance?
No. It only gives yes or no within the set range.
Why does it fail outdoors?
Sunlight contains IR that swamps the sensor.
Can it detect black objects?
Only at closer distances because black absorbs IR.
Can it run on 3.3 V?
Yes. Power it from 3.3 V for ESP32 and Pico boards.
Parts for this guide
Keep learning
Sources
Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

