Documentation

ShillehTek IR Infrared Obstacle Avoidance Sensor Module for Arduino Robot | ShillehTek Product Manual
Documentation / ShillehTek IR Infrared Obstacle Avoidance Sensor Module for Arduino Robot | ShillehTek Product Manual

ShillehTek IR Infrared Obstacle Avoidance Sensor Module for Arduino Robot | ShillehTek Product Manual

manualObstacle DetectionRoboticsshillehtek

Overview

The IR Infrared Obstacle Avoidance Sensor is the cheapest, simplest way to give a robot or machine a "is there something in front of me?" reflex. It pairs an IR LED that constantly emits modulated light with a matched IR receiver and a comparator IC. When an object comes close enough to reflect IR back into the receiver, the digital output (OUT) flips from HIGH to LOW.

The detection distance is adjustable from about 2 cm to 30 cm via the on-board trim pot — perfect for small robots that need to back up before hitting a wall, conveyor systems that detect a part arrival, an "object placed on stand" trigger, or contactless button replacements.

Output is purely digital — there's no analog reading of distance, just a yes/no. That makes it dead simple to wire (one GPIO is enough) and works on Arduino, ESP32, Raspberry Pi, or Pico without any libraries.

At a Glance

Sensor Type
Active IR (emitter + receiver)
Operating Voltage
3.3V - 5V
Detection Range
2 - 30 cm (adjustable)
Output
Digital (active LOW)
Pin Count
3 pins
Pins
VCC, GND, OUT

Specifications

Parameter Value
Sensor Type Active IR reflective (LED emitter + IR receiver)
Operating Voltage 3.3V - 5V DC
Operating Current ~20 mA
IR Wavelength ~940 nm
Detection Range 2 cm - 30 cm (adjustable via trim pot)
Detection Angle ~35 degrees
Output Type Digital (active LOW when obstacle detected)
Output LED On-board indicator (lights when triggered)
Comparator LM393 with on-board trim pot
Operating Temperature -25 degC to +85 degC
Mounting Holes 2 x M3
Dimensions ~46 x 16 mm

Pinout Diagram

IR infrared obstacle avoidance sensor module pinout diagram showing VCC (3.3V/5V), GND (0V), and Digital Output Pin, plus the IR receiver, IR emitter, and trim pot for distance threshold adjustment

Wiring Guide

Arduino Wiring

Three wires, one digital pin. Read the OUT pin with digitalRead() — it goes LOW when an obstacle is detected within the threshold distance you set with the trim pot.

Sensor Pin Arduino Pin
VCC 5V
GND GND
OUT Digital Pin 2
Tip: Use multiple modules around your robot (front-left, front-right, rear) and wire each OUT to its own GPIO. With three sensors you have enough information to steer around obstacles, not just stop in front of them.

ESP32 Wiring

Power from 3.3V or VIN (5V). Output is 3.3V-friendly when the sensor is powered at 3.3V.

Sensor Pin ESP32 Pin
VCC 3V3
GND GND
OUT GPIO 5

Raspberry Pi Wiring

Power from the Pi's 3.3V rail to keep the OUT signal safe for the 3.3V-only Pi GPIO.

Sensor Pin Raspberry Pi Pin
VCC Pin 1 (3.3V)
GND Pin 6 (GND)
OUT Pin 11 (GPIO 17)
Warning: If you power the sensor from 5V, its OUT line can swing to 5V too — which will damage the 3.3V-only Pi GPIO. Either use 3.3V or place a level shifter / voltage divider on the OUT line.

Raspberry Pi Pico Wiring

Power at 3.3V keeps the digital output safe for the Pico's 3.3V GPIO.

Sensor Pin Pico Pin
VCC 3V3 (OUT)
GND GND
OUT GP15

Code Examples

Arduino - Read Obstacle State

ir_obstacle_arduino.ino
// IR Obstacle Sensor - print obstacle status on Arduino
// Wire VCC=5V, GND=GND, OUT=D2

