If you are building a home automation project or a universal controller, the 38kHz IR receiver module (commonly sold as the VS1838B or the higher-quality Vishay TSOP38238) is the standard component for capturing commands from a TV or AC remote. The direct answer to what this component outputs is a digital, active-LOW pulse train. It does not output an analog voltage proportional to light intensity. To use it, you wire the OUT pin to a digital GPIO, power it with 2.5V to 5.5V, and use hardware timers (like the ESP32's RMT peripheral or Arduino's interrupt-driven micros()) to measure the microsecond pulse widths and decode them into hexadecimal command bytes.

The Sensing Principle: Demodulating 38kHz Light

An IR remote control does not just shine a continuous beam of infrared light; it blinks an IR LED at a specific carrier frequency, almost always 38kHz. The receiver module contains a specialized photodiode paired with an Automatic Gain Control (AGC) amplifier and a bandpass filter tuned exactly to 38kHz. This internal circuitry ignores steady ambient IR (like heat from a radiator or sunlight) and only amplifies the rapidly pulsing signal from your remote.

Once the 38kHz carrier is detected, the module's internal demodulator strips away the high-frequency carrier wave and outputs the underlying data envelope as a clean digital logic signal. When the remote is transmitting a burst of 38kHz light, the receiver's OUT pin pulls LOW. When the light stops, an internal pull-up resistor pushes the OUT pin HIGH. This translates the optical data into a precise time-domain digital waveform that your microcontroller can measure.

Wiring Pinout and Power Supply Requirements

While the generic VS1838B modules (usually $0.15 to $0.30 each) and the name-brand Vishay TSOP38238 modules ($1.00 to $1.50) share the same basic footprint, their power tolerance and noise rejection differ. Always verify the silkscreen on your specific board, as some manufacturers swap the VCC and GND pins on the generic breakout boards.

Pin Label Function Supply Range Wiring Notes & Best Practices
VCC (or DAT) Power Supply 2.5V to 5.5V Use a clean 3.3V or 5V rail. Add a 10µF electrolytic and 0.1µF ceramic capacitor across VCC/GND near the module to suppress power rail noise.
GND Ground Reference 0V Must share a common ground with your microcontroller. Keep the ground wire short to prevent ground loops from corrupting the signal.
OUT (or SIG) Digital Output Active-LOW Logic Connect to any digital GPIO. No external pull-up resistor is needed; the module has an internal 30kΩ pull-up.
Callout: Digital vs. Analog Warning
Unlike a raw photodiode or photoresistor that outputs a variable analog voltage based on ambient light intensity, an IR receiver module outputs a strict digital logic signal (HIGH/LOW). Do not connect the OUT pin to an Analog-to-Digital Converter (ADC) pin expecting to measure light levels. You will only read digital rail voltages.

Output Signal Math: From Raw Microseconds to Hex Codes

The raw output of the sensor is not a physical unit like temperature or humidity; it is a sequence of time intervals measured in microseconds (µs). To get a usable "physical unit"—in this case, a hexadecimal command byte like 0x18 for "Volume Up"—you must apply protocol decoding math. The most common protocol is the NEC IR protocol.

The NEC protocol uses pulse-distance encoding with a base time unit of 562.5µs. The microcontroller measures the duration of the HIGH spaces between the LOW bursts. Here is the exact math used to convert raw time readings into binary data:

  1. Header Detection: The remote sends a 9ms LOW burst followed by a 4.5ms HIGH space. If your raw reading shows a space of ~4500µs, the decoder knows a valid NEC frame is starting.
  2. Logical 0 Math: A logical zero is represented by a 562.5µs LOW pulse followed by a 562.5µs HIGH space. Formula: If raw_space_duration / 562.5 ≈ 1, append bit 0.
  3. Logical 1 Math: A logical one is represented by a 562.5µs LOW pulse followed by a 1687.5µs HIGH space. Formula: If raw_space_duration / 562.5 ≈ 3, append bit 1.
  4. Byte Assembly: The decoder shifts these bits into an 8-bit register, reading the LSB (Least Significant Bit) first, to construct the final hex command byte.

