Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
23 views39 pages

Final

Uploaded by

gana888t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views39 pages

Final

Uploaded by

gana888t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 39

A Project Report on

SECURITY SYSTEM USING HC-SR04


Submitted in fulfillment of requirements for the award of degree

BACHELOR OF TECHNOLOGY

by

GUMMALLA HIMAJA(O191065)
YALAPALA LOKESH(O190318)
ABBURI SIVATEJA(O190833)
BOYAPATI ANITHA(O190114)
YERRAGUNDU HIMAJA(O190980)

Under the Guidance of

Ms.B.SHARON LILLY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

RAJIV GANDHI UNIVERISTY OF KNOWLEDGE AND TECHNOLOGIES

ONGOLE CAMPUS

(2023-2024)

i
APPROVAL SHEET

This Thesis Report entitled SECURITY SYSTEM USING HC-SR04 by Gummalla


Himaja(O191065) , Yalapala Lokesh(O190318), Abburi Sivateja(O190833), Boyapati
Anitha(O190114), Yerragundu Himaja(O190980) is approved for the degree of Bachelor of
Technology in Electronics and Communication Engineering.

Examiner(s): _________________

Supervisor(s): _________________
Chairman: ______________________

Date: ________________
Place: ________________

ii
DECLARATION

We declare that, this written submission represents our ideas in our own words
and where other ideas or words have been included. We have cited and referenced
the original sources.We also declare that, We have adhered to all principles of
academic honesty and integrity and have not misrepresented or fabricated or
falsified any idea/data/fact/source in my submission. I understood that any
violation of the above will be cause for disciplinary action by the Institute and
can also evoke penal action from the sources which have thus not been properly
cited or from proper permission has not been taken.

SIGNATURE
Gummalla Himaja(O191065)

Yalapala Lokesh(O190318)

Abburi Sivateja(O190833)

Boyapati Anitha(O190114)

Yerragundu Himaja(O190980)

DATE: _______________

PLACE: _______________

iii
CERTIFICATE

This is to certify that the report entitled "SECURITY SYSTEM USING HC-

SR04" submitted by Gummalla Himaja(O191065), Yalapala Lokesh(O190318), Abburi


Sivateja (O190833), Boyapati Anitha(O190114),Yerragundu Himaja(O190980) respectively
in partial fulfillment of the requirement for the award of Bachelor of Technology in Electronics
and Communication Engineering in an Bonafide work carried by them under my supervision
and Guidance.

Head of Department(HOD)

Mr.V.Prasannanjaneya Reddy

iv
ACKNOWLEDGEMENT

We take this opportunity to express our sincere gratitude to all those supported and guided us
throughout the completion of our mini project.

Firstly, we wish our deepest sense of gratitude and respect to our guide Ms.B.Sharon

lilly madam for her constant support, invaluable mentorship, guidance and insightful
feedback. The constant encouragement and timely suggestion have helped us to complete this
mini project.

We extend our heartful thankfulness to head of department of ECE Mr .V.


Prasannanjaneya Reddy sir for his support and encouragement. We would like to
acknowledge the sir's encouragement and expertise in shaping our project and ensuring its
successful execution.

We would like to extend our gratitude to RAJIV GANDHI UNIVERSITY OF

KNOWLEDGE AND TECHNOLOGIES(RGUKT), ONGOLE for providing


all the resources and facilities for the completion of the project successfully.

We are thankful to our team mates and other classmates for their constructive support. We
are also grateful to family for their constant encouragement and support, which motivated us
to complete this project successfully.

WITH SINCERE REGARDS

GUMMALLA HIMAJA(O191065)

YALAPALA LOKESH(O190318)

ABBURI SIVATEJA(O190833)

BOYAPATI ANITHA(O190114)

YERRAGUNDU HIMAJA(O190980)

v
ABSTRACT

In an increasingly interconnected world, ensuring the security of our homes and properties has
become a paramount concern. This project introduces a cutting-edge IOT-based security
system that leverages sonar technology to enhance real-time threat detection and surveillance.

The Sonar-Based Security System utilizes ultrasonic sensors to detect and locate moving
objects in a defined area. By emitting sound waves and analyzing their reflections, the system
can accurately determine the size, distance, and direction of potential intruders. By analyzing
the patterns and changes in the sound waves, the system can accurately identify and track
moving objects, including humans, vehicles, or even animals.

This technology is not dependent on light or weather conditions, making it ideal for all
environments. Furthermore, the use of sonar technology allows for 24/7 monitoring, making it
immune to visual obstructions, such as fog or darkness.

The system employs ultrasonic sensors to create a 360-degree detection field, detecting even
subtle movements and intrusions within a defined perimeter. The Processing-3.5.4 software
gives the graphical representation and it also gives the angle or position and distance of the
object .When the intrusion is detected within the defined perimeter, then the system triggers
the buzzer(alert).

