Robocraze
IR (Infrared) Obstacle Avoidance Sensor Module
IR (Infrared) Obstacle Avoidance Sensor Module
Couldn't load pickup availability
IR Proximity Sensor
The IR Proximity Sensor has a distance range of 2cm to 30cm and it is ideal for obstacle detection, line tracking, and more.
It is designed for easy setup and has onboard detection indication to verify its status. A preset knob allows you to fine-tune the distance range for more accurate readings.
This IR Sensor is best for IoT projects, such as creating automatic sanitizer dispensers and home automation systems.
This infrared sensor is suitable for various applications in industrial, automotive, and consumer electronics settings. This sensor offers unbeatable value for money while ensuring optimal accuracy and efficiency in all your projects.
The detection range of the infrared proximity sensor can be adjusted by the potentiometer.
Read our blog proximity sensor working principle.
Enjoy our free shipping on orders above Rs 500/- within India.
Features:
- Easy to assemble and use
- Onboard detection indication
- The effective distance range of 2cm to 30cm
- A preset knob to fine-tune distance range
- If there is an obstacle, the indicator lights on the circuit board.
Infrared Sensor Applications:
- IP cameras
- Alarm systems and other crime prevention devices
- Battery-driven human presence sensors for IoT smart homes
- IR sensors are also used in IR imaging devices, optical power meters, sorting devices, remote sensing, flame monitors, moisture analyzers, night vision devices, infrared astronomy, etc.
Infrared Sensor Diagram:

The IR proximity sensor circuit diagram consists of the following components:
- LM358 IC
- Resistors in the kilo-ohm range
- 2 pairs of IR transmitter and receiver
- LED
- Variable resistors
IR sensor pinout

IR Proximity Sensor Interfacing with Arduino - Wiring & Code Guide

Wiring Guide
- Connect the sensor’s VCC pin to the Arduino’s +5 V supply (or 3.3 V if your module supports it).
- Connect the sensor’s GND pin to the Arduino’s ground (GND).
- Connect the sensor’s OUT pin (digital output) to one of the Arduino digital input pins, e.g., D2.
- Ensure the sensor has a common ground with the Arduino to avoid erratic behaviour.
- Optionally: adjust the onboard potentiometer to set the detection distance (typically 2‑30 cm).
Arduino Code Example – Basic Detection
const int sensorPin = 2; // sensor output pin
void setup() {
Serial.begin(9600);
pinMode(sensorPin, INPUT);
Serial.println("IR Obstacle Sensor Test");
}
void loop() {
int val = digitalRead(sensorPin);
if (val == LOW) {
Serial.println("Obstacle detected!");
}
else {
Serial.println("Clear");
}
delay(500);
}
Arduino Code Example – LED Indicator
const int sensorPin = 2;
const int ledPin = 13; // onboard LED on many Arduino boards
void setup() {
pinMode(sensorPin, INPUT);
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
}
void loop() {
int state = digitalRead(sensorPin);
if (state == LOW) {
digitalWrite(ledPin, HIGH);
Serial.println("Obstacle!");
} else {
digitalWrite(ledPin, LOW);
Serial.println("All clear");
}
delay(300);
}
Tips & Notes
- The sensor output usually goes **LOW** when an obstacle is detected (and HIGH when clear) on typical modules.
- Dark or non‑reflective surfaces may not trigger the sensor as reliably — aim for reflective surfaces for best results.
- Adjust the onboard sensitivity potentiometer if detection is too close or too far.
- Keep wiring short and solid to avoid noise; use shielded or twisted wires if needed in noisy environments.
- If using the sensor in analogue mode (if applicable) you may read the analog output via A0 and use thresholds in code instead of simple HIGH/LOW.
IR vs Ultrasonic Sensors – Comparison
| Feature | IR Proximity Sensor | Ultrasonic Sensor |
|---|---|---|
| Detection Method | Emits infrared light and measures reflection from nearby objects. | Emits ultrasonic sound waves and measures time-of-flight to calculate distance. |
| Typical Range | 2–30 cm (depends on module and potentiometer setting) | 2 cm–4–5 m (depending on module like HC-SR04) |
| Accuracy | Good for short distances, less accurate with dark/transparent surfaces. | Moderate to high accuracy over longer distances, generally unaffected by color. |
| Surface Sensitivity | Reflectivity matters; black/dark or transparent surfaces may be poorly detected. | Works with almost any surface type; sound reflects reliably from most objects. |
| Response Speed | Fast response, good for obstacle avoidance in robots at short range. | Slower than IR; small delay due to sound travel, but good for medium distances. |
| Cost & Size | Low cost, very compact, easy to integrate. | Moderate cost, slightly larger, requires both transmitter and receiver elements. |
| Environment Limitations | Sunlight or strong ambient IR light can interfere; close proximity required. | Can be affected by soft materials (fabric, foam), or air turbulence; generally works well outdoors. |
| Best Use Case | Short-range obstacle detection, line following, touchless buttons. | Distance measurement, medium-range obstacle avoidance, level detection, robotics. |
IR Proximity Sensor – Troubleshooting Tips
- False Triggering: If the sensor triggers without any object present, check for reflective surfaces nearby. Highly reflective objects (mirrors, shiny metals) can cause false readings.
- Sunlight Interference: Direct sunlight or strong IR sources may cause the sensor to behave erratically. Try shielding the sensor or repositioning it away from direct sunlight.
- Wiring & Connections: Loose or long wires can introduce noise. Ensure solid, short connections between sensor and Arduino, and use proper grounding.
- Adjust Sensitivity: Many IR modules have a potentiometer to adjust detection distance. Turn it carefully to reduce false triggers.
- Surface Color & Material: Dark or transparent objects may not reflect IR well. Test with different materials if detection seems inconsistent.
- Environment Check: Avoid placing the sensor near other IR emitters (remote controls, heaters) that may interfere with readings.
- Power Supply Stability: Ensure a stable 5 V supply. Voltage fluctuations can cause inconsistent sensor behavior.
Share

Featured collection
-
Laser Module
Regular price Rs. 31.00Regular priceSale price Rs. 31.00 -
Mini Epoxy Solar Panel 70X70 mm
Regular price Rs. 50.00Regular priceRs. 199.00Sale price Rs. 50.00Sale -
Eye Blink Sensor
Regular price Rs. 130.00Regular priceSale price Rs. 130.00 -
Mini LCD Digital Thermometer with Probe
Regular price Rs. 74.00Regular priceRs. 199.00Sale price Rs. 74.00Sale