The HC-SR04 is a small low-cost ultrasonic sensor that can measure distance from 2cm up to 4 meters with a stable performance and high ranging accuracy under a 15° detection angle and in an easy-to-use package. This sensor is very easy to interface with the Arduino board or any other microcontroller.
As any ultrasound sensor, the HC-SR04 operates like a simple radar, by sending a series of pulse waves and listen to an echo. To measure a distance, start by sending a short trigger pulse to the TRIG pin, at the same time monitor the ECHO pin until the output is HIGH and measure the pulse width.
The distance is equal to (pulse duration in seconds) * (speed of sound) / 2 where the pulse width is in unit of second and sound speed is in unit of meter/second. Normally sound speed is 340m/s under room temperature.
To use this sensor with the Arduino simply download the srf04-library if you’re using the Arduino IDE 1.0 or theUltrasound Library if your IDE version is older. We recommend a pause of 60-100ms between each distance reading to allow the echo pulse enough time to settle.
Note: The HC-SR04 is not temperature compensated, because the speed of sound varies with the room temperature you might get different result for the same distance when measuring at different room temperatures. If you need more precision we recommend the Maxbotix Ultrasound Sensors.
Operating Voltage: 5V
DC Operating Current: 15mA
Operating Frequency: 40KHz
Maximum reading distance: 400cm
Minimum reading distance: 2cm
Detection Angle: 15°
Trigger pulse: >10us
TTL pulse Output pulse with proportional to distance
Maximum pulse width: 38ms if no obstacle
Dimension: 45 x 20 x 15 mm