1. Watch the round trip
The sensor measures the echo pulse width. The sound travels out and back, so the distance is half the sound path.
Watch an ultrasonic trigger, burst, echo, and distance calculation unfold step by step.
Trigger a short ultrasonic burst, follow the sound to the target and back, then see how echo time becomes distance. Adjust the real-world conditions that decide whether the reading is trustworthy.
The sensor measures the echo pulse width. The sound travels out and back, so the distance is half the sound path.
distance = echo time x speed of sound / 2. The division by two is the most common beginner mistake.
Temperature changes sound speed. Angled or soft targets may return weak echoes even when the ideal formula is correct.
Use the diagnosis to check blind zone, timeout, signal strength, repeat rate, and whether averaging hides fast motion.
A microcontroller sends a 10 us pulse to start one measurement.
The module emits about eight 40 kHz ultrasonic cycles.
Sound travels from the transmitter toward the target.
The target surface returns part of the acoustic energy.
The receiver detects the returning wave and closes the echo pulse.
Echo duration, sound speed, and round-trip correction produce the reading.
Use Play or Step to inspect the trigger, burst, outbound wave, reflection, echo return, and timing pulse.
Change the measurement setup and watch the formula, timing, and diagnosis update together.
The echo should be easy to detect. The reading is inside the typical HC-SR04 range.
The sound path is 240.0 cm for a 120.0 cm target, so distance uses half the echo time.
At 20 C, using 343 m/s is close. In colder or hotter air, hard-coded constants drift.
Hard, flat targets facing the sensor produce stronger echoes than soft or angled targets.
Longer distances need longer timeouts and slower repeat rates so old echoes can fade.
distance = echo time x speed of sound / 2. Echo time is the width of the ECHO pulse and represents the full out-and-back path.
For classroom calculations, use v = 331.3 + 0.606T m/s, where T is air temperature in C. At 20 C this is about 343.4 m/s.
A common module needs a 10 us trigger pulse, emits a short 40 kHz burst, and reports distance by holding ECHO high for the round-trip time.
Many classroom modules are useful from about 2 cm to 400 cm. Below the blind zone or above the range limit, readings become unreliable.
Flat hard surfaces reflect well. Cloth, foam, narrow objects, rough surfaces, and angled targets may scatter or absorb the echo.
Leave about 50 to 60 ms between readings for long-range measurements so echoes from the previous burst do not contaminate the next one.
The measured time includes sound travelling from sensor to target and from target back to sensor. One-way distance is therefore half of the measured sound path.
If firmware assumes 20 C but the air is much colder or warmer, the calculated distance shifts. Temperature compensation only fixes sound-speed error, not weak echoes.
A timeout shorter than the expected echo duration will look like "no object." A very long timeout slows the application and can hide missed detections.
Averaging reduces random jitter for static targets. It can lag behind moving targets, so obstacle avoidance usually needs faster decision logic.
The common quoted beam angle is approximate. Real beam width depends on transducer, mounting, surface size, and the threshold used by the receiver circuit.
Ultrasonic sensing is poor for vacuum, very turbulent air, absorbent materials, narrow target edges, and applications that require millimetre-class repeatability over changing conditions.
Set the target to 100 cm at 20 C. Predict the echo time before reading the metric card. Then explain why it is close to 5.8 ms.
Keep the distance fixed and move temperature from -10 C to 45 C. Describe what firmware would do wrong if it always assumed room temperature.
Use the weak-echo button, then recover the setup. Which change helped most: shorter distance, flatter target, harder material, or longer timeout?
Compare ultrasonic sensors with resistive, optical, magnetic, and inertial sensing methods.
Connect sensor readings to firmware timing, filtering, calibration, and embedded decision logic.
Use filtering ideas to reduce jitter once the physical measurement is producing valid echoes.