What Is an Infrared Sensor and How Does It Work?
An infrared sensor is an electronic component that detects infrared radiation — the heat energy given off by everything around us, from a human body to a cup of coffee to a PCB on a test bench. It converts this invisible thermal signal into an electrical output that a microcontroller, PLC, or data logger can read and act on.
The term covers a wide range of devices. Some emit infrared light and measure reflections. Others sit passively and watch for heat signatures. Some resolve temperature to within 0.1 degrees C. Others simply flag whether something has crossed a line. That breadth is exactly why “infrared sensor” alone tells you almost nothing — the sensor type, wavelength, and configuration matter far more than the category name.
The Physics: Why Wavelength Is the First Thing to Know
Every object above absolute zero emits electromagnetic radiation. Stefan-Boltzmann’s law describes the total power output; Wien’s displacement law tells you the peak wavelength. For most objects at room temperature (293 K), the peak emission falls around 10 micrometers (um). Human bodies, running at 310 K, peak at roughly 9.4 um. This is the long-wave infrared band, also called thermal infrared.
Shorter wavelengths behave differently. Near-infrared (NIR), from about 0.75 to 1.4 um, behaves almost like visible light — it reflects off surfaces and can be imaged with standard silicon photodiodes. Mid-wave and long-wave IR (3–14 um) interacts with materials differently, requiring specialized detectors like thermopiles or microbolometers.
Choosing the wrong wavelength for your application is the most common spec mistake engineers make with IR sensors. A silicon photodiode tuned for 850 nm won’t detect a human body — it’s looking at reflected sunlight and IR LEDs, not thermal emission.
Two Categories: Active vs. Passive Infrared Sensors
This is the fork in the road that most articles gloss over.
Active infrared sensors emit IR radiation — usually from an LED or laser — and measure what comes back. The reflected signal changes depending on the target’s surface, distance, and reflectivity. Reflective object sensors, through-beam sensors, and proximity sensors all fall into this category. They need a clean line of sight and work best over short distances, typically 5 cm to 150 cm for common module-style sensors, though industrial through-beam pairs can reach 60 meters.
Passive infrared sensors (PIR) do exactly what the name says: they watch. They have no emitter. They detect the thermal energy naturally emitted by objects. The classic PIR sensor used in motion detectors has a split Fresnel lens that divides the field of view into zones. When a warm body — human, animal, running motor — crosses between zones, the differential between the two sensing elements produces a pulse. This is why PIR sensors are essentially motion detectors rather than temperature sensors; they respond to change, not steady-state heat.
How an IR Sensor Actually Works (Signal Path)
Understanding the signal chain matters when you’re debugging a malfunctioning sensor in the field.
1. Optical filtering. A window or lens passes only the target IR band. For PIR sensors, this is typically 8–14 um. For proximity sensors, it might be 850 nm or 940 nm. The filter blocks visible light and out-of-band IR that would create false signals.
2. IR-to-electrical conversion. In a photodiode, incoming photons generate electron-hole pairs via the photovoltaic effect. In a thermopile, absorption creates a temperature difference between a hot junction and a cold junction, which generates a voltage proportional to incident power. Microbolometers change resistance as they heat up.
3. Signal conditioning. The raw output is usually tiny — microvolts for a thermopile, nanoamps for a photodiode. Signal conditioning includes transimpedance amplification, low-pass filtering (to remove 50/60 Hz noise from ambient light), and often a logarithmic amplifier to compress the dynamic range.
4. Thresholding or digitization. A simple digital PIR module outputs a high/low signal once the conditioned voltage crosses a threshold. A more sophisticated module — like the MLX90614 IR thermometer — outputs a calibrated I2C value representing temperature in degrees Celsius, accurate to plus/minus 0.5 degrees C in typical conditions.
Key Specifications and What They Actually Mean
Detection range — For active sensors, this is the distance at which the reflected signal is strong enough to reliably exceed the threshold. It depends on target reflectivity, ambient light, and the LED power. The spec in the datasheet is usually measured against a 90% white test card; a matte black surface at the same distance may not trigger at all.
Field of view (FOV) — This determines the angular sensitivity. A wide FOV (e.g., 60 degrees) detects objects anywhere within a cone but has lower angular resolution. A narrow FOV (e.g., 5 degrees) is more directional and better for precision positioning. For PIR sensors, the FOV is largely set by the Fresnel lens geometry.
Spectral response — The wavelength band the detector is sensitive to, measured in nanometers or micrometers. Match this to your application’s emission peak.
Response time — How quickly the output changes after a stimulus. Thermopile sensors used for contactless temperature measurement typically settle in 50–500 ms. High-speed photodiodes used in optical encoders respond in nanoseconds.
Accuracy and resolution — For temperature-measuring IR sensors (thermopiles and microbolometers), accuracy ranges from plus/minus 1 degrees C to plus/minus 0.1 degrees C depending on calibration and the sensor’s operating range. Resolution is often 0.01 degrees C or better on the digital interface even if the absolute accuracy is plus/minus 0.5 degrees C.
Common Applications
Motion detection. The most ubiquitous use. PIR sensors behind a Fresnel lens sit in hallways, security lights, automatic doors, and occupancy counters. They trigger on the heat signature of a moving warm body.
Contactless temperature measurement. A thermopile or IR thermometer sensor (think Melexis MLX90614, Heimann HMS J11, or Omega OS36) measures surface temperature from a distance. Industrial uses include monitoring conveyor belt temperatures in steel mills, checking bearing temperatures on rotating equipment, and verifying solder joint profiles during reflow.
Object detection and proximity sensing. Active IR proximity sensors sit behind a bezel in automatic faucets, paper towel dispensers, and under-shelf displays. They detect the presence or absence of a hand or object in the sensing field.
Industrial flame detection. IR sensors tuned to specific CO2 absorption bands (around 4.3 um) detect the flame emission signature and are used in fire alarm systems and burner safety controls.
Optical encoding. High-speed IR LED-photodiode pairs straddle a slotted disc or reflective strip. As the disc rotates, the interruptions create a pulse train that a microcontroller counts to determine position or speed.
Spectroscopy and gas sensing. Some IR wavelengths are absorbed by specific gas molecules. NDIR (non-dispersive infrared) sensors use a narrow-band IR emitter and a matching detector to measure gas concentration — commonly CO2 in HVAC monitors and breathalyzers.
Infrared Sensor vs Ultrasonic Sensor
Engineers frequently weigh IR against ultrasonic sensors for object detection. The choice is rarely obvious.
| Factor | Infrared Sensor | Ultrasonic Sensor |
|---|---|---|
| Detection principle | IR radiation reflection or thermal emission | Sound wave time-of-flight |
| Target dependence | Affected by surface color, reflectivity, ambient light | Almost independent of color and surface texture |
| Transparency | Sees through glass; fails on clear objects | Detects clear glass but absorbs into foam/soft fabric |
| Range | Typically 5 cm–150 cm for modules; up to meters with lenses | Typically 2 cm–400 cm |
| Response speed | Fast (ms for proximity; us for photodiode) | Slower (limited by speed of sound, ~340 m/s) |
| Interference | Sunlight, strong IR sources, dust | Wind noise, temperature gradients, acoustic reflections |
| Best for | Line-following robots, proximity detection, color sensing | Liquid level sensing, tank gauging, obstacle detection in robotics |
The honest answer: if your target is a matte black surface in bright sunlight, neither is a great choice without careful shielding. If you’re measuring distance to a white wall indoors, either works. The decision comes down to geometry, environmental conditions, and whether you need a digital threshold output or a calibrated measurement.
How to Get Started with an IR Sensor and Arduino
For the majority of makers and engineers prototyping with IR, the SHARP GP2Y0A21YK0F or its newer equivalent is the default starting point. It outputs an analog voltage that corresponds to distance over a range of 10–80 cm.
Wiring is straightforward: 5V, GND, and the analog output connected to an ADC pin on your microcontroller. The datasheet includes a graph mapping output voltage to distance — you’ll want to run your own calibration for your target surface, since the datasheet curve assumes a 90% reflective Kodak gray card.
const int IR_SENSOR_PIN = A0;
void setup() {
Serial.begin(115200);
}
void loop() {
int rawValue = analogRead(IR_SENSOR_PIN);
// SHARP GP2Y0A21: distance(cm) ≈ 2076 / (rawValue - 11)
float distance = 2076.0 / (rawValue - 11.0);
if (rawValue > 11) {
Serial.print("Distance: ");
Serial.print(distance, 1);
Serial.println(" cm");
} else {
Serial.println("Out of range");
}
delay(100);
}
For digital PIR sensors (HC-SR501 style), the wiring is even simpler: 5V, GND, and a digital output pin. These modules usually have onboard threshold adjustment via a trimpot — set the sensitivity and the hold time before the output goes low again after the last motion detection.
Environmental Factors That Kill IR Sensor Performance
Ambient sunlight. Direct or reflected sunlight contains enormous IR energy, especially at the wavelengths used by active sensors. Outdoor applications need optical filtering, shielded enclosures, or a switch to ultrasonic or microwave radar.
Dust and condensation. The optical window accumulates dust over time. In industrial environments, oil mist or condensation on the window causes gradual signal attenuation that’s hard to diagnose without a reference target.
Temperature drift. Thermopile and thermistor-compensated sensors self-heat slightly during operation, which shifts the measurement baseline. High-accuracy applications require a stabilization period and, ideally, periodic recalibration against a known reference.
Target emissivity. IR sensors calibrated for human-body detection assume an emissivity of ~0.98 (very close to a blackbody). Shiny metal surfaces have emissivity as low as 0.05 — a polished aluminum panel at room temperature will read dramatically lower than its actual temperature. If you’re measuring non-bulk targets, apply emissivity correction or use contact temperature measurement as a cross-check.
Choosing the Right Infrared Sensor: A Quick Framework
Before selecting a sensor, answer these questions:
- What am I measuring? Temperature change (motion), absolute temperature, distance, or light reflection?
- What is the target’s temperature range? Objects near room temperature peak around 10 um (use a thermopile). Objects above 400 degrees C peak in the 1–2 um band (use a silicon photodiode or InGaAs detector).
- What is the target distance and geometry? Short-range proximity (< 1 m) is easier to implement with active IR. Long-range or high-accuracy temperature measurements need careful optical design.
- What environment? Indoor controlled, industrial, outdoor, vacuum? Ambient conditions determine required ingress protection and filtering.
- What interface do I need? Analog voltage, digital on/off, I2C, SPI, or UART? Digital interfaces simplify calibration but add complexity if you’re working with a bare microcontroller.
A single-chip IR temperature sensor like the MLX90614 (I2C, plus/minus 0.5 degrees C accuracy, 90 degree FOV) will solve the majority of use cases for under $10 in single quantities. When the spec calls for sub-0.1 degrees C accuracy or narrow FOV for remote measurement, the cost and complexity climb quickly into thermography-camera territory.
Conclusion
Infrared sensors are not a single technology — they are a family of techniques unified by their use of the infrared portion of the electromagnetic spectrum. The distinction between active and passive, between thermopile and photodiode, between 850 nm and 10 um, determines everything about how the sensor behaves in your system.
For makers and engineers evaluating IR for the first time, start with the MLX90614 or the SHARP GP2Y0A21 if you need a calibrated, digitally accessible temperature or distance reading. For motion detection, a basic PIR module like the HC-SR501 handles nearly every indoor occupancy application with no calibration required.
The physics sets the constraints. Match your wavelength, your geometry, and your target’s emissivity to the application — and the rest is straightforward implementation.
Frequently Asked Questions
How does an infrared sensor detect objects?
Active IR sensors emit infrared light and measure the reflection. When an object enters the field, it reflects IR back to the sensor. The sensor’s photodiode converts the reflected photon energy into a voltage change. Passive IR sensors (PIR) work differently — they detect the thermal energy naturally emitted by warm bodies. PIR sensors don’t detect static objects; they respond to change, which is why they are used for motion detection rather than temperature measurement.
What are the main types of infrared sensors?
The three most common types are: IR photodiodes and phototransistors (active, used for proximity and object detection), PIR sensors (passive, used for motion detection), and thermopile sensors (passive, used for contactless temperature measurement). Each type operates in a different IR wavelength band and serves a fundamentally different measurement purpose.
How accurate is an infrared temperature sensor?
Consumer-grade IR temperature sensors like the Melexis MLX90614 achieve plus/minus 0.5 degrees C accuracy across a -70 degrees C to 380 degrees C range with 0.01 degrees C resolution. Industrial-grade thermopile sensors can reach plus/minus 0.1 degrees C with careful calibration. The effective accuracy depends on target emissivity, distance-to-spot-size ratio (D:S), and ambient temperature compensation.
Can infrared sensors work through glass?
Active IR sensors at near-infrared wavelengths (850–940 nm) pass through glass. However, glass reflects some IR and transmits visible light, so reflections from the glass itself can cause false triggers. Long-wave thermal IR (8–14 um) is blocked by most standard glass. For through-glass detection, a narrow-beam IR LED-photodiode pair mounted on the same side and angled to catch reflection from the glass surface is a common workaround.
What is the difference between IR and ultrasonic sensors?
IR sensors detect reflections of infrared light or thermal emission; they are affected by surface color, reflectivity, and ambient light conditions. Ultrasonic sensors measure distance using sound waves and are nearly independent of surface color and texture. Ultrasonic sensors handle transparent and soft targets better; IR sensors have faster response times and work better for precise short-range proximity sensing.
Do infrared sensors work in sunlight?
Direct sunlight can saturate active IR sensors because it contains strong IR energy in the same bands they use. For outdoor applications, use optical filtering, shield the sensor from direct sun exposure, or consider microwave radar sensors instead. PIR sensors used for outdoor motion detection typically include IR filtering and daylight discrimination circuitry.