learn and build innovative projects

Distance Measurement Using Ultrasonic Sensor (Hc-Sr04) And Arduino

No comments :
Distance Measurement Using Ultrasonic Sensor (Hc-Sr04)  And Arduino 

The Arduino is connected to an HC-SR04 ultrasonic sensor, enabling the measurement of distances within a short range, spanning from 2 cm to 400 cm or 1 inch to 13 feet. This adaptable project finds utility in tasks like water level measurement and distance measurement. The HC-SR04 sensor excels in non-contact range detection, providing high accuracy and consistent readings in a user-friendly design. Importantly, its performance remains unaffected by sunlight or material color, distinguishing it from Sharp rangefinders. The HC-SR04 comprises both an ultrasonic transmitter and a receiver module.

Components Required:

  •  Arduino Uno with USB 2.0 Cable
  •  Ultrasonic Sensor(HC-SR04)
  •  Jumper Wires
  •  Breadboard

Arduino Uno with USB 2.0 Cable:

Arduino is a user-friendly, open-source electronics platform comprising both hardware and software components. Its design is geared towards enabling individuals involved in creating interactive projects.
Distance Measurement Using Ultrasonic Sensor And Arduino, IoT Projects. Interfacing Arduino and HC-SR04 ultrasonic sensor to measure distance with in the short range from 2 cm to 400 cm or 1” to 13 feet. We can use this project like water level measurement, distance measurement etc. ultrasonic sensor comes with ultrasonic transmitter and receiver module.


Ultrasonic Sensor:

The Ultrasonic sensor HC-SR04 is employed in this setup to measure distances within a range of 2 cm to 400 cm. This is achieved through the transmission and reception of ultrasonic waves. The transmitter emits an ultrasonic wave, and the sensor calculates the distance by measuring the time duration between sending the signal and receiving its reflection from the target.

distance can be calculated by using formula:

Distance=(Time duration/2)* Speed of sound in air
(speed of sound in air is about 343 meters per second)

Ultrasonic sensor HC-SR04 is used here to measure distance in range of 2 cm - 400 cm based on transmitting and receiving ultrasonic waves. Transmitter emits an ultrasonic wave and receives the wave reflected back from the target. It measure the distance by measuring the time duration between sending and receiving the signal.

Specifications (HC_SR04):

  • 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

Jumper Wires:

A jumper wire is an electrical wire equipped with connectors or pins at each end. It is commonly employed to interconnect components without the need for soldering, providing a convenient method for establishing electrical connections between different parts of a circuit.A jumper wire is an electrical wire with a connector or pin at each end, which is normally used to interconnect the components  each other without soldering.

Breadboard:

A breadboard is a solderless device for temporary prototyping of electronics. It is used to interconnection between sensors and hardware boards using jumper wires.

A breadboard is a solderless device for temporary prototyping of electronics. It is used to interconnection between sensors and hardware boards using jumper wires.

Connection Diagram:

Connect your components according to the provided diagram and link the USB cable from Arduino to your computer.

Connect your components using jumper wires to Arduino

Arduino Code:

#define trigPin 12
#define echoPin 11
// defines variables 
int duration, distance;

void setup ()
{
Serial.begin(9600); // Starts the serial communication
pinMode(trigPin, OUTPUT);// Sets the trigPin as an Output
pinMode(echoPin, INPUT);// Sets the echoPin as an Input
Serial.print("Ultrasonic Sensor Starting!!!");
Serial.println("");
delay(1000);
}
void loop ()
{
// Clears the trigPin
digitalWrite(trigPin, HIGH);
delay(1000);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance =(duration/2) * 0.0343; // Calculating the distance in cm

// Prints the distance on the Serial Monitor
Serial.print("Distance = ");
Serial.print(distance);
Serial.println(" cm");
delay(1000);
}

Upload Code:
Connect Arduino board to computer using USB cable and wait for few seconds then it will show you "Com port". 

Check your Com Port and Board Selection before upload arduino code and upload.

Com Port and Board Selection before upload arduino code

Output:

distance measurement using ultrasonic sensor


Additional Projects:

No comments :

Post a Comment

Internet of Things

What is Internet of Things?

What is IoT? The Internet of Things (IoT) is the network of physical objects/things are embedded with software, sensors, and hardw...