This project aims to enhance security measures for a wide range of applications, from home
security and industrial facilities to border surveillance, navigation, positioning, object
identification, mapping, spying etc.

vi
TABLE OF CONTENTS

CHAPTER 1 INTRODUCTION.......................................................................................1-5

1.1 Introduction..........................................................................................................1-2

1.2 Background......................................................................................................... 2-3

1.3 Project Objectives................................................................................................3

1.4 Scope...................................................................................................................3-4

CHAPTER 2 MATERIALS&THEORY............................................................................6-16

2.1 IOT (Internet Of Things).......................................................................................6-12

2.2 Requirements.........................................................................................................12-15

2.3 Block diagram.......................................................................................................16

CHAPTER 3 METHODOLOGY......................................................................................17-19

3.1 Proposed method...................................................................................................17

3.2 Working principle.................................................................................................18-19

CHAPTER4 CODE...........................................................................................................20-27

4.1 Arduino code.........................................................................................................20-22

4.2 Processing IDE code...............................................................................................23-27

CHAPTER 5 RESULT,SUMMARY&CONCLUSIONS.................................................28-30

5.1 Results.....................................................................................................................28

5.2 Summary................................................................................................................38-29

5.3 Conclusion..............................................................................................................29-30

REFERENCES..................................................................................................................31

vii
TABLE OF FIGURES

Figure-2.1 Internet of things…………………………………………………6


Figure-2.2 IOT Architecture…………………………………………………7
Figure-2.3 Servomotor………….……………………………………………..12
Figure-2.4 Ultrasonic Sensor…………………………………………………13
Figure-2.5 Arduino UNO……………………………………………………..14
Figure-2.6 Buzzer……………………………………………………………..14
Figure-2.7 Jumper Wires…………………………………………………….…15
Figure-2.8 Block diagram……………………….………………………….…16
Figure-3.1 Architecture……….…………………………………………….…17
Figure-5.1 The Result…………………………………………………………28

viii
CHAPTER 1
INTRODUCTION

1.1 INTRODUCTION
IoT stands for Internet of Things. It refers to the interconnectedness of physical devices, such
as appliances and vehicles, that are embedded with software, sensors, and connectivity which
enables these objects to connect and exchange data. This technology allows for the collection
and sharing of data from a vast network of devices, creating opportunities for more efficient
and automated systems.

Internet of Things (IoT) is the networking of physical objects that contain electronics embedded
within their architecture in order to communicate and sense interactions amongst each other or
with respect to the external environment. In the upcoming years, loT-based technology will
offer advanced levels of services and practically change the way people lead their daily lives.
Advancements in medicine, power, gene therapies, agriculture, smart cities, and smart homes
are just a very few of the categorical examples where lot is strongly established.

lot is network of interconnected computing devices which are embedded in everyday objects,
enabling them to send and receive data. Over 9 billion 'Things' (physical objects) are currently
connected to the Internet, as of now. In the near future, this number is expected to rise to a
whopping 20 billion.

HC-SR04 is an ultrasonic sensor mainly used to determine the distance of the target object. It
measures accurate distance using a non-contact technology. A technology that involves no
physical contact between sensor and object. Transmitter and receiver are two main parts of the
sensor where former converts an electrical signal to ultrasonic waves while later converts that
ultrasonic signals back to electrical signals.

HC-SRO4 is an ultrasonic sensor contains four pins. They are

1)VCC The power supply pin of the sensor that mainly operates at 5V DC.

2) Trig Pin It plays a vital role to initialize measurement for sending ultrasonic waves. It
should be kept high for 10us for triggering the measurement.

1
3) Echo Pin This pin remains high for short period based on the time taken by the ultrasonic
waves to bounce back to the receiving end. 4)Ground This pin is connected to ground.

In this lot project, we’ve developed a cutting-edge security system using ultrasonic sensors.
These sensors utilize high-frequency sound waves to detect and monitor the physical
environment in real-time. Our system leverages this technology to create a robust and
responsive security solution. By measuring the time it takes for ultrasonic waves to bounce off
objects, we can detect intruders, monitor room occupancy, and ensure the safety of your
premises. Through remote connectivity and data analysis, this system offers you an intelligent
and efficient way to protect your space.

Ultrasonic technology is particularly well-suited for security systems because it is non-


intrusive ,non-contact, and provides high accuracy in detecting objects within its field of view.
This technology forms the foundation of our security system, ensuring its reliability. By using
the HC SR04 sensor as the core element, we aim to create a cost-effective yet robust solution
for enhancing security in various environments.

