Back to Learn

Ultrasonic Sensor

The HC-SR04 is the industry-standard ultrasonic module for beginners, providing non-contact distance measurement for robotics.

Ultrasonic Sensor (HC-SR04)
📡

Ultrasonic Sensor (HC-SR04)

Uses sound waves to measure distance. It emits a high-frequency sound pulse and measures the time it takes for the echo to reflect back from an object.

Key Applications

  • Obstacle avoidance
  • Distance measurement
  • Liquid level sensing
Range: 2cm to 400cm | Angle: 15° | Supply: 5V DC

🧪The Science Behind It

The Ultrasonic sensor works on the principle of Echolocation, similar to how bats and dolphins navigate. It uses a transducer to send out a high-frequency sound pulse (40kHz).

The Time of Flight (ToF) principle is used to calculate distance: The sensor triggers a pulse, waits for the echo to return, and calculates the distance based on the speed of sound (approx. 343m/s).

Distance = (Time × Speed of Sound) / 2

Pin Configuration

VCC5V Power Supply
TrigTrigger input to start the sound pulse
EchoOutput pulse width corresponds to distance
GNDGround Connection