Skip to content
MakerBuddy

Term 2 · Weeks 9–16

Converting physical phenomena — light, heat and motion — into data and mechanical movement. Each lesson includes its full classroom material, activity and challenge.

Learning Objective

Measure distance using ultrasonic sound waves.

Distance & Echolocation (HC-SR04)

Week 12 Term 2 45-60 minutes
Hardware

Hardware: HC-SR04 Ultrasonic Rangefinder

Dashboard

Dashboard: Ultrasonic Distance Reading Card

Theory: Ultrasonic Distance Measurement

Seeing Without Light: Introduction to Echolocation

So far we've used sensors that respond to physical touch (buttons), rotation (potentiometers), light (LDR) and temperature (DHT11, DS18B20). But how do we measure distance to objects without physically touching them? This week we explore the fascinating world of ultrasonic sensing - the same technology bats use to navigate in complete darkness! The HC-SR04 sensor uses sound waves beyond human hearing to measure distances from 2 centimeters to 4 meters with remarkable accuracy.

How Ultrasonic Sensors Work

The HC-SR04 has two key components: a transmitter (the "T" eye) and a receiver (the "R" eye). Here's how it measures distance: First, the transmitter sends out a burst of ultrasonic sound at 40 kHz - far above the 20 kHz limit of human hearing. This sound wave travels through the air at approximately 343 meters per second (the speed of sound). When it hits an object, it bounces back like an echo. The receiver detects the returning echo. The sensor measures how long the round trip took - this is called Time of Flight. Since we know the speed of sound, we can calculate distance using the formula: Distance = (Speed of Sound × Time) ÷ 2. We divide by 2 because the sound traveled to the object AND back!

Technical Details: Range, Resolution and Limitations

The HC-SR04 has a measuring range of 2cm to 400cm (0.8 inches to 13 feet) with accuracy of about ±3mm under ideal conditions. The sensor has a beam angle of approximately 15 degrees, meaning it detects objects in a cone shape rather than a laser-thin line. This sensor works best with large, flat, hard surfaces perpendicular to the sensor. Soft materials (like fabric or foam) absorb sound and may give weak echoes. Angled surfaces reflect sound away from the receiver. Very small objects may not reflect enough sound to be detected. Temperature and humidity affect the speed of sound slightly, but for our purposes, the sensor compensates automatically.

Real-World Applications

Ultrasonic sensors are used everywhere! Car parking sensors beep faster as you get closer to obstacles, preventing expensive collisions. Autonomous robots and drones use arrays of ultrasonic sensors to navigate and avoid obstacles.Water level monitors in tanks measure the distance to the water surface to calculate remaining volume. Automatic hand dryers and soap dispensers detect your hands approaching. Industrial automation uses them to verify parts are in position on assembly lines. Even some medical devices use ultrasound to measure distances and create images!

For Teachers

This lesson introduces Time of Flight measurement - a critical concept in physics and robotics. Use this opportunity to discuss the speed of sound (343 m/s at 20°C) and how it differs from the speed of light (300,000 km/s). Have students calculate expected times: at 10cm distance, the sound travels 20cm total (there and back) in about 580 microseconds! Demonstrate the beam angle by moving objects to the side - students will see the sensor "loses" the object. Discuss why submarines use sonar (sound works underwater, radar doesn't) and why bats evolved echolocation (works in darkness, vision doesn't). This prepares students for next term's servo control and automation projects like parking barriers.

For Parents

This week your child learns about echolocation and Time of Flight measurement - the technology behind parking sensors, robots and even medical ultrasound. Understanding how we can measure without touching teaches important physics concepts: wave propagation, reflection and using time measurements to calculate distance. This sensor is particularly exciting because it mimics how bats and dolphins navigate - biomimicry is a powerful engineering concept. The skills learned here - understanding sensor limitations, interpreting measurements and working with physics-based calculations - are fundamental to robotics, automation and many STEM careers.

Hands-On Activity: Distance Sensing

Activity Duration: 20-25 minutes

Students will connect the HC-SR04 sensor, explore how distance readings change with object position and investigate the sensor's limitations and ideal operating conditions.