In summary, this project seeks to harness the capabilities of the HC-SR04 ultrasonic sensor to
create a versatile, cost-effective, and customizable security system that addresses the pressing
need for enhanced security in today’s world. By the end of this journey, we aim to have a
functional security solution that can be tailored to various scenarios while maintaining the
highest standards of privacy and legality.

1.2 BACKGROUND

In an era marked by increasing security concerns, the development of robust and affordable
security systems has become paramount. The project at hand is a step towards addressing this
need, as it aims to create a reliable security system utilizing the HC-SRO4 ultrasonic sensor.
At the heart of this project is the HC-SRO04 ultrasonic sensor, which employs ultrasonic waves
to accurately measure distances. This versatile sensor has gained popularity due to its
simplicity, precision, and affordability, making it an ideal choice for a security application.

As we embark on this journey, it is imperative to bear in mind the ethical and legal aspects of
surveillance. The system will be designed with privacy and security in mind, adhering to legal
requirements and ensuring user data remains confidential. The beauty of this project lies in its

2
flexibility. It allows for customization and scalability. Users can adapt it to suit their specific
security needs and environment, whether it's for home security, workplace monitoring, or other
applications.

Throughout the project, we will meticulously document the development process, offering a
detailed guide for those interested in replicating or further improving upon our system.

1.3 PROJECT OBJECTIVES

1. Remote Monitoring:

Access the lot platform from a web browser or mobile app to view real-time data from the
security system. Implement alerting mechanisms, such as email notifications or push
notifications, when an intruder is detected.

2. Security Features:

Consider adding features like user authentication and encryption to secure the loT
communication between the Arduino and the cloud platform.

3.User Interface:

Develop a user-friendly interface for controlling and configuring the security system, which
can be accessed through a web or mobile app. Remember that security is a critical aspect, and
you should consider both the hardware and software security aspects of your lot project to
prevent unauthorized access or tampering with the system.

4.Extensible platform for future enhancement:

With a strong existing possibility of adding and integrating more features and applications to
the system, the designed system needs to be highly extensible in nature.

3
1.4 SCOPE
Exploring the future scope of "security system using HC-SR04" project opens up a realm of
possibilities for enhancements and advancements. Here's a detailed look at potential future
directions for this project.

1. Machine Learning Integration:

Incorporate machine learning algorithms for advanced threat detection and recognition. Train
the system to distinguish between different types of intruders or objects, reducing false
alarms.

2. Al-based Automation:

Implement artificial intelligence to automate security responses. For example, the system
could automatically alert authorities or trigger additional security measures in response to
specific threat levels.

3. Mobile Application Development:

Create a dedicated mobile application that provides real-time alerts, remote control of the
security system, and access to historical data. Ensure compatibility with both Android and
iOS platforms.

4.Integration with emergency alarms:

Connect the security system to emergency alarms, such as fire alarms or medical alerts, to
provide a holistic security and safety solution.

5. Geofencing and GPS Integration:

Implement geofencing capabilities, so the system can automatically arm or disarm itself
based on the user's location. Additionally, incorporate GPS tracking for asset security.

6. Emergency Services Integration:

Establish direct communication with emergency services (police, fire, medical) in case of
security breaches, enabling faster response times.

7.Border Security

For border security, especially in remote or rugged terrains, sonar systems can provide

4
effective monitoring of large areas, helping identify illegal border crossing.

8.Perimeter Security

It can be extended to create a protective perimeter around sensitive areas such as military
bases, power plants, or research facilities. It can detect intruders attempting to breach a
physical barrier like a fence or wall.

9.Home Security:

This project can be developed further by adding a GSM module to the circuit It is designed to
ensure a wireless home security. This system detects unauthorized movement, triggers an
audible alarm, and sends SMS notifications to the user, ensuring enhanced security.

As technology continues to advance, the future of a "security system using HC-SR04" project
is filled with opportunities for innovation, automation, and integration into broader smart
home and security ecosystems. Adaptability and ongoing development will be key to staying
at the forefront of security technology.

5
CHAPTER 2
MATERIALS &THEORY

2.1 IOT(INTERNET OF THINGS)


IoT stands for Internet of Things, which means accessing and controlling daily usable
equipments and devices using Internet.

Connecting everyday things embedded with electronics, software, and sensors to internet
enabling to collect and exchange data without human interaction called as the Internet of
Things (IoT).

The term "Things" in the Internet of Things refers to anything and everything in day to day life
which is accessed or connected through the internet.

Figure 2.1 Internet of things

IoT is an advanced automation and analytics system which deals with artificial intelligence,
sensor, networking, electronic, cloud messaging etc. to deliver complete systems for the
product or services. The system created by IoT has greater transparency, control, and
performance.

6
2.1.1 ARCHITECTURE OF IOT

