ANALOGbeginner

Reflective Optical Sensor

A Vishay TCRT5000 on a TinkerBlock board: an infrared emitter that is always on and a phototransistor beside it, both looking out of the front. Infrared coming back pulls SIGNAL down from VCC through 4.7 kΩ, so white paper reads low and black tape or open air reads high. Analog only, best at 2.5 mm, and VCC goes to your board's logic voltage: 3V3, or 5V on an Uno.

Comes in this kit — not sold separately

Specifications

TypeReflective optical sensor: an infrared emitter and a phototransistor side by side, looking out of the front of the board. Analog output only
SensorVishay TCRT5000, 10.2 × 5.8 × 7 mm, emitter about 950 nm, with a filter that blocks visible light
RangeBest at 2.5 mm; above a fifth of that peak from 0.2 to 15 mm, against a reflecting card (Vishay). It measures light coming back, not distance
SIGNALThe phototransistor's collector, 4.7 kΩ up to VCC and 100 nF to GND. More light back reads lower: down to around a volt over white paper close up, VCC over black tape or open air
SupplyYour board's logic voltage: 3V3 on an ESP32, ESP32-S3 or Pico, 5V (or 3V3) on an Uno. A dark surface puts VCC on SIGNAL
CurrentAbout 18 mA at 3.3 V and 32 mA at 5 V, all the time: the emitter is lit through 120 Ω whenever the block has power, and nothing switches it off
At 5 VAbout 31 mA, half the TCRT5000's 60 mA maximum, and about 117 mW in a 120 Ω rated 125 mW: inside it, and warm. Worked out, not measured
SpeedSIGNAL climbs back through 4.7 kΩ into 100 nF: a 0.47 ms time constant, most of the way in about a millisecond
Pins to wire3 of the 4: GND, VCC and SIGNAL. NC is connected to nothing on the board
Header4-pin right-angle male, 2.54 mm pitch: GND, VCC, NC, SIGNAL, with GND on the square pad
Board22.4 × 30.4 mm, two 4.8 mm mounting holes 16 mm apart. The front prints ANALOG, the back USED FOR PROXIMITY DETECTION
In the box1 × TK57 block. It also ships inside the TinkerBlock kits

What it does

It tells your board how much infrared comes back from whatever is in front of it. The black housing near the top is a Vishay TCRT5000: an infrared LED under the blue dome and a phototransistor under the black one, side by side, looking out of the front of the board. Something pale and close sends the emitter's light back into the receiver; something dark, or nothing at all, does not.

Drag to turn it
The TK57. The blue dome sends infrared, the black one receives it. Turn it over for the back.

The receiver hangs from a 4.7 kΩ pull-up, so SIGNAL is a voltage that falls as more light comes back: down to around a volt over white paper a few millimetres away, VCC over black tape or open air. The front prints ANALOG, and it means it. There is no comparator, no threshold potentiometer and no indicator LED on this board. Read SIGNAL with analogRead, and the threshold is a number in your sketch.

It measures light coming back, not distance. The TCRT5000 sees best at 2.5 mm and falls to a fifth of that by 15 mm, so grey card near and white paper farther away can read the same. It suits jobs where the height is fixed: following a line, finding a table's edge, counting marks on a belt or slots in a wheel.

The page this replaces said the output was digital "on some variants", that SIGNAL went to a digital pin, and that it took 3.3 V and 5 V alike. It is analog only, and 5 V on VCC is 5 V on SIGNAL, which only a 5 V board's pins can take.

Two things to know before wiring

  • VCC is your board's logic voltage. Over a dark surface SIGNAL rises to VCC, and a 3.3 V pin must not see 5 V. So VCC goes to 3V3 on an ESP32, an ESP32-S3 or a Pico, and to 5V on an Uno, where the block's 120 Ω resistor runs warm but inside its rating.
  • The emitter is always on. The block takes about 18 mA from 3.3 V, about 32 mA from 5 V, whenever it has power. On a battery, switch its VCC.

Wiring, in four lines

  1. GND to your board's GND.
  2. VCC to 3V3 on an ESP32, ESP32-S3 or Pico; to 5V on an Uno.
  3. SIGNAL to an analog pin: GPIO 4 on an ESP32-S3, GPIO 34 on an ESP32, A0 on an Uno, GP26 on a Pico.
  4. NC to nothing: it is connected to nothing on the board.

Then analogRead(pin) is low over white paper and high over black tape.

Where to start

The handbook below is nine short articles, each with a working figure. The first reading is the whole build in three wires and a few lines, and a counter that learns calibrates itself and counts each mark once.

For how it works, read light out, light back and near is not a number. For which VCC your board takes, VCC is your logic voltage. If the numbers are wrong, when the reading is wrong.

When it doesn’t work

It reads the same over the line and off it.
The line is not dark in infrared. Some black inks and plastics reflect 950 nm almost as well as paper. Test the real surface with the first reading sketch, and use matte black electrical tape for a line.
Does it give a digital output?
No. This board has no comparator and no potentiometer, only the sensor, a pull-up and a filter capacitor, so SIGNAL is a voltage. Read it with analogRead and choose the threshold in your sketch.
Should VCC go to 3V3 or 5V?
To the voltage your board's pins run at: 3V3 on an ESP32, an ESP32-S3 or a Pico, 5V on an Uno. Over a dark surface SIGNAL rises to VCC, and a 3.3 V pin must not see 5 V. The Uno's pins take 5 V, and it reads the block from its 3.3V pin too, over two thirds of its range.
It works indoors, not near a window.
Sunlight carries infrared, and the receiver cannot tell it from the emitter's own. The emitter is always on, so the board cannot subtract the room's light. Mount the sensor close to the surface and shade it.
Can I measure distance with it?
Not reliably. The reading depends on the surface as much as the distance, and it rises again closer than 2.5 mm. Use the TK50 ultrasonic sensor for distance.
Which way does it look?
Out of the front, the side with the parts and the pin names. For a line follower, the block hangs face down with its two domes 2 to 5 mm over the floor.

The optical sensor handbook

9 articles · about 40 minutes

This page is the reference: what the part is, what it is made of, and the questions people arrive already asking. The handbook is the walk — the same part in the order somebody actually meets it.

The board

2 articles

Four pins of which three are wired, a TCRT5000 looking out of the front, and a SIGNAL that is a voltage, not a yes or no.

How it works

3 articles

Infrared out, infrared back, and a pull-up that turns it into a voltage that falls. Then what the emitter costs, and which VCC your board takes.

Reading it

2 articles

Three wires, analogRead, and why the number is not a distance.

Using it

2 articles

A counter that learns its own threshold and counts each mark once, and what to check when the numbers are wrong.

Edit this page — content/modules/reflective-optical-sensor.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

Ask a question ↗

Reflective Optical Sensor

Loading discussions…

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum →