Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

How to Use IR Sensor : Examples, Pinouts, and Specs

Image of IR Sensor Design with IR Sensor in Cirkit Designer

Introduction

The IR Sensor (Manufacturer: JLC PCB, Part ID: UNO) is a versatile electronic component designed to detect infrared (IR) radiation. It is widely used in applications such as proximity sensing, motion detection, and remote control systems. The sensor operates by emitting and/or detecting IR light, making it suitable for both reflective and transmissive sensing tasks.

Common applications include:

Explore Projects Built with IR Sensor

Use Cirkit Designer to design, explore, and prototype these projects online. Some projects support real-time simulation. Click "Open Project" to start designing instantly!
Image of Arduino UNO IR Sensor Motion Detector: A project utilizing IR Sensor  in a practical application
Arduino UNO IR Sensor Motion Detector

This circuit consists of an IR sensor connected to an Arduino UNO. The IR sensor's output is connected to digital pin D2 of the Arduino, while its power and ground pins are connected to the 5V and GND pins of the Arduino, respectively. The Arduino is programmed to read the sensor data and can be used for applications such as object detection or proximity sensing.

Open Project in Cirkit Designer
Image of ESP32-Based Car Detection System with IR Sensors: A project utilizing IR Sensor  in a practical application
ESP32-Based Car Detection System with IR Sensors

This circuit uses an ESP32 microcontroller to monitor the presence of a car using four IR sensors. The sensors are connected to GPIO pins 35, 34, 25, and 26 of the ESP32, which reads their values and prints the sensor states to the Serial Monitor. The system is designed to detect and report the status of each sensor in real-time.

Open Project in Cirkit Designer

Technical Specifications

The following table outlines the key technical details of the IR Sensor:

Parameter Specification
Operating Voltage 3.3V - 5V
Operating Current 20mA (typical)
Detection Range 2cm - 30cm (adjustable)
Output Type Digital (High/Low)
Wavelength Sensitivity 760nm - 1100nm (Infrared range)
Response Time < 2ms
Operating Temperature -25°C to 85°C

Pin Configuration and Descriptions

The IR Sensor typically has three pins. The table below describes each pin:

Pin Number Pin Name Description
1 VCC Power supply pin (3.3V - 5V)
2 GND Ground pin
3 OUT Digital output pin (High when no object detected, Low when object detected)

Usage Instructions

How to Use the IR Sensor in a Circuit

  1. Power the Sensor: Connect the VCC pin to a 3.3V or 5V power source and the GND pin to the ground of your circuit.
  2. Connect the Output: Attach the OUT pin to a digital input pin of your microcontroller or to an external circuit for further processing.
  3. Adjust the Sensitivity: Use the onboard potentiometer (if available) to adjust the detection range of the sensor.
  4. Test the Sensor: Place an object within the detection range and observe the output signal on the OUT pin.

Important Considerations and Best Practices

Example: Connecting the IR Sensor to an Arduino UNO

Below is an example of how to connect and use the IR Sensor with an Arduino UNO:

Circuit Diagram

Arduino Code

// IR Sensor Example Code for Arduino UNO
// This code reads the output of the IR sensor and prints the status to the Serial Monitor.

const int irSensorPin = 2; // IR sensor output connected to digital pin 2
int sensorValue = 0;       // Variable to store the sensor reading

void setup() {
  pinMode(irSensorPin, INPUT); // Set the IR sensor pin as input
  Serial.begin(9600);          // Initialize serial communication at 9600 baud
}

void loop() {
  sensorValue = digitalRead(irSensorPin); // Read the sensor output
  if (sensorValue == LOW) {
    // Object detected
    Serial.println("Object detected!");
  } else {
    // No object detected
    Serial.println("No object detected.");
  }
  delay(500); // Wait for 500ms before the next reading
}

Troubleshooting and FAQs

Common Issues and Solutions

  1. Sensor Not Detecting Objects

    • Cause: Incorrect wiring or insufficient power supply.
    • Solution: Double-check the connections and ensure the power supply is stable and within the specified range.
  2. False Positives or Erratic Behavior

    • Cause: Ambient IR interference or unstable power supply.
    • Solution: Shield the sensor from strong IR sources and use a decoupling capacitor (e.g., 0.1µF) across the power pins.
  3. Short Detection Range

    • Cause: Sensitivity not properly adjusted.
    • Solution: Use the onboard potentiometer to increase the detection range.
  4. Output Always High or Low

    • Cause: Faulty sensor or incorrect pin connections.
    • Solution: Test the sensor with a multimeter or replace it if necessary. Verify the pin connections.

FAQs

Q1: Can the IR Sensor detect transparent objects?
A1: No, the IR Sensor may not reliably detect transparent objects as they do not reflect sufficient IR light.

Q2: Can I use the IR Sensor with a 3.3V microcontroller?
A2: Yes, the sensor operates within a voltage range of 3.3V to 5V, making it compatible with 3.3V systems.

Q3: How do I increase the detection range?
A3: Adjust the onboard potentiometer to increase the sensitivity and detection range.

Q4: Can the IR Sensor detect heat?
A4: No, this sensor is designed to detect reflected IR light, not heat. For heat detection, use a thermal IR sensor.

By following this documentation, you can effectively integrate and troubleshoot the IR Sensor in your projects.