The working of IoT is different for different IoT echo system (architecture). However, the key
concept of there working are similar. The entire working process of IoT starts with the device
themselves, such as smartphones, digital watches, electronic appliances, which securely
communicate with the IoT platform. The platforms collect and analyze the data from all
multiple devices and platforms and transfer the most valuable data with applications to devices.

Figure 2.2 IOT Architecture

2.1.2 FEATURES OF IOT


The most important features of IoT on which it works are connectivity, analyzing, integrating,
active engagement, and many more. Some of them are listed below:

Connectivity: Connectivity refers to establish a proper connection between all the things of
IoT to IoT platform it may be server or cloud. After connecting the IoT devices, it needs a high
speed messaging between the devices and cloud to enable reliable, secure and bi-directional
communication.

7
Analyzing: After connecting all the relevant things, it comes to real-time analyzing the data
collected and use them to build effective business intelligence. If we have a good insight into
data gathered from all these things, then we call our system has a smart system.

Integrating:

IoT integrating the various models to improve the user experience as well.

Artificial Intelligence:

IoT makes things smart and enhances life through the use of data. For example, if we have a
coffee machine whose beans have going to end, then the coffee machine itself order the coffee
beans of your choice from the retailer.

Sensing:

The sensor devices used in IoT technologies detect and measure any change in the environment
and report on their status. IoT technology brings passive networks to active networks. Without
sensors, there could not hold an effective or true IoT environment.

Active Engagement:

IoT makes the connected technology, product, or services to active engagement between each
other.

Endpoint Management:

It is important to be the endpoint management of all the IoT system otherwise, it makes the
complete failure of the system. For example, if a coffee machine itself order the coffee beans
when it goes to end but what happens when it orders the beans from a retailer and we are not
present at home for a few days, it leads to the failure of the IoT system. So, there must be a
need for endpoint management.

8
2.1.3 ADVANTAGES AND DISADVANTAGES OF IOT

Any technology available today has not reached to its 100 % capability. It always has a gap to
go. So, we can say that Internet of Things has a significant technology in a world that can help
other technologies to reach its accurate and complete 100 % capability as well.

Advantages:

1. Efficiency Improvement:
IoT enhances efficiency by automating tasks, optimizing processes, and reducing
human intervention.

2. Data Collection and Analysis:


It enables the collection of vast amounts of data from various sources, facilitating
better decision-making and insights through data analytics.

3. Remote Monitoring and Control:


Devices can be monitored and controlled remotely, offering convenience and
accessibility from anywhere with an internet connection.

4. Improved Customer Experience:


IoT enables personalized and tailored experiences for consumers, leading to
enhanced satisfaction and engagement.

5. Cost Savings:
Automation and optimization through IoT often lead to cost reductions in various
industries, such as energy savings, predictive maintenance, and resource management.

6. Innovation and New Opportunities:


IoT fosters innovation, creating new business models, products, and services across
different sectors.

9
Disadvantages:

1.Security Concerns:

With the increased connectivity, IoT devices are susceptible to cyber threats and
data breaches if not adequately secured.

2.Privacy Issues:

Collecting vast amounts of personal data raises concerns about privacy and the
potential misuse or unauthorized access to sensitive information.

3. Complexity and Interoperability:

Integrating various IoT devices and platforms can be complex, especially when
different systems need to communicate with each other seamlessly.

4. Reliability and Compatibility:

Reliability issues can arise due to device malfunctions, connectivity problems, or


compatibility issues between different IoT devices or systems.

5.Data Overload:

Managing and analyzing the enormous volume of data generated by IoT devices
can be overwhelming, requiring efficient storage and processing capabilities.

6. Dependency on Connectivity:

IoT devices heavily rely on a stable internet connection. Any disruption in connectivity can
affect their functionality.

10
2.1.4 APPLICATIONS OF IOT

WEARABLES

Wearable technology is the hallmark of IoT applications and one of the earliest industries to
deploy IoT. We have fit bits, heart rate monitors and smartwatches these days.

Guardian glucose monitoring device has been developed to help people with diabetes. It detects
glucose levels in our body, uses a small electrode called the glucose sensor under the skin, and
relates it to a radiofrequency monitoring device.

2. SMART HOMES

The smart home is probably the first thing when we talk about the IoT application. The example
we see the AI home automation is employed by Mark Zuckerberg. Alan Pan's home automation
system, where a string of musical notes uses in-house functions.

3.HEALTH CARE

IoT applications can transform reactive medical-based systems into active wellness-based
systems. Resources that are used in current medical research lack important real-world
information. It uses controlled environments, leftover data, and volunteers for clinical trials.
The Internet of Things improves the device's power, precision and availability. IoT focuses on
building systems rather than just tools. Here's how the IoT-enabled care device works.

4.AGRICULTURE