Step-by-Step Instructions:

  1. Identify the Sensor: Locate the HC-SR04 sensor with its two circular "eyes" (transmitter and receiver) and 4-pin connection.
  2. Connect to MakerBuddy: Plug the HC-SR04 into the 4-pin header labeled for distance sensing Labled as HC-SR04 .
  3. Open Dashboard: Navigate to the Distance Sensor card on your web interface. You should see a real-time distance reading in centimeters.
  4. Point at Wall: Aim the sensor at a flat wall about 50-100cm away. Note the distance reading.
  5. Move Closer: Slowly move the sensor toward the wall while watching the distance value decrease. Get as close as 5cm.
  6. Move Farther: Back away from the wall. Watch the distance increase. How far can you go before the reading becomes unstable or shows errors?
  7. Test Different Materials: Point the sensor at different surfaces: smooth wall, textured fabric, your hand, a book, a curved surface. Which gives the most reliable reading?
  8. Test Angles: Tilt the sensor at different angles to the wall. What happens when it's not perpendicular? At what angle does it stop detecting the surface?

What Students Should Observe:

  • Distance reading updates in real-time (several times per second)
  • Smooth, hard, flat surfaces give the most accurate and stable readings
  • Very close distances (under 2cm) cannot be measured reliably
  • Very far distances (over 3-4 meters) may show errors or unstable readings
  • Angled surfaces or soft materials may give inconsistent or no readings
  • The sensor has a cone-shaped detection area, not a pinpoint beam

Challenge

Your Mission: Accuracy Verification Lab

You're a quality control engineer testing a batch of distance sensors. Your job is to verify they meet accuracy specifications using scientific measurement techniques!

Challenge 1: Precision Testing

Using a ruler or measuring tape, test the sensor at these specific distances:

  1. 10 cm from a flat object
  2. 20 cm from a flat object
  3. 50 cm from a flat object
  4. 100 cm from a flat object

Record: Actual distance (measured), Sensor reading, Error (difference). Calculate the percentage error for each measurement. Which distance range is most accurate?

Challenge 2: Material Testing

Hold the sensor exactly 30cm from different surfaces and record the reading for each:

  • Smooth wall or whiteboard
  • Textbook cover
  • Your hand (palm flat)
  • Fabric or clothing
  • Cylindrical object (like a water bottle)

Which materials give the most accurate readings? Which don't work well? Why?

Discussion Questions:

  • Why does the sensor divide the time by 2 in its distance calculation?
  • How would temperature affect the sensor's accuracy? (Hint: sound travels faster in warm air)
  • Why is this sensor better than a laser for some robotics applications, but worse for others?
  • Can you think of situations where this sensor would fail completely?

Bonus Challenge: If sound travels at 343 m/s and the sensor measures 50cm distance, how many microseconds did it take for the sound to travel there and back? (Answer: about 2,900 microseconds or 2.9 milliseconds - calculate it yourself!)

Key Takeaways

✓ Ultrasonic Waves

Ultrasonic waves are sound frequencies above human hearing (typically 40 kHz for sensors like the HC-SR04). These waves travel through air, bounce off objects and return as echoes - the same principle bats and dolphins use for navigation in darkness or murky water. Unlike light, ultrasonic waves can work in complete darkness and can detect transparent objects.

✓ Time of Flight

Time of Flight (ToF) measures the elapsed time between sending a signal and receiving its reflection, then calculates distance using known signal speed. For ultrasonic sensors: Distance = (Speed of Sound × Time) ÷ 2, where we divide by 2 because the sound travels to the object and back. This principle is used in sonar, radar, laser rangefinders and even smartphone facial recognition.

✓ Echolocation

Echolocation is the biological or technological ability to detect objects by emitting sounds and listening for echoes. Bats evolved this ability to hunt insects in darkness; dolphins use it to navigate murky oceans. The HC-SR04 mimics this natural phenomenon, demonstrating how engineering often draws inspiration from nature - a field called biomimicry.

✓ Distance Measurement

Non-contact distance measurement enables robots to navigate, parking sensors to prevent collisions and automation systems to detect object presence without physical touch. Understanding sensor limitations - minimum/maximum range, beam angle, surface requirements - is crucial for effective implementation. Different applications require different sensing technologies: ultrasonic for mid-range obstacles, infrared for short-range, radar for long-range.

Coming Up Next Week:

Week 13: Security Sensing (PIR Motion)