Skip to content

HC-SR04 ultrasonic range sensor

This sensor uses a simple pulse echo to compute the distance to an object. It simply emits a high frequency 'ping' and measures the time taken for the echo to return. The distance to an object is then calculated using a simple formula.

Ultrasonic proximity sensor

To operate the sensor, the Vcc and Gnd pins should be connected to 5V and ground respectively. The remining pins, Trig and Echo, should be connected to digital pins on the Arduino. A pulse is sent to the Trig pin by raising the pin to 5V for a short period such as 10 milliseconds. The echo is received and processed automatically by the sensor which delivers a pulse back on the Echo pin. The duration of the echo pulse indicates the distance from the object. The pulse can be read using the Arduino pulseIn() function. The distance in centimetres can be calculated using the formula:

\[distance (cm) = \frac{duration (μs)}{58}\]

Datasheet Datasheet