Ultrasonic Sensor HC-SR04 Specification and Its Alications
SR04 Ultrasonic Distance Sensor is a popular and low cost solution for non-contact distance measurement function. This module includes ultrasonic transmitter, ultrasonic receiver and its control circuit. The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. From 2 cm to 400 cm or 1” to 13 feet. It comes complete with ultrasonic transmitter and receiver module.
SENSOR PIN | ARDUINO CONNECTION |
Vcc | 5V DC |
TRIGGER | Trigger pin D9 |
ECHO | Echo Pin (output) D12 |
GND | Ground with Circuit |
FEATURES:
1. Quiescent Current: <2mA.
2. Working Current: 15mA.
3. Effectual Angle: <15°.
4. Ranging Distance: 2cm – 400 cm/1″ – 13ft.
5. Resolution: 0.3 cm
6. Measuring Angle: 30 degree.
7. Trigger Input Pulse width: 10uS.
8. Dimensions: 45mm x 20mm x 15mm.
9. Power Supply:+5V DC.
OPERATION:
The ultrasonic sensor works on the principle of SONAR and RADAR system which is used to determine the distance to an object. An ultrasonic sensor generates the high-frequency sound (ultrasound) waves. When this ultrasound hits the object, it reflects as echo which is sensed by the receiver
Provide TRIGGER signal, atleast 10μS High Level (5V) pulse.
The module will automatically transmit eight 40KHz ultrasonic burst.
If there is an obstacle in-front of the module, it will reflect the ultrasonic burst.
If the signal is back, ECHO output of the sensor will be in HIGH state (5V) for a duration of time taken for sending and receiving ultrasonic burst. Pulse width ranges from about 150μS to 25mS and if no obstacle is detected, the echo pulse width will be about 38ms.
ALL SENSOR DETAILS:
1. HC-05 – Bluetooth
2. Mpu 6050 accelerometer-gyroscope- -module
3. Flame-sensor
4. Rotary-encoder
5. Force-sensor-fsr400
6. Current-sensor-acs712
7. Flex-sensor
8. IR-sensor-tcrt5000
9. Pulse-sensor-pin
10. Color-sensor-tcs230
11. SD-card-module
12. Oled-with-arduino
13. Addressable-rgb-led-strip-ws1812
14. Relay-module
15. TFT-1-8-display-st7735r
16. 8×8-dot-matrix-display-max7219
17. Smoke-sensor-mq-2
18. Ultrasonic-sensor-HC-sr04
19. PIR-motion-sensor-hc-sr501
20. Tilt-sensor-sw-520d
21. Microphone-sound-sensor
22. Reed-switch-reed-sensor
23. Rfid-reader-Em18
24. Rfid-tag
25. RTC-real-time-clock-ds1307
26. Temperature-sensor-ds18b20
27. Moisture-sensor
28. Rain-sensor
29. Pressure-sensor
30. Accelerometer
31. MOC-3021-circuit
32. DHT11-DHT22-temperature-and-humidity-sensor
HC-SR04 WITH ARDUINO:
In this project the ultrasonic sensor reads and writes the distance in the serial monitor.
Upload the following code to your Arduino IDE.
/*
* Code for Ultrasonic Sensor HC-SR04
*/
#define trigPin 3
#define echoPin 2
#define led 5
#define led2 6
void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(led, OUTPUT);
pinMode(led2, OUTPUT);
}
void loop()
{
long duration, distance;
digitalWrite(trigPin, LOW); // Added this line
delayMicroseconds(2); // Added this line
digitalWrite(trigPin, HIGH);
// delayMicroseconds(1000); – Removed this line
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance = (duration/2) / 29.1;
if (distance < 4)
{
// This is where the LED On/Off happens digitalWrite(led,HIGH);
// When the Red condition is met, the Green LED should turn off digitalWrite(led2,LOW);
}
else
{ digitalWrite(led,LOW);
digitalWrite(led2,HIGH);
}
if (distance >= 200 || distance <= 0)
{
Serial.println(“Out of range”);
}
else
{
Serial.print(distance);
Serial.println(” cm”);
}
delay(500);
}
For Arduino IDE Software: Download Here.