Introduction
HC-SR04 Ultrasonic Sensor Module
Ultrasonic Module HC-SR04 works on the principle of SONAR and RADAR system. It can be used to determine distance of an object in the range 2 cm – 400 cm.
The module has only 4 pins, Vcc, Gnd, Trig and Echo.
When a pulse of 10µsec or more is given to the Trig pin, 8 pulses of 40 kHz are generated. After this the Echo pin is made high by the control circuit in the module. Echo pin remains high till it gets echo signal of the transmitted pulses back.
The time for which the echo pin remains high, i.e. the width of the Echo pin gives the time taken for generated ultrasonic sound to travel to the object and back.
Using this time and the speed of sound in air, we can find the distance of the object using simple formula for distance using speed and time.
For more information about ultrasonic module HC-SR04 and how to use it, refer the topic Ultrasonic Module HC-SR04 in the sensors and modules section.
Interfacing Diagram
Interfacing Ultrasonic Sensor Module WithParticle Photon
Steps for coding
1. Open IDE and click on Library.
2. Type HC-SR04 and open it.
3. Then click on example of usage.ino and open it and flash on your photon board.
Output of the HC-SR04:
Components Used |
||
---|---|---|
Particle Photon PHNTRAYH |
X 1 | |
Ultrasonic Module HC-SR04 Ultrasonic module HC-SR04 is generally used for finding distance value and obstacle detection. It can operate in the range 2cm-400cm. |
X 1 |