The HC-SR04 ultrasonic sensor uses sonar to measure distance to an object. It offers excellent range accuracy and stable readings in an easy-to-use package. It operation is not affected by sunlight or black material like sharp range finders are (soft materials like cloth can be difficult to detect).
Module main technical parameters.
- Working Voltage: 5V(DC)
- Static Current: Less than 2mA.
- Output Signal: Electric frequency signal, high level 5V, low level 0V
- Sensor Angle: Not more than 15 degrees
- Detection Distance: 2 to 450 cm
- High Precision: Up to 0.3cm
- Input Trigger Signal: 10us TTL impulse
- Echo Signal: Output TTL PWL signal mode of connection, VCC, trig(T), echo(R), GND.
The basic operation principle is: use IO port TRIG to trigger ranging. It needs 10 us high level signal at least module will send eight 40kHz square wave automatically and will test if there is any signal returned. If there is signal returned, output will be high level signal via IO port ECHO. The duration of the high level signal is the time from transmitter to receiving with the ultrasonic.
Testing distance = duration of high level x sound velocity(340m/s) / 2
You can use the above calculation to find the distance between the obstacle and the ultrasonic module.