TCRT5000L Sensor Setup and Calibration Guide
By Official Hobby Components Online Store | Buy Electronic Kits, Components, Boards, Shields, Modules | Published: 2026-10-29
Category: How-to Guides
Learn how to wire, mount, and calibrate the TCRT5000L reflective optical sensor for line detection and distance sensing with reliable, repeatable results.
Quick Answer
To get reliable readings from the TCRT5000L, wire the IR LED and phototransistor correctly, mount the sensor at the right height, and calibrate the threshold for your surface.
Why Calibration Matters More Than Wiring
The TCRT5000L is a reflective sensor that works by emitting infrared light and measuring how much of it bounces back to the phototransistor. Because ambient light, surface color, and mounting height all affect the output, a fixed threshold rarely works across different setups.
Calibration is the difference between a line follower that stays on track and one that wanders. Taking a few minutes to measure your 'line' and 'floor' values will save you hours of debugging later.
Choosing the Right Output Mode
The sensor's phototransistor can be used in two common configurations: analog (voltage divider) or digital (with a comparator like the LM393). For analog readings, connect the collector to VCC and the emitter to a resistor to ground. For digital output, you'll need an external comparator module.
Analog mode gives you finer control for calibration, while digital mode simplifies your code. If you're building a line follower with multiple sensors, digital modules reduce pin usage.
Step-by-Step Setup and Calibration
- Wire the sensor correctly: Connect the IR LED anode (pin 1) through a 100-220 ohm resistor to VCC (5V or 3.3V) and cathode to GND. Connect the phototransistor collector (pin 4) to VCC and emitter (pin 3) to a 10k ohm resistor to GND. Take the analog reading from the emitter-resistor junction. Double-check pinout: pin 1 is LED anode, pin 2 LED cathode, pin 3 emitter, pin 4 collector. Reversing LED polarity will prevent operation.
- Mount at the right height: Position the sensor 5-10 mm above the surface for line detection. Too high reduces reflected IR, too low can cause false readings from surface texture. Secure with the included mounting clips. Test different heights and choose the one that gives the largest difference between line and floor readings.
- Read raw analog values: Use an ADC pin (e.g., A0 on Arduino) to read the voltage. With a 10k pull-down resistor, you'll get values near 0 on a white surface and higher on a black line (or vice versa depending on your resistor configuration). Record the minimum and maximum values you see in your actual lighting conditions.
- Set a threshold: Calculate the midpoint between the line and floor readings: threshold = (line_value + floor_value) / 2. Use this in your code to decide if the sensor is on the line. Re-calibrate whenever you change surface, lighting, or sensor height.
- Test and adjust: Run a simple test sketch that prints the raw value and the detected state (line/floor). Move the sensor across the boundary to verify the threshold works consistently. If readings fluctuate, add a small hysteresis band (e.g., threshold ±10) to prevent rapid switching.
Product Spotlight
- TCRT5000L Reflective Optical Sensor: The TCRT5000L includes an infrared emitter and phototransistor in a leaded package that blocks visible light and is sensitive to IR. This built-in shielding reduces interference from ambient light, making it easier to get consistent readings in typical indoor environments.

TCRT5000L Reflective Optical Sensor
