DIGITALbeginner

Infrared Speed Sensor

A GK105A slotted optical switch on a TinkerBlock board: an infrared beam across a 5 mm slot, judged by an LM393 comparator. Something in the slot reads HIGH; a clear slot reads LOW and lights a red LED. Put a slotted disc through it and count pulses for rpm, up to about 1,900 a second. VCC must be your board's logic voltage.

Comes in this kit — not sold separately

Specifications

TypeSlotted optical switch with a comparator and an indicator LED. Something in the slot reads HIGH
SensorGK105A: an infrared LED and a phototransistor facing each other across the slot, in one 12.9 × 6.3 × 11 mm housing
Slot5 mm wide and 8 mm deep. The beam passes through windows drawn about 0.7 mm wide, below the top of the towers
ComparatorLM393 judging the light sensor against half of VCC, set by two 10 kΩ. No knob, and no hysteresis
SIGNALThe comparator's open-collector output with a 10 kΩ pull-up to VCC. Clear: about 0.15 V, LOW. Blocked: VCC, HIGH. Read it with INPUT
SpeedAbout 1,900 pulses a second at most, from the sensor's typical 100 µs and 130 µs edges on its 10 kΩ: some 5,800 rpm on a 20-slot disc
SupplyYour board's logic voltage on VCC: 3V3 on an ESP32, ESP32-S3 or Pico, 5V on an Uno. SIGNAL is pulled up to it
CurrentAbout 3 to 5 mA at 3.3 V and 5 to 8 mA at 5 V, worked out: the infrared LED is always on
IndicatorRed LED and 1 kΩ from VCC onto SIGNAL: lit while the slot is clear, dark while it is blocked. Not a power light
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 back prints TK61 INFRARED SPEED SENSOR and MEASURES SPEED VIA PULSES
In the box1 × TK61 block. It also ships inside the TinkerBlock kits

What it does

It tells your board whether something is in its slot, fast enough to count the bars of a spinning disc. The two black towers are a GK105A: an infrared LED in the right-hand one, a light sensor in the left, and a 5 mm slot between them that the beam crosses. Anything opaque in the slot breaks the beam.

Drag to turn it
The TK61. The slot sensor is the pair of towers at the top. Turn it over for the back.

The light sensor does not drive SIGNAL itself. An LM393 comparator compares its voltage with half of VCC and answers: slot clear, SIGNAL LOW and the red LED lit; something in the slot, SIGNAL HIGH through a 10 kΩ pull-up and the LED dark. So HIGH means blocked. With a slotted disc on a shaft, every bar is one pulse, and pulses a second times 60 over the openings is rpm.

The page this replaces had the polarity right, but offered either supply as though it suited any board, and gave no speed limit. The block counts up to about 1,900 pulses a second, set by the light sensor, not the sketch.

Two things to know before wiring

  • VCC is your board's logic voltage. SIGNAL is pulled up to VCC: 3V3 on an ESP32, an ESP32-S3 or a Pico, 5V on an Uno.
  • Count on an interrupt. A loop that looks every few milliseconds misses most of the pulses from a spinning disc. attachInterrupt on a rising edge catches every one.

Wiring, in four lines

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

Then pinMode(pin, INPUT), and digitalRead(pin) is HIGH while something blocks the slot.

Where to start

The handbook below is ten short articles, each with a working figure. The first read is the whole build in three wires and a few lines, and a tachometer counts a spinning disc in rpm.

For how it works, read a beam across a slot and the comparator and the light. If the count is off, when the count is wrong.

When it doesn’t work

Does HIGH mean blocked or clear?
Blocked. With the slot clear the comparator pulls SIGNAL LOW and the red LED lights; with something in the slot SIGNAL goes HIGH through the 10 kΩ pull-up and the LED goes dark.
Should VCC go to 3V3 or 5V?
To your board's logic voltage: 3V3 on an ESP32, ESP32-S3 or Pico, 5V on an Uno. SIGNAL is pulled up to VCC, so 5 V on VCC is 5 V on a 3.3 V pin every time something passes the slot.
How do I get rpm from it?
Put a disc with N openings on the shaft, its rim through the slot, and count rising edges on an interrupt for one second. rpm is the count times 60 over N. The handbook's tachometer does exactly that.
How fast can it count?
About 1,900 pulses a second, set by the light sensor's edges on its 10 kΩ; that is some 5,800 rpm on a 20-slot disc. Past it, the block starts to miss bars. Fewer openings bring the rate down.
It counts two for one when I push a card in slowly.
The comparator has no hysteresis, so a slow edge can flip SIGNAL more than once. Ignore a second edge within about half a millisecond, as the handbook's tachometer does, or longer for slow hand-driven counting.
Does sunlight affect it?
It can. The housing shields the sensor from most light, but the slot is open at the top and the ends, and sunlight carries a lot of infrared. Shade it if it misreads near a window.

The speed sensor handbook

10 articles · about 50 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 slot with a beam across it, a comparator that turns the beam into HIGH and LOW, and a light that shows the beam clear.

How it works

3 articles

An infrared LED, a phototransistor that passes current while it sees it, a comparator that decides at half of VCC, and why VCC has to be your board's logic voltage.

Reading it

2 articles

Three wires and digitalRead, then the arithmetic that turns pulses into revolutions a minute.

Using it

3 articles

A tachometer on an interrupt, how fast the block can honestly count, and what to check when the count is wrong.

Edit this page — content/modules/ir-speed-sensor.mdx

Community

Questions about this product

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

Ask a question ↗

Infrared Speed 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 →