const int sensorPin = 2;

void setup() {
  Serial.begin(9600);
  pinMode(sensorPin, INPUT);
}

void loop() {
  int state = digitalRead(sensorPin);
  if (state == LOW) {
    Serial.println("Obstacle detected!");
  } else {
    Serial.println("Path clear");
  }
  delay(100);
}

Arduino - Robot Stops Before Hitting Wall

ir_obstacle_robot.ino
// Front-mounted IR obstacle sensor stops the robot when something is close
// OUT to D2; motor enable pins go to your motor driver

const int sensorPin = 2;
const int motorL = 9;
const int motorR = 10;
const int speed = 180;

void setup() {
  pinMode(sensorPin, INPUT);
  pinMode(motorL, OUTPUT);
  pinMode(motorR, OUTPUT);
}

void loop() {
  if (digitalRead(sensorPin) == LOW) {
    analogWrite(motorL, 0);
    analogWrite(motorR, 0);
    delay(500);                  // pause
  } else {
    analogWrite(motorL, speed);
    analogWrite(motorR, speed);
  }
}

Raspberry Pi (Python)

ir_obstacle_rpi.py
#!/usr/bin/env python3
# IR Obstacle Sensor on Raspberry Pi - print state and trigger an action

import RPi.GPIO as GPIO
import time

PIN = 17
GPIO.setmode(GPIO.BCM)
GPIO.setup(PIN, GPIO.IN)

try:
    while True:
        if GPIO.input(PIN) == 0:
            print("Obstacle detected!")
        else:
            print("Path clear")
        time.sleep(0.1)
except KeyboardInterrupt:
    GPIO.cleanup()

Raspberry Pi Pico - MicroPython

ir_obstacle_pico.py
# IR Obstacle Sensor on Raspberry Pi Pico (MicroPython)

from machine import Pin
import time

sensor = Pin(15, Pin.IN)

while True:
    if sensor.value() == 0:
        print("Obstacle detected!")
    else:
        print("Path clear")
    time.sleep(0.1)

Frequently Asked Questions

How do I adjust the detection distance?
Turn the on-board trim pot. Clockwise generally increases the trigger distance (more sensitive); counter-clockwise decreases it. Place an object at your desired trigger distance and adjust until the indicator LED turns ON, then back off slightly for a stable threshold.
Why is the output LOW when there's no obstacle?
The trim pot is set too sensitive — the sensor is detecting reflections from far-away surfaces or the floor. Turn the pot to make it less sensitive until the LED stays off in clear conditions, then verify it triggers when you wave a hand near it.
Does it work in bright sunlight?
It can struggle. Sunlight has a lot of IR that overwhelms the receiver. For outdoor use, mount the sensor with a small hood/shield to block direct ambient IR, or switch to an ultrasonic sensor like the HC-SR04 which is unaffected by light.
Can it detect transparent objects like glass?
Often poorly. Glass reflects very little IR — most of it passes through. Dark/matte surfaces also absorb a lot of IR and may not trigger reliably. For glass and dark obstacles, use ultrasonic or LiDAR distance sensors instead.
What's the difference between this and the TCRT5000?
The TCRT5000 is short-range (1-15 mm) and ideal for line following or close surface detection. This obstacle sensor uses larger 5mm IR LEDs with a stronger emitter and longer range (2-30 cm), making it suitable for actual obstacle avoidance on robots — you'd never use a TCRT5000 to stop a robot from hitting a wall.
Can I use multiple sensors at once?
Yes — and you usually want to. Mount a front-left and front-right sensor on the robot's chassis to detect obstacles on either side. Each sensor needs its own GPIO. Note that two sensors aimed at the same object can interfere if their IR beams overlap; angle them slightly outward to minimize crosstalk.
Does it give me distance to the obstacle?
No — only a "yes/no" digital signal. If you need actual distance values, use an ultrasonic sensor (HC-SR04) or a Time-of-Flight sensor like the VL53L0X.