Video summary

HC SR0405 초음파거리센서 사용하기

Main summary

Key takeaways

Technology

Goal of the Session

  • Demonstrates how to measure distance using an ultrasonic distance sensor (e.g., SR04 / HC-SR04) connected to a Raspberry Pi.

Ultrasonic Distance Sensing (Time-of-Flight)

  • The sensor has:
    • An emitter/transducer to generate ultrasonic waves
    • A receiver/transducer to detect the returning echo
  • Operating principle:
    1. Ultrasonic waves travel through air in a straight line
    2. They reflect off an obstacle
    3. The echo returns to the sensor
    4. The Raspberry Pi measures the round-trip time
    5. Distance is computed from the time-of-flight
  • Analogy: bat echolocation
    • Bats generate high-frequency sounds and estimate distance using the timing of echoes.

Human Hearing Context (Why It’s “Invisible”)

  • Background subtitles reference the human audible range of roughly 20 Hz–20,000 Hz.
  • Humans generally cannot perceive ultrasonic frequencies, which helps explain why ultrasonic sensing feels “invisible” to people.

Hardware / Wiring Guidance (Sensor ↔ Raspberry Pi)

  • Sensor pins mentioned:
    • VCC (5V)
    • Trigger / Output pin
    • Echo pin
    • Ground
    • (Five total pins are referenced in subtitles, but the actual wiring/script behavior uses 4.)
  • Key wiring warning:
    • Pay attention to correct polarity and grounding to avoid reversed connections.
  • GPIO voltage level conversion is required:
    • Raspberry Pi GPIO input logic level is 3.3V
    • HC-SR04 Echo is typically around 5V
    • A voltage level conversion / resistor divider is used to scale Echo down to 3.3V for the Pi.
  • Suggested pin mapping in the session:
    • GPIO 23 as Trigger
    • GPIO 24 as Echo
    • If pins are already in use, adjust the connections accordingly.
  • After wiring:
    • The sensor is connected to the Raspberry Pi and configured in software once connections are confirmed.

Software Approach (Python on Raspberry Pi)

  • Core logic:
    1. Pi sends a Trigger pulse
    2. When the echo returns, the code measures the time interval
    3. The program converts propagation time into a distance value (e.g., centimeters)
  • Code structure described:
    • Functions for:
      • measurement
      • time-to-distance conversion
    • A main loop that:
      • repeatedly triggers measurement
      • prints results
      • runs any basic decision logic
  • Copy/paste guidance:
    • Instructor suggests copying the code “as is” and fixing indentation if needed when pasting.

References / Code Sources Mentioned

  • LMS post/material uploaded by the instructor:
    • Title: “Using Ultrasonic Distance Sensors”
    • Includes materials describing wiring for HC-SR04 with Raspberry Pi
  • An additional external reference:
    • Explains using the sensor with Arduino and Raspberry Pi
    • Notes that Arduino can accept 3.3V directly (no issue mentioned),
    • While Raspberry Pi requires level shifting for Echo.

Testing / Observed Behavior

  • As an obstacle/hand approaches the sensor, the measured distance changes.
    • Example mention: values around the ~30 cm region with variation.
  • Demonstrates working at multiple ranges:
    • Moving closer changes the “closeness” readings appropriately
    • Moving the object to a different position still yields valid distance measurements.
  • An error margin is mentioned (subtitles include wording like “35 ± 0.5” style), though exact values are unclear due to auto-subtitles.

Assignment / Tutorial Outcome

  • Concludes that users can measure distances easily with the provided module/code.

Assignment 5

  • Task: Modify/create a program that outputs the ultrasonic distance reading to an OLED screen.
  • Current demo behavior:
    • Prints readings to the console
  • Required change:
    • Display the readings on OLED instead.

Original video