HC-SR04 UltraSonic Sensor
Ultrasonic sensor operating in the range of 2-200 cm. Powered by 5 V. The output is a signal whose duration is proportional to the measured distance.
- Power supply: 5 V
- Average power consumption: 15 mA
- Measuring range: from 2 cm to 200 cm
- Output: frequency signal
- Operating frequency: 40 kHz
- Dimensions: 45 x 20 x 15 mm
To start the measurement, a voltage pulse (high state 5V) must be given to the TRIG pin for 10 μs. The module measures distance by means of a 40 kHz sound wave. A signal is sent to the microcontroller in which the distance depends on the duration of the high state and can be calculated from the formula:
test distance = (high level time × velocity of sound (340m / s) / 2
- test distance - measured distance
- high level time - duration of the high state
- velocity of sound - speed of sound wave propagation in the air - 340 m / s
In short, to get the result in cm you can use the formula:
distance [cm] = (high level time [us] * 34) / 1000/2
The measurement procedure is shown in the figure below.