Skip to content
Tutorials

Measuring Vehicle Speed with Two Sensors: Accuracy, Classification and Traffic Surveys

10 October 2026 4 min read 15
Measuring Vehicle Speed with Two Sensors: Accuracy, Classification and Traffic Surveys

As towns grow, residents near schools and markets ask for speed humps and lower limits, and road authorities need data to decide where they actually help. A two-sensor speed detector is one of the simplest tools that produces that data. It is also a good engineering exercise, because the accuracy depends on details that are easy to overlook.

The principle

Place two sensors across the lane a known distance d apart. When a vehicle passes the first sensor, start a timer. When it reaches the second, stop it. Then:

v = d / Δt

With sensors 2 m apart and a measured time of 90 ms:

v = 2 / 0.090 ≈ 22.2 m/s ≈ 80 km/h

Sensors can be infrared beams across the lane, inductive loops in the road surface, pneumatic tubes, or piezo strips. The maths is the same for all of them.

How accurate is it?

Two things limit accuracy: how precisely you know d, and how precisely you measure Δt.

Timing resolution. At 100 km/h (27.8 m/s) with sensors 1 m apart, the vehicle takes only 36 ms. If the timer resolution is 1 ms, that is roughly a 3 % error. Spread the same sensors 5 m apart and the time is 180 ms, so the same 1 ms error is about 0.6 %. Microcontrollers can timestamp edges to microseconds with input capture or micros(), but sensor response time adds its own uncertainty.

Spacing. A 2 cm error in a 1 m spacing is a 2 % speed error. Measure the installed spacing carefully and keep the sensors rigidly mounted.

Triggering point. Both sensors must trigger on the same part of the vehicle. An infrared beam at bumper height works for cars but may trigger on a truck's mirror at one sensor and its bumper at the other. Mount both identically.

Sensor spacingTime at 100 km/hError from 1 ms resolution
1 m36 msabout 2.8 %
2 m72 msabout 1.4 %
5 m180 msabout 0.6 %

Getting more than speed

The same two sensors give extra information almost for free:

  • Direction. Which sensor triggers first tells you the direction of travel, so one installation can survey both directions on a two-way road.
  • Length. The time a single beam stays blocked, multiplied by the speed, gives the vehicle's length. Length separates motorcycles, cars, buses and trucks into classes.
  • Gaps and tailgating. The time between one vehicle leaving and the next arriving shows dangerously short following distances.

From readings to decisions: the 85th percentile

One speeding car proves little. What traffic engineers use is the distribution of speeds over hundreds or thousands of vehicles, especially the 85th percentile speed: the speed at or below which 85 % of drivers travel. It is widely used as a starting point for setting speed limits and judging whether traffic calming is needed.

A useful survey therefore records every vehicle, then reports for each hour or day:

  • vehicle counts by class and direction,
  • mean and 85th percentile speed,
  • the share of vehicles over the speed limit.

Practical design points

  • Display: a large "YOUR SPEED" display alone measurably slows many drivers.
  • Logging: store violations or summaries in EEPROM or on an SD card so a power cut does not lose a week of data.
  • Settings protection: guard the speed limit and sensor spacing settings with a PIN, because a wrong spacing value silently corrupts every reading.
  • Legal use: a home-built detector is fine for surveys and awareness. Enforcement needs certified, calibrated equipment.

See the project

The vehicle speed detector project measures speed, direction, length and class, flags tailgating, shows speed on a large display, computes 85th percentile statistics, logs violations to EEPROM and produces a survey report. It also includes a browser demo with sample traffic for Kathmandu, Pokhara, Chitwan and Hetauda. For related junction work, see traffic light controller design.

Comments 0

No comments yet. Be the first to share your thoughts!

Leave a Comment
Comment submitted!
0 / 3000

Your email will never be published. Comments are moderated before appearing.