By the year 2050, the world's growing population is estimated to have reached about 10 billion.
To feed such a large population, agriculture needs to marry technology and get the best results.
There are many possibilities in this area. One of them is Smart Greenhouse.Farming techniques
grow crops by environmental parameters. However, manual handling results in production
losses, energy losses and labour costs, making it less effective. The greenhouse makes it easy
to monitor and enables to control the climate inside it.

5.INDUSTRIAL AUTOMATION

It is one of the areas where the quality of products is an essential factor for a more significant
investment return. Anyone can re-engineer products and their packaging to provide superior

11
performance in cost and customer experience with IoT applications. IoT will prove as a game-
changer. In industrial automation, IoT is used in the following areas:

o Product flow monitoring


o Factory digitization
o Inventory management
o Safety and security
o Logistics and Supply Chain Optimization
o Quality control
o Packaging customization

2.2REQUIREMENTS
2.2.1 SERVO MOTOR
A servo motor is a type of rotary actuator that allows for precise control of angular position,
velocity, and acceleration. It uses feedback to accurately position the motor shaft, making it an
ideal choice for applications that require precise and repeatable movement. A servo motor
consists of a DC motor, a control circuit, and a position feedback device such as a
potentiometer. The control circuit receives signals from a controller and adjusts the motor's
rotation to achieve the desired position. Servo motors are widely used in robotics, automation,
and other industries that require precise control of motion.

Figure 2.3 Servomotor

12
2.2.2 ULTRASONIC SENSOR
An ultrasonic sensor is a device that uses sound waves at a frequency higher than the human
ear can detect to measure distance or detect objects. It emits a high-frequency sound wave and
then measures the time it takes for the wave to bounce back after hitting an object, which can
be used to determine the distance to that object. Ultrasonic sensors are commonly used in
industrial automation, automotive, and security systems for object detection, obstacle
avoidance, and distance measurement. They are reliable, accurate, and can detect objects
regardless of their color or transparency.

Figure 2.4 Ultrasonic sensor

2.2.3 ARDUINO UNO


The Arduino UNO is a standard board of Arduino. Here UNO means 'one' in Italian. It was
named as UNO to label the first release of Arduino Software. It was also the first USB board
released by Arduino. It is considered as the powerful board used in various projects. Arduino.cc
developed the Arduino UNO board. Arduino UNO is based on an
ATmega328P microcontroller. It is easy to use compared to other boards, such as the Arduino
Mega board, etc. The board consists of digital and analog Input/Output pins (I/O), shields, and
other circuits. The Arduino UNO includes 6 analog pin inputs, 14 digital pins,
a USB connector, a power jack, and an ICSP (In-Circuit Serial Programming) header. It is
programmed based on IDE, which stands for Integrated Development Environment. It can run
on both online and offline platforms.

13
Figure 2.5 Arduino UNO

2.2.4 BUZZER

Buzzers are electric sounding devices that generate sounds. Typically powered by DC
voltage, they can be categorized as Piezo buzzer and magnetic buzzer. They come in different
designs and uses as well, and based on that, they can produce different sounds.

Figure 2.6 Buzzer

14
2.2.5 JUMPER WIRES

Jumper wires are simply wires that have connector pins at each end, allowing them to be used
to connect two points to each other without soldering. Jumper wires are typically used with
breadboards and other prototyping tools in order to make it easy to change a circuit as needed.
Fairly simple. In fact, it doesn’t get much more basic than jumper wires.

Figure 2.7 Jumper wires

15
2.3 BLOCK DIAGRAM

Figure 2.8 Block diagram

16
CHAPTER -3
METHODOLOGY

3.1 SECURITY SYSTEM USING HC-SR04

3.1.1.PROPOSED METHOD

The primary goal of this project is to design and implement a cost- effective security system
using an ultrasonic sensor(HC-SR04) to detect intrusions or movements within a defined
parameter. The proposed aim to develop an efficient and budget friendly security surveillance
system utilizing sonar technology. This system will be used to detect the unauthorized access
within a specified range and trigger an alert through the buzzer or alarm. The entire perimeter
range can be displayed on the monitor and it displays the position, distance of the intrusions,
unauthorized access, presence of objects in that defined range.

3.1.2 DESIGN

Figure 3.1 Architecture

17
3.1.3. WORKING PRINCIPLE
This security system utilizing an ultrasonic senor and buzzer operates on the principle of
detecting objects within a certain range using sound waves. The working principle revolves
around the ultrasonic sensor, which emits high frequency sounds which are inaudible to human
ears( around 20 kHz to several MHz).The ultrasonic sensor works on the principle of SONAR
and RADAR system which is used to determine the distance of the object. When an electrical
pulse of high voltage is applied to the ultrasonic sensor transducer it vibrates across a specific
spectrum of frequencies and generates a burst of sound waves .

