0

members

Easy Basics: Project 009a Ultrasonic Sensor HC-SR04

of Acoptex.com in UNO

Basics: Project 009a

Project name: Ultrasonic Sensor HC-SR04

Attachments: libraries and sketch1

In this project, you needed these parts :

1.Aruduino Uno R3 (you can also use the other version of Arduino)

2.Ultrasonic Sensor HC-SR04 module

3.Arduino IDE ( you can download it from here  )

4.Jumper cables

5. Half breadboard 1 pc

Understanding the HC-SR04 Ultrasonic Module

The HC-SR04 Ultrasonic Sensor is a very affordable proximity/distance sensor that has been used mainly for object avoidance in various robotics projects. It essentially gives your Arduino eyes / spacial awareness and can prevent your robot from crashing or falling off a table. 

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 2cm to 400 cm or 1” to 13 feet. It operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.

Features
Power Supply :+5V DC
Quiescent Current : <2mA
Working Current: 15mA
Effectual Angle: <15°
Ranging Distance : 2cm – 400 cm/1″ – 13ft
Resolution : 0.3 cm
Measuring Angle: 30 degree
Trigger Input Pulse width: 10uS
Dimension: 45mm x 20mm x 15mm

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 operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.

Features

  • Power Supply :+5V
  • DCQuiescent Current : <2mA
  • Working Current: 15mA
  • Effectual Angle: <15°
  • Ranging Distance : 2cm – 400 cm/1″ – 13ft
  • Resolution : 0.3 cm
  • Measuring Angle: 30 degrees
  • Trigger Input Pulse width: 10uS
  • Dimension: 45mm x 20mm x 15mm

 

Ultrasonic Sensor emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board.In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward.  So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2.

 

You can see datasheet here.

Signals and connections of HC-SR04 Ultrasonic Module

"Trig" stands for Trigger Pulse Input

"Echo" stands for Echo Pulse Output

"VCC" stands for power supply (+5V)

"GND" stands for GND (0V)

Duration for the sound to reach echo is twice the duration required to reach the object that will create echo. That is if you shout in front of a wall the voice to reaches the wall and returns back to your ear. The moment you hear the sound, the voice has traveled twice the distance between you and the wall. Thus the time taken will be twice as the speed of sound is constant. Hence the following formula:

d = v/t;

therefore d = 29 / (time in miliseconds / 2).

or d = 340 / (time in seconds / 2).

Wiring

The following picture shows the needed connections with the Arduino Uno 

Step by Step instruction

  1. Plug your Adruino Uno board into your PC and select the correct board and com port
  2. Open up serial monitor and set your baud to 9600 baud
  3. Verify and upload the the sketch to your Adruino Uno
  4. If you move the sensor the distance will change in serial monitor window

Libraries:

  • See attachments on the begining of this project description - all libraries included.

Program/Sketch

  • See attachment on the begining of this project description.


Other projects of Acoptex.com
Easy Merry Xmas to everyone of Acoptex.com, Not selected 24-12-2019

Published at 02-07-2017
Viewed: 720 times