On an Arduino Uno, libraries like Arduino IRremote use pin-change interrupts and the micros() function to capture these raw timings. On an ESP32, you should leverage the hardware RMT (Remote Control Transceiver) peripheral. The RMT captures the microsecond pulse widths in dedicated hardware memory without waking the main CPU, completely eliminating the timing jitter that plagues software-based interrupt decoding on slower 8-bit boards.

Interference Sources and Protocol Calibration

Because the sensor relies on an Automatic Gain Control (AGC) circuit to amplify weak 38kHz signals, it is highly susceptible to specific types of optical and electrical interference. Understanding these sources is critical for reliable bench and jobsite operation.

  • Direct Sunlight: Sunlight contains massive amounts of broadband infrared radiation. While the 38kHz bandpass filter blocks steady IR, intense direct sunlight can saturate the internal photodiode, blinding the AGC amplifier. The module will output a solid HIGH or chatter randomly. Fix: Add a physical optical shroud or use a dark red acrylic filter over the receiver dome.
  • CFL and Cheap LED Bulbs: Compact Fluorescent Lamps and low-quality LED bulbs use high-frequency switching power supplies that emit broadband optical noise, sometimes harmonizing near 38kHz. This causes the receiver to output continuous garbage data. Fix: Use high-quality LED drivers with proper EMI filtering in the same room, or move the receiver away from direct line-of-sight to the bulbs.
  • Power Rail Noise: If the ESP32 or Arduino is driving high-current loads (like relays or motors) on the same 5V rail, voltage sags will trigger the receiver's internal brownout detection, causing it to drop incoming packets. Fix: Isolate the IR module's VCC with an RC filter (e.g., 100Ω resistor + 47µF capacitor) as recommended in the Vishay TSOP38238 datasheet.

Calibration and Scaling: You do not need to perform analog calibration (like mapping a 0-1023 ADC reading to a voltage). The "calibration" for an IR sensor is purely software-based protocol thresholding. If your raw microsecond readings are drifting due to a cheap ceramic resonator on your remote, you must widen the software tolerance margins in your decoding library (e.g., accepting a logical 1 space anywhere between 1400µs and 1900µs instead of strictly 1687µs).

Frequently Asked Questions

Why is my IR sensor remote reading random hex codes?

If your serial monitor is printing random, constantly changing hex codes even when you aren't pressing a button on the remote, your receiver is being blinded by ambient optical noise. This is almost always caused by direct sunlight hitting the dome, or a nearby CFL/LED bulb emitting switching noise near 38kHz. The AGC is maxing out its gain to find a signal and is instead demodulating random noise. Shield the sensor from direct light and check your room's lighting. If the random codes only appear when a specific appliance turns on, you have power rail noise; add a decoupling capacitor directly across the sensor's VCC and GND pins.

Can I use a 3.3V ESP32 with a 5V IR sensor remote module?

Yes, but you must power the module correctly. The TSOP38238 and most VS1838B modules operate perfectly fine on a 3.3V power supply. Wire the VCC pin of the IR module directly to the ESP32's 3.3V output pin, and wire the OUT pin to a 3.3V-tolerant GPIO. Do not power the IR module with 5V and connect the OUT pin directly to an ESP32 GPIO; while the module's internal pull-up will pull the line to 5V when idle, pushing 5V into an ESP32 pin can degrade or destroy the silicon over time. If you must use a 5V supply for the sensor, use a simple voltage divider (e.g., 2kΩ and 3.3kΩ resistors) on the OUT line to step the logic HIGH down to a safe ~3.1V.

How far away can an IR sensor remote receiver actually detect a signal?

Under ideal indoor conditions with a standard remote powered by fresh AAA batteries, a quality receiver like the Vishay TSOP38238 can reliably detect signals up to 10 meters (33 feet) away at a direct line-of-sight angle. The generic VS1838B modules typically max out around 5 to 7 meters due to lower-quality internal AGC amplifiers and poorer optical filtering. Range drops drastically if you are off-axis; at a 45-degree angle, expect the maximum range to cut in half. To maximize range, ensure your remote's IR LED is clean, use fresh alkaline batteries (which provide better current spikes than NiMH rechargeables), and keep the receiver away from strong ambient light sources.