ThisCalculator

Everyday

ToF Sensor Meaning: How Time-of-Flight Works

Updated · Standard formula, shown below

Distance to object 1.499 m
Distance in centimeters
149.9 cm
Result
Round-trip time
10 ns
You entered
Speed of light
299792458 m/s
You entered

A Time-of-Flight (ToF) sensor is an optical component that measures distance by calculating how long light takes to travel from the sensor to an object and back. You enter the speed of light and the measured round-trip time, and the sensor (or its software) computes the distance. This article explains the underlying principle, the different types of ToF sensors, their real-world uses, and how to interpret their output.

Formula

The fundamental ToF equation is:

Distance = (c × t) / 2

Where:

  • c = speed of light in the medium (about 299,792,458 m/s in air, slightly slower in other materials)
  • t = round-trip time of the light pulse (in seconds; the calculator above uses nanoseconds)
  • 2 = because the light travels to the target and back, so the round-trip distance is twice the one-way distance

The result is the distance from the sensor to the object. In air, the speed of light is very close to the vacuum value, so most practical ToF systems use the vacuum constant.

Worked Example

Using the default values from the calculator: t = 10 ns (nanoseconds) and c = 299,792,458 m/s.

  1. Convert nanoseconds to seconds: 10 ns = 10 × 10⁻⁹ s = 1 × 10⁻⁸ s
  2. Compute the round-trip distance: c × t = 299,792,458 × 1 × 10⁻⁸ = 2.99792458 m
  3. Divide by 2 to get one-way distance: 2.99792458 / 2 = 1.49896229 m
  4. Round to 3 decimal places: 1.499 m

The calculator shows the same result: 1.499 m (or 149.9 cm). This matches the physical reality: light travels about 30 cm in 1 ns, so 10 ns round-trip corresponds to about 1.5 m one-way.

How a ToF Sensor Works

A ToF sensor typically consists of a light source (usually a laser or an LED emitting infrared light), a photodetector, and a timing circuit. The sensor emits a short pulse of light, which reflects off the target and returns to the detector. By measuring the time delay between emission and reception, the distance is calculated.

There are two main techniques:

  • Direct ToF (dToF): Measures the actual time of flight of individual photons. This is used in applications like LiDAR for autonomous vehicles and some smartphone proximity sensors.
  • Indirect ToF (iToF): Measures the phase shift of a continuous modulated light wave. The phase difference between emitted and received signals is proportional to distance. This method is common in depth cameras for face recognition and gesture control.

Both methods rely on the same fundamental formula, but iToF uses phase measurement rather than direct timing.

Common Applications

ToF sensors are found in many everyday devices:

  • Smartphone cameras: Used for autofocus, portrait mode background blur, and augmented reality (AR) depth mapping.
  • Proximity sensors: In phones, they detect when the device is held to the ear to turn off the screen.
  • Robotics and drones: For obstacle avoidance and terrain mapping.
  • Automotive LiDAR: For adaptive cruise control and emergency braking.
  • Industrial automation: For measuring fill levels, part dimensions, and conveyor belt sorting.

The key advantage of ToF over other distance sensors (like ultrasonic) is speed and precision: light travels much faster than sound, and the measurement is nearly instantaneous.

Choosing a ToF Sensor

When selecting a ToF sensor for a project, consider these factors:

  • Range: How far do you need to measure? Some sensors work up to a few centimeters, others up to several meters.
  • Accuracy: Direct ToF tends to be more accurate at longer ranges; indirect ToF can be more precise at short range.
  • Ambient light: Most ToF sensors work in sunlight, but performance can degrade in very bright conditions. Look for sensors with ambient light rejection.
  • Field of view: Some sensors measure a single point, others a 2D array (like a depth camera).
  • Interface: Common interfaces are I²C, SPI, and UART. Ensure your microcontroller supports the chosen protocol.

For hobbyist projects, a single-point ToF sensor like the VL53L0X is popular because it is small, cheap, and has good accuracy. For depth imaging, you would need a more complex sensor like those used in phone cameras.

Common Mistakes and Limitations

One frequent error is forgetting to divide by 2. The time measured is the round-trip, not the one-way. Another mistake is using the wrong speed of light: in air, the speed is slightly lower than in vacuum, but the difference is less than 0.03%, so it rarely matters for typical applications.

Limitations include:

  • Ambient light interference: Strong sunlight can add noise to the detector.
  • Reflective surfaces: Mirrors or glossy surfaces can cause erroneous readings because the light reflects at an angle.
  • Transparent materials: Glass or clear plastic may not reflect enough light.
  • Maximum range: Beyond a certain distance, the reflected signal is too weak to detect.

Also, the speed of light in a medium like water is about 225,000 km/s, not 299,792 km/s. If you are measuring through water, the formula would need to use that value.

ToF vs. Other Distance Sensors

ToF sensors are often compared with ultrasonic sensors and infrared (IR) proximity sensors:

  • Ultrasonic: Uses sound waves. Slower, but works in dust and smoke. Range is usually a few meters. Not affected by light.
  • IR proximity (simple LED/photodiode): Measures intensity of reflected IR light. Not a true distance measurement; it only indicates if an object is within a threshold. Cheap but unreliable for precise distance.
  • ToF: Measures actual distance with high speed and precision. More expensive than simple IR, but more robust.

For applications needing accurate distance in real time, ToF is usually the best choice.

Safety and Accuracy Notes

ToF sensors that use lasers are typically Class 1, meaning they are safe for eyes under normal use. However, never stare directly into the laser beam. When integrating a ToF sensor, follow the manufacturer’s guidelines for power and wiring to avoid damage.

For accurate measurements, ensure the target surface is large enough to reflect a sufficient signal. Small or distant objects may give unreliable readings. Calibration may be needed if the sensor is used behind a cover glass, as the glass adds a small offset.

Frequently Asked Questions

What does ToF stand for?

ToF stands for Time-of-Flight. It refers to the time a light signal takes to travel from the emitter to the target and back to the receiver.

Is a ToF sensor the same as LiDAR?

Not exactly. LiDAR is a broader term that often uses ToF principles, but LiDAR systems are typically more complex, using scanning lasers to create 3D maps. A ToF sensor can be a single point or a small array, while LiDAR usually covers a wider area.

Why do phones have ToF sensors?

Phones use ToF sensors for depth sensing, which enables features like portrait mode (background blur), improved autofocus in low light, and AR applications that place virtual objects in the real world.

Can a ToF sensor work in the dark?

Yes. Since the sensor emits its own light, it works in complete darkness. In fact, darkness can improve performance because there is less ambient light interference.

How accurate is a ToF sensor?

Accuracy depends on the sensor and conditions. Typical hobbyist sensors have accuracy of ±3 mm to ±5 mm at short range. High-end industrial sensors can achieve better than ±1 mm.

Does temperature affect ToF measurements?

Yes. Temperature can affect the speed of light in air slightly, and also the electronics’ timing. Most sensors include temperature compensation, but for extreme accuracy, you may need to calibrate for your environment.

Related

Formula used
in t | Round-trip time | ns | 10 | 0
in c | Speed of light | m/s | 299792458 | 0
out distance | Distance to object | m | (c * t * 1e-9) / 2 | 3
out dist_cm | Distance in centimeters | cm | ((c * t * 1e-9) / 2) * 100 | 1

Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.