Whenever an obstacle comes ahead of the ultrasonic sensor the sound waves will
reflect back in the form of echo and generates an electric pulse. It calculates the time taken
between sending sound waves and receiving the echo.

This setup is commonly used in various applications, including home security, object detection
systems etc. The ultrasonic sonar system is an effective way to identify objects within its field
of view. By using sound waves, an ultrasonic sensor can detect the presence of objects in the
environment. In this system, a ultrasonic sensor is placed on the servo motor, providing
complete 360° coverage.

The data collected by the sensors is processed using the Processing IDE, which creates
a visual representation of the environment. This feature can be used for remote monitoring or
surveillance. Finally, the system includes an alerting mechanism that can be triggered if an
object is detected within a certain range. The ultrasonic sonar system has a wide range of
potential applications, including robotics, security, and environmental monitoring.

WORKING

➢ When we give the power supply, the servo motor starts to rotate from 0 to 360 degrees.

➢ At the same time, the ultrasonic sensor start to work and scan the areas within their range
and detect the objects by sending sound waves.

➢ The Ultrasonic sensor rotates from 0 to 360 degrees ,after completing one cycle then it
rotates 360 to 0 degrees.

➢ If the object is in the range of the ultrasonic sensor and the object comes too close then the
buzzer starts to ring and indicates the angle and distance of the object in the Processing IDE.

18
➢ If the object is not in the range of the ultrasonic sensor then the interface will become
green and this process continues.

ULTRASONIC SENSOR OUTPUT


➢ Ultrasonic sonar sensors work on the principle called Trigger and Echo, the transmitter sends
a bunch of

pulses and gets reflected if any object is detected.

➢ We can calculate the distance of the object by using the formula Distance=(speed*time)/2.

19
CHAPTER 4
CODE

4.1 ARDUINO CODE


// Includes the Servo library

#include <Servo.h>.

// Defines Tirg and Echo pins of the Ultrasonic Sensor

const int trigPin = 10;

const int echoPin = 11;

// Variables for the duration and the distance

long duration;

int distance;

Servo myServo; // Creates a servo object for controlling the servo motor

