IoTClass Inside the measurement
A closer look · 01

Sensor

Look inside
a sensor.

Ultrasonic ranger

An ultrasonic distance sensor sends out a sound pulse and listens for its reflection from a target. In the HC-SR04, the ECHO pin goes HIGH when sound is sent and LOW when the reflection returns. The IoT controller measures how long this electrical pulse lasts, multiplies that time by the speed of sound, and divides by two to get distance. The division accounts for the outward and return journeys.

Air temperature changes the speed of sound, so use temperature correction when you need a precise distance.

01

Recognize the element

Recognize the element: Ultrasonic ranger

ultrasonic: measurement pathA sound pulse returns from a target; the echo time supports a distance calculation. The transducer and target are generic conceptual shapes, not to scale.ConceptualUltrasonic rangingtargetEcho round-trip time Δtd = cΔt/2
The timer includes the journey out and back. Divide the sound travel distance by two to get the target distance.
02

Peel the teaching model

From case to sensing element

Choose a layer to see the measurement path. The enclosure and board layout are invented teaching choices, not a particular product.

The full text version below describes every layer. All measurement explanations are available without 3D.
Conceptual, not to scale
Case: transmitter and receiver cansThe paired transducers send a sound pulse and receive its returning echo. [Ultrasonic Distance Sensor (HC-SR04)]

Drag to rotate; pinch to zoom. With the view focused: arrow keys rotate, + / − zoom, 1–3 choose a layer, Home resets rotation and zoom. Step advances to the next layer; Reset returns to the case and default view. Layer buttons select a view directly. The page does not move on its own.

Layer 1 of 3 / Outside

Case: transmitter and receiver cans

The paired transducers send a sound pulse and receive its returning echo. [Ultrasonic Distance Sensor (HC-SR04)]

Teaching view: Two silver cans sit side by side on the board. One sends sound toward a target; the other receives the echo.

The measurement to rememberFor example, with sound traveling at 343 meters per second and an echo returning after 2 milliseconds, distance is 343 meters per second × 0.002 seconds ÷ 2 = 0.343 meters. The division by two accounts for the trip to the target and back. [Ultrasonic Distance Sensor (HC-SR04)]

Full text version · every layer

1 · Case: transmitter and receiver cans

The paired transducers send a sound pulse and receive its returning echo. [Ultrasonic Distance Sensor (HC-SR04)]

Teaching view: Two silver cans sit side by side on the board. One sends sound toward a target; the other receives the echo.

2 · Board / module: echo timing

The microcontroller measures the echo pulse duration and converts it into distance. [Ultrasonic Distance Sensor (HC-SR04)]

Teaching view: The blue board supports two gold discs and a dark controller block. Trigger and echo connections let the microcontroller start a measurement and time the return.

3 · Element: sound transducer

For example, at a sound speed of 343 meters per second, a 2-millisecond round trip gives a target distance of 343 meters per second × 0.002 seconds ÷ 2 = 0.343 meters. [Ultrasonic Distance Sensor (HC-SR04)]

Temperature changes the speed of sound and therefore the distance calculation. [Ultrasonic Distance Sensor (HC-SR04)]

Teaching view: Each can contains a thin piezoelectric element that changes shape when a voltage is applied. The transmitter circuit drives its element back and forth to send a sound pulse. The returning echo vibrates the receiver element, producing a small voltage. The board detects the echo, and the microcontroller uses its travel time to calculate distance.

Explore the layers in order to follow the teaching model.

03

Listen

Package narration

Read transcript
Imagine Luis fitting a connected bin with an ultrasonic ranger under its lid. He wants a distance reading to help judge how full the bin is. Before choosing a threshold, he asks what the module actually returns. It returns echo time. A sound pulse travels to the target and comes back. The controller turns that elapsed time into distance by multiplying it by the speed of sound, then dividing by two. The physical event being timed includes both journeys. Use the chapter's worked ping. The echo takes five point eight three milliseconds, which is zero point zero zero five eight three seconds. At twenty degrees Celsius, use three hundred forty three meters per second. Multiply that speed by the time and divide by two: the target is about one meter away. A common misconception is that the entire timed journey is the distance to the target. It is the outward journey plus the return, so leaving out the division by two counts both legs as target distance. Luis should also check echoes with the sensor at its final lid height, because the chapter calls for calibration in the installed geometry. Take away this rule: an ultrasonic distance is an interpreted round trip, so keep the timing, sound speed, and installation together.

You can use “Read layer aloud” in the explorer for your browser’s optional voice reading.