A time-of-flight sensor measures distance by timing light. A VCSEL emits a short infrared burst, usually at 940 nm; a single-photon avalanche diode array counts returning photons and builds a histogram of arrival times; the peak in that histogram, divided by the speed of light and halved for the round trip, is your distance. The whole assembly is a 4.4 mm by 2.4 mm part costing $2 to $9, reporting millimeters over a serial bus with no calibration on your side.

That convenience is why ToF has replaced mechanical switches, IR beam breaks, and ultrasonic rangers across soap dispensers, robot vacuums, drone landing gear, and presence detection. It is also why teams get surprised: the datasheet is honest about the physics, and its test conditions rarely match a real product.

What the Numbers on the Datasheet Mean

Maximum range is quoted against a specific reflectance in a specific ambient condition, almost always an 88 percent white target in darkness. The same part quoted at four meters that way will manage 1.2 meters against a 17 percent gray target under office lighting, and perhaps 60 cm against black fabric outdoors.

Three variables move the result:

  • Target reflectance at 940 nm, which is not visible color. Black plastics vary enormously in near-infrared: some carbon-pigmented resins absorb almost everything, some black dyes are quite reflective. Test your actual materials.
  • Ambient infrared. Sunlight puts roughly 1,000 W per square meter on a surface with a substantial IR component that swamps the return. A sunlit window or outdoor use cuts range by half or more.
  • Integration time. Longer windows collect more photons and extend range at the cost of update rate and current — 20 mA average at 15 ms per measurement, under a milliamp at one slow reading per second.

Accuracy is typically ±3 percent or ±5 mm, whichever is larger, and only where the signal is strong. Near the limit the error grows and the sensor reports a status flag rather than a distance. Firmware that ignores the status byte is the most common integration bug there is.

Field of View and What Falls Inside It

A ToF module has a cone-shaped field of view, commonly 15 to 27 degrees for single-zone parts. Everything inside the cone contributes photons, and the reported distance is dominated by whatever returns the most light, not necessarily the object you care about. At 1 meter a 25 degree cone is 44 cm across, so a floor, a table edge, or the product's own housing intruding into it gets reported.

Multi-zone parts split the field into an 8 by 8 grid of independently ranged zones, turning a distance sensor into a coarse depth camera. That enables gesture recognition, obstacle mapping, and people counting from a $6 part, and it sits between simple ranging and the full image sensor selection problem.

Cover Glass and Crosstalk: The Design Rule That Matters Most

Every ToF integration failure that is not a range expectation problem is a crosstalk problem. Emitter light reflects off the inside of your cover window straight back into the receiver, and the sensor reads that internal reflection as a very close, very strong target. Symptoms are a stuck short reading, a collapsed maximum range, or drift as the window gets dusty. The countermeasures are geometric and non-negotiable:

  1. Build an optical barrier between emitter and receiver that touches the cover, or as close as the tolerance stack allows — a molded rib, a black foam wall, or a die-cut spacer. Any gap is a light path.
  2. Keep the air gap under 0.5 mm between module top and cover. Larger gaps let stray light circulate.
  3. Size the aperture generously, typically 4 to 6 mm for a single-zone part, clearing both cones plus alignment tolerance. A clipped aperture vignettes the field and cuts range.
  4. Choose the right cover material: IR-transmissive, 1 mm or less, untextured inside. Polycarbonate and acrylic both transmit well at 940 nm but differ in scratch behavior and stress, as compared in acrylic versus polycarbonate.
  5. Run the crosstalk calibration in production with the real cover installed, against a known target, storing the coefficients in the device. Skip it and every unit ships with a different systematic error. It belongs in the production test fixture sequence.

When Not to Use ToF

ToF is the wrong tool in four ordinary situations, and knowing them early saves a redesign. Transparent and specular targets — glass, clear liquid, polished metal — either pass the light through or bounce it away from the receiver, so level sensing in a clear tank needs ultrasonic, capacitive, or a float. Bright outdoor sun beyond about a meter gives intermittent readings unless you buy a much more expensive module. Very short distances below 3 to 5 cm sit in the crosstalk-dominated region, where a reflective IR or capacitive sensor is cheaper and more robust. And wide-area coverage is not what a cone does: detecting a person anywhere in a doorway wants a PIR sensor or a multi-zone array.

The Alternatives, Briefly

Ultrasonic rangers cost $2 to $15, handle transparent and dark targets equally, ignore ambient light, and cover a wide 30 to 60 degree beam. They are slower, sensitive to temperature and air currents, blind under about 20 cm, and confused by soft absorbing surfaces. Millimeter-wave radar sees through plastic housings and works in fog and dust, but costs more and adds an FCC intentional-radiator certification burden that ToF does not carry.

Firmware Practices That Keep Readings Honest

Always check the range status byte and discard invalid readings rather than clamping them. Apply a median filter across three to five samples before any threshold decision, since ToF noise is impulsive rather than Gaussian, and add hysteresis to any threshold driving an actuator or the product chatters at the boundary. Log signal rate and ambient rate alongside distance; when a field unit misbehaves, those two numbers tell you whether the window is dirty or the environment changed. On battery products, gate the ranging rate to the application, following the pattern in low-power firmware and sleep modes.

Sensors that guide motion need one more layer: a policy for what happens when ranging fails. Mobile robots and aircraft handle this with sensor voting and safe defaults, the reasoning behind drone obstacle avoidance and robotics inside consumer products.

Integrating Optical Ranging Properly

Projects House treats ToF integration as an optical and mechanical problem rather than a component selection: barrier geometry, window material, production calibration, and firmware that handles the failure modes. Describe what you need to measure through the contact form.