void setup() {

pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output

pinMode(echoPin, INPUT); // Sets the echoPin as an Input

Serial.begin(9600);

myServo.attach(12); // Defines on which pin is the servo motor attached

void loop() {

// rotates the servo motor from 15 to 165 degrees

for(int i=15;i<=165;i++){

myServo.write(i);

delay(30);

distance = calculateDistance();// Calls a function for calculating the distance measured by


the Ultrasonic sensor for each degree

20
Serial.print(i); // Sends the current degree into the Serial Port

Serial.print(","); // Sends addition character right next to the previous value needed later in
the Processing IDE for indexing

Serial.print(distance); // Sends the distance value into the Serial Port

Serial.print("."); // Sends addition character right next to the previous value needed later in
the Processing IDE for indexing

// Repeats the previous lines from 165 to 15 degrees

for(int i=165;i>15;i--){

myServo.write(i);

delay(30);

distance = calculateDistance();

Serial.print(i);

Serial.print(",");

Serial.print(distance);

Serial.print(".");

// Function for calculating the distance measured by the Ultrasonic sensor

int calculateDistance(){

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH); // Reads the echoPin, returns the sound wave travel
time in microseconds

21
distance= duration*0.034/2;

return distance;

4.2 PROCESSING IDE CODE


import processing.serial.*; // imports library for serial communication

import java.awt.event.KeyEvent; // imports library for reading the data from the serial port

import java.io.IOException;

Serial myPort; // defines Object Serial

// defubes variables

String angle="";

String distance="";

String data="";

String noObject;

float pixsDistance;

int iAngle, iDistance;

int index1=0;

int index2=0;

PFont orcFont;

void setup() {

size (1200, 700); // ***CHANGE THIS TO YOUR SCREEN RESOLUTION***

smooth();

myPort = new Serial(this,"COM5", 9600); // starts the serial communication

myPort.bufferUntil('.'); // reads the data from the serial port up to the character '.'. So actually
it reads this: angle,distance.

void draw() {

22
fill(98,245,31);

// simulating motion blur and slow fade of the moving line

noStroke();

fill(0,4);

rect(0, 0, width, height-height*0.065);

fill(98,245,31); // green color

// calls the functions for drawing the radar

drawRadar();

drawLine();

drawObject();

drawText();

void serialEvent (Serial myPort) { // starts reading data from the Serial Port

// reads the data from the Serial Port up to the character '.' and puts it into the String variable
"data".

data = myPort.readStringUntil('.');

data = data.substring(0,data.length()-1);

index1 = data.indexOf(","); // find the character ',' and puts it into the variable "index1"

angle= data.substring(0, index1); // read the data from position "0" to position of the
variable index1 or thats the value of the angle the Arduino Board sent into the Serial Port

distance= data.substring(index1+1, data.length()); // read the data from position "index1" to


the end of the data pr thats the value of the distance

// converts the String variables into Integer

iAngle = int(angle);

iDistance = int(distance);

void drawRadar() {

23
pushMatrix();

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

noFill();

strokeWeight(2);

stroke(98,245,31);

// draws the arc lines

arc(0,0,(width-width*0.0625),(width-width*0.0625),PI,TWO_PI);

arc(0,0,(width-width*0.27),(width-width*0.27),PI,TWO_PI);

arc(0,0,(width-width*0.479),(width-width*0.479),PI,TWO_PI);

arc(0,0,(width-width*0.687),(width-width*0.687),PI,TWO_PI);

// draws the angle lines

line(-width/2,0,width/2,0);

line(0,0,(-width/2)*cos(radians(30)),(-width/2)*sin(radians(30)));

line(0,0,(-width/2)*cos(radians(60)),(-width/2)*sin(radians(60)));

line(0,0,(-width/2)*cos(radians(90)),(-width/2)*sin(radians(90)));

line(0,0,(-width/2)*cos(radians(120)),(-width/2)*sin(radians(120)));

line(0,0,(-width/2)*cos(radians(150)),(-width/2)*sin(radians(150)));

line((-width/2)*cos(radians(30)),0,width/2,0);

popMatrix();

void drawObject() {

pushMatrix();

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

strokeWeight(9);

stroke(255,10,10); // red color

pixsDistance = iDistance*((height-height*0.1666)*0.025); // covers the distance from the


sensor from cm to pixels

24
// limiting the range to 40 cms

if(iDistance<40){

// draws the object according to the angle and the distance

line(pixsDistance*cos(radians(iAngle)),-pixsDistance*sin(radians(iAngle)),(width-
width*0.505)*cos(radians(iAngle)),-(width-width*0.505)*sin(radians(iAngle)));

popMatrix();

void drawLine() {

pushMatrix();

strokeWeight(9);

stroke(30,250,60);

translate(width/2,height-height*0.074); // moves the starting coordinats to new location

line(0,0,(height-height*0.12)*cos(radians(iAngle)),-(height-
height*0.12)*sin(radians(iAngle))); // draws the line according to the angle

popMatrix();

void drawText() { // draws the texts on the screen

pushMatrix();

if(iDistance>40) {

noObject = "Out of Range";

else {

noObject = "In Range";

fill(0,0,0);

noStroke();

25
rect(0, height-height*0.0648, width, height);

fill(98,245,31);

textSize(25);

text("10cm",width-width*0.3854,height-height*0.0833);

text("20cm",width-width*0.281,height-height*0.0833);

text("30cm",width-width*0.177,height-height*0.0833);

text("40cm",width-width*0.0729,height-height*0.0833);

textSize(40);

text("Indian Lifehacker ", width-width*0.875, height-height*0.0277);

text("Angle: " + iAngle +" °", width-width*0.48, height-height*0.0277);

text("Distance: ", width-width*0.26, height-height*0.0277);

if(iDistance<40) {

text(" " + iDistance +" cm", width-width*0.225, height-height*0.0277);

textSize(25);

fill(98,245,60);

translate((width-width*0.4994)+width/2*cos(radians(30)),(height-height*0.0907)-
width/2*sin(radians(30)));

rotate(-radians(-60));

text("30°",0,0);

resetMatrix();

translate((width-width*0.503)+width/2*cos(radians(60)),(height-height*0.0888)-
width/2*sin(radians(60)));

rotate(-radians(-30));

text("60°",0,0);

resetMatrix();

translate((width-width*0.507)+width/2*cos(radians(90)),(height-height*0.0833)-

26
width/2*sin(radians(90)));

rotate(radians(0));

text("90°",0,0);

resetMatrix();

translate(width-width*0.513+width/2*cos(radians(120)),(height-height*0.07129)-
width/2*sin(radians(120)));

rotate(radians(-30));

text("120°",0,0);

resetMatrix();

translate((width-width*0.5104)+width/2*cos(radians(150)),(height-height*0.0574)-
width/2*sin(radians(150)));

rotate(radians(-60));

text("150°",0,0);

popMatrix();

27
CHAPTER 5
RESULTS, SUMMARY&CONCLUSIONS

5.1 RESULT

Figure 5.1 The Result

The experimental model was made according to the circuit diagram and the results were as
expected. The traditional security systems could be remotely switched over this security system
using HC SR-04. Both the arduino code and processing IDE code were success fully achieved
successfully. The Graphical User Interface(GUI) was successfully displayed on the monitor
and described the information about the distance, angle and position of the object.

5.2 SUMMARY

In this project we get to know how a security system works using sonar technology. Here, we
designed the project SECURITY SYSTEM USING HC-SR04 AND ARDUIO. This project
will help us to improve ourselves through technologies and one of the main trending
28
technologies in now-a-days is IOT(Internet of Things),where we can link every day work to
the internet ,where we can control everything through our mobiles or laptops or any other
devices.

This technology makes our day to day life very flexible and comfortable. In our project, the
security system utilizes an ultrasonic sensor which moves 0 to 360 degrees with the help of
servomotor, to detect movement within a defined range. When triggered, the sensor sends
signals to the arduino initiating an alarm through a buzzer and we can display this interface on
the monitor which shows red whenever an object or intrusions present in that particular defined
range. This system offers a cost-effective and reliable method for detecting intrusions or
movement within a designated area. Its simplicity in design and implementation makes it a
valuable addition to home or small-scale security setups.

5.3 CONCLUSIONS:

In conclusion, the integration of a security system utilizing sonar-based technology represents


a pivotal advancement in safeguarding various environments. The implementation of this
system offers a multifaceted approach to security, leveraging the power of sound waves for
robust monitoring and threat detection.

By harnessing sonar technology, this security system demonstrates unparalleled


effectiveness in detecting and tracking movements within designated areas. Its ability to
operate in diverse conditions, including low light or adverse weather, provides a reliable
solution for continuous surveillance, ensuring a higher level of security around the clock.

Furthermore, the non-intrusive nature of sonar-based sensors minimizes false alarms,


enhancing the system's accuracy and reducing unnecessary disruptions. Its versatility extends
beyond traditional security applications, finding utility in areas such as perimeter defense, asset
protection, and even in underwater surveillance.

However, as with any technology, ongoing research and development are crucial to
enhance its capabilities, address potential limitations, and adapt to evolving security threats.
Collaborative efforts between experts in the fields of sonar technology, signal processing, and
cybersecurity are imperative to continuously refine and optimize the system for maximum
efficiency and resilience against emerging threats.

29
In summary, the deployment of a security system founded on sonar-based technology
presents a promising solution, marking a significant stride towards bolstering security measures
across various domains.

30
REFERNECES
1. Sungbok Kim and Hyunbin Kim, “Simple and Complex Obstacle Detection Using an
Overlapped Ultrasonic Sensor Ring,”2012 12th International Conference on Control,
Automation and Systems.

2. Jun Hou, Chengdong Wu, Zhongjia Yuan, Jiyuan Tan, Qiaoqiao Wang and Yun Zhou,
“Research of Intelligent Home Security Surveillance System Based on ZigBee,” International
Symposium on Intelligent Information Technology Application Workshops, pp.554-557,21-
22 Dec.2008

3. J. Borenstein, H. R. Everett, and L. Feng, “Where Am I?”: Sensors and Methods for
Mobile Robot Positioning, The University of Michigan, 1996.

4. J. L. Crowley, “World Modelling and Position Estimation for a Mobile Robot Using
Ultrasonic Ranging,”Proc. IEEE Int. Conf. Robotics and Automation, pp. 674-680,1989.

5. H. Choset, K. Nagatani, and N. A. Lazar, "The Arc Traversal Median Algorithm: A


Geometric Approach to Increase Ultrasonic Sensor Azimuth Accuracy," IEEE Trans.
Robotics and Automation, vol. 19, no. 3, pp. 513-522, 2003.

6. Ying-Wen Bai, Li-Sih Shen and Zong-Han Li “Design and Implementation of an


Embedded Home Surveillance System by Use of Multiple Ultrasonic Sensor”.

7. G. Bhor, P. Bhandari, R. Ghodekar and S. Deshmukh, "Mini Radar," International Journal


of Technical Research and Applications, pp. 68-71, 2016

8. D. B. Kadam, Y. B. Patil, K. V. Chougale and. S. S. Perdeshi, "Arduino-Based Moving 3.


Radar System," International Journal of Innovative Studies in Sciences and Engineering
Technology (IJISSET).

9. T. P. Rajan, K. K. Jithin, K. S. Hareesh, C. A. Habeeburahman and. A. Jithin, "Range


Detection based on Ultrasonic Principle," International Journal of Advanced Research in
Electrical, Electronics and Instrumentation Engineering, vol. 3, no. 2, pp. 7638-7643, 2014.

10. P. S. Abhay. S. K. Akhilesh, P. Amrit, and Kriti, “A Review on Ultrasonic Radar Sensor
for Security system,” Journal of Emerging Technologies and Innovative Research (JETIR),
pp. 137-140, 2016.

31

You might also like