0% found this document useful (0 votes)
138 views

Project Report

This document describes a security system project that uses an ultrasonic sensor and GSM module. The system was developed by Shubham Bhalekar, Pratik Avhad, and Rushikesh Waghmode for their diploma in Information Technology from Government Polytechnic Mumbai. The system is intended to provide low-cost home security and notify owners of intrusions via text message. It uses an Arduino Uno board to monitor the ultrasonic sensor and trigger an alarm if motion is detected, also sending a text to the owner. The document outlines the components, design, and software code for the system.

Uploaded by

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

Project Report

This document describes a security system project that uses an ultrasonic sensor and GSM module. The system was developed by Shubham Bhalekar, Pratik Avhad, and Rushikesh Waghmode for their diploma in Information Technology from Government Polytechnic Mumbai. The system is intended to provide low-cost home security and notify owners of intrusions via text message. It uses an Arduino Uno board to monitor the ultrasonic sensor and trigger an alarm if motion is detected, also sending a text to the owner. The document outlines the components, design, and software code for the system.

Uploaded by

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

SECURITY SYSTEM USING ULTRASONIC

SENSOR AND GSM MODULE

A PROJECT REPORT

SUBMITTED BY

SHUBHAM BHALEKAR

PRATIK AVHAD

RUSHIKESH WAGHMODE

in partial fulfilment for the award of

Diploma
IN

INFORMATION TECHNOLOGY

DEPARTMENT OF INFORMATION TECHNOLOGY


GOVERNMENT POLYTECHNIC MUMBAI

JUNE 2021

i
GOVERNMENT POLYTECHNIC MUMBAI
DEPARTMENT OF INFORMATION TECHNOLOGY

CERIFICATE

This is to certify that the project entitled “SECURITY SYSTEM USING

ULTRASONIC SENSOR AND GSM MODULE” is the bonafide work of

“SHUBHAM BHALEKAR AND PRATIK AVHAD AND RUSHIKESH

WAGHMODE”, submitted in partial fulfilment of the requirements for the

award of Diploma in Information Technology of Government Polytechnic

Mumbai.

Dr. Rajesh A. Patil Dr. Rajesh A. Patil

HEAD OF THE DEPARTMENT PROJECT GUIDE

Lecturer in Information Technology

EXTERNAL EXAMINER Mrs. Swati. D. Deshpande

PRINCIPAL

DECLARATION

ii
We hereby declare that the project entitled “LOCATION DETECTOR

WITH GSM MODULE” being submitted by us towards the partial

fulfilment of the requirements for the award of Diploma in Information

Technology is a project work carried by us under the supervision of Dr. Rajesh

A. Patil and have not been submitted anywhere else.

We will be solely responsible if any kind of plagiarism is found.

Date :-

Name of the Students Enrollment No. Signature

1. Shubham Bhalekar FS18IF017

2. Pratik Avhad FS18IF015

3. Rushikesh Waghmode FS18IF011

iii
ACKNOWLEDGMENTS

It is our privilege to express our sincerest regards to our project coordinator, Dr Rajesh A. Patil for their valuable
inputs, guidance, encouragement, whole-hearted cooperation and constructive criticism throughout the duration of
our project. Their useful suggestions for this whole work and co-operative behavior are sincerely acknowledged.

We also deeply express our sincere thanks to our Head of Department Dr Prof. Rajesh A. Patil for encouraging
and allowing us to present the project on the topic “Security System Using Ultrasonic Sensor And Gsm Module”
at our department premises for the partial fulfillment of the requirements.

We take this opportunity to thank all our lecturers who have directly or indirectly helped our project. We pay our
respects and love to our parents and all other family members and friends for their love and encouragement
throughout our career. Last but not the least we express our thanks to our friends for their cooperation and support.

Rushikesh Waghmode (FS18IF011)

Pratik Avhad (FS18IF015)

Shubham Bhalekar (FS18IF017)

iv
ABSTRACT

Home security is becoming necessary nowadays as the possibilities of intrusion are increasing day by
day .Lot of Security companies are available towards protecting house from getting vandalized or so. But still
there is no much guarantee that the house be safe or even if the house vandalized, security personnel safe and
sound to report to police nearby.

Lot of research been carried out employing sensors like PIR, Sensor Camera, GSM towards detecting the
intruder at home. But the drawback in all these systems is that they are all expensive to be deployed integrated
with LCD panel or Camera. Again with PIR sensor or Ultrasonic Sensor integrated with GSM, there is good
possibility of false intruder detection based on line of sight cut by any entity and not necessarily an intruder.
Currently homes in India still rely on security service personnel and no home security system been employed so
far.

So taking the above mentioned aspects into consideration, we here have developed an economical and
affordable Home security system which have integrated the security component by making use of sensors like
Ultrasonic Sensor to sense the motion. After Ultrasonic sense the motion, the busser will buzz. The owner of the
house is informed about any intruder by sending a text message by using of GSM module. All these activities are
controlled by Arduino Uno. This system would help all the users at any level of income to have one at their home
and secure home

from any vandalizing Keywords— UltraSonic Sensor, Buzzer, GSM, Arduino

v
Table of Content:

1. Introduction
1.1. Introduction to Project
1.2. Future Scope
2.Literature Review
3.Overview of the Major Concepts Used
3.1 Arduino UNO
3.2. GSM - Global System for Mobile communication
3.3. Ultrasonic Sensor

4.Requirement Analysis
4.1. Hardware Components
4.2. Software Components

5.System Design
5.1 Working of Ultrasonic Sensor
5.2 Working of BUZZER
5.3 Working of GSM
5.4 Working f Security System

6.Software Code Development


6.1 Introduction
6.2 What is Arduino?
6.3 Arduino Software IDE
6.4 #include
6.5 #define
6.6 User-Defined Methods in the Code:
6.7 Uploading Code to the Board
Advantages and Disadvantages
Conclusion and Future Scope
References
Appendices

vi
List of Figures
1. Introduction
2. Literature Review
3. Overview of the Major Concepts Used
Fig.No.3.1.1. Arduino Uno
Fig.No.3.1.2 Arduino Uno Pin Diagram
Fig.No.3.2.1. GSM Module

4. Requirement Analysis
Fig.No. 4.1.1. Piezo Buzzer
Fig.No.4.1.2. Bread Board
Fig.No.4.1.3. Male To Male
Fig.No.4.1.4. Male To Female
Fig.No.4.1.5. Micro USB

5. System Design
Fig.No.5.1.1. Ultrasonic Sensor
Fig.No.5.1.2. Ultrasonic Sensor Received Signal
Fig.No.5.1.3. Flowchart of Ultrasonic Sensor
Fig.No. 5.1.4. Connection of Ultrasonic sensor
Fig.No.5.2.1. Flowchart of Buzzer
Fig.No.5.2.2. Connection of Buzzer
Fig.No.5.3.1. Flowchart of GSM
Fig.No.5.3.2. Connection of GSM
Fig.No.5.4.1. Flowchart Of Security System

6. Software Code Development


Fig.No.6.2.1. Arduino
Fig.No.6.3.1. Arduino Software IDE

vii
Abbreviations

GSM- Global System for Mobile Communication

DC- Direct Current

SMS- Short Message Service

IDE- Integrated Development Environment

API- Application Programming Interface

PWM- Pulse Width Modulation

USB- Universal Serial Bus

AC- Alternating current

DC- Direct Current

LED- Light Emitting Diode

FDMA- Frequency Division Multiple Access

TDMA- Time-Division Multiple Access.

PCB- Printed Circuit Board.

viii
CHAPTER 1

INTRODUCTION

1
1. INTRODUCTION

1.1 Introduction to Project


Security entails the condition of not being threatened, especially; physically,
psychologically or emotionally. A security system is a system designed to detect intrusion or
unauthorized entry into a building or an area. They are used in residential, commercial,
military, and industrial properties for protection against burglary (theft) or property damage,
as well as personal protection against intruders.

The ‘modern and smart’ security systems which do in fact cover other potential
threats and do function smartly by incorporating other forms of alarms notably phone-based
alarms for remote monitoring, costs a fortune to set up, operate and maintain, owing to the
nature of software design, type of materials used etc.

This design signifies a major improvement in terms of using cheaper materials,


easier to maintain components and cheaper operating cost than other systems of the same
kind, as notifications via text messages and calls are only made when owner is actually away.
The GSM based smart security system using Arduino can be adopted at home, offices,
institutions (educational, military, commercial, industrial, etc.

It consists of various types of sensors used for the task of monitoring. The system is fully
controlled by the ‘powerful’ Arduino Uno board. The Arduino Uno board, continuously
monitors all sensors, and if any security threat is detected from these sensors, then a
combination of three alarms are triggered, namely; visual, audio and/or phone-based alarm.

The system offers a safe security system, in that only the user can activate or deactivate
the two operational modes, through a phone call made only from his phone to the system,
unlike other systems. This capability means that the security system is in itself minimally
prone to attack.

1.2 Future Scope

 We can add a keypad to arm or disarm the alarm.


 We can determine the position of the intruder and then send a SMS to the concerned authorities.
 We can also add camera to the system to click the intruder picture when Entered.
 Instead of Bread Board We can use PCB.

2
CHAPTER 2

LITERAURE REVIEW

3
2. Literature Review

The tasks of a modern security system include identifying an intruder trying to gain access to the home,
alerting the homeowner about the intrusion or intrusion attempt, preventing the intruder from gaining access
to the home, and gathering or collecting evidence regarding the intrusion so that the perpetuators can be
brought to justice. The changing concept of security in modern homes has an impact on the advancement of
technology.

This setup can also be used in commercial offices where some areas are restricted for certain personnel, such
a system will immediately inform the administrator of any unauthorized personnel trying to access such an
area. Therefore the extensibility and applicability of such a system is only limited only by the imagination.
Some benefits of security system:

 Cost Effective

 Easy to implement

 It provides security

4
5
CHAPTER 3

OVERVIEW OF THE MAJOR CONCEPTS USED

6
3.Overview of the Major Concepts Used

3.1 AURDINO UNO:

The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output
pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a
power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller;
simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started.
The Uno differs from all preceding boards in that it does not use the FTDI USB-to-serial driver chip. Instead, it
features the Atmega8U2 programmed as a USB-to-serial converter

The Arduino Uno can be powered via the USB connection or with an external power supply. The power source is
selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be
connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads from a battery can be
inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V, however, the 5V pin
may supply less than five volts and the board may be unstable. If using more than 12V, the voltage regulator may
overheat and damage the board. The recommended range is 7 to 12 volts.

Fig.No.3.1.1. Arduino Uno

7
Fig.No.3.1.2 Arduino Uno Pin Diagram

Summary:

Microcontroller ATmega328

Operating Voltage 5V

Input Voltage 7-12V

Input Voltage (limits) 6-20V

Digital I/O Pins 14 (of which 6 provide PWM output)

Analog Input Pins 6

DC Current per I/O Pin 40 mA

DC Current for 3.3V Pin 50 mA

Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader

SRAM 2 KB (ATmega328)

EEPROM 1 KB (ATmega328)

Clock Speed 16 MHz

8
The power pins are as follows:

 VIN. The input voltage to the Arduino board when it's using an external power source (as opposed to 5
volts from the USB connection or other regulated power source). You can supply voltage through this pin,
or, if supplying voltage via the power jack, access it through this pin.
 5V. The regulated power supply used to power the microcontroller and other components on the board.
This can come either from VIN via an on-board regulator, or be supplied by USB or another regulated 5V
supply
 3V3. A 3.3 volt supply generated by the on-board regulator. Maximum current draw is 50 mA.
 GND. Ground pins.

1. Power:
The Arduino Uno can be powered via the USB connection or with an external power supply. The
power source is selected automatically.

External (non-USB) power can come either from an AC-to-DC adapter (wall-wart) or battery. The
adapter can be connected by plugging a 2.1mm center-positive plug into the board's power jack.
Leads from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.

The board can operate on an external supply of 6 to 20 volts. If supplied with less than 7V,
however, the 5V pin may supply less than five volts and the board may be unstable. If using more
than 12V, the voltage regulator may overheat and damage the board. The recommended range is 7
to 12 volts.
The power pins are as follows:
 VIN. The input voltage to the Arduino board when it's using an external power source (as
opposed to 5 volts from the USB connection or other regulated power source). You can
supply voltage through this pin, or, if supplying voltage via the power jack, access it
through this pin.
 5V.This pin outputs a regulated 5V from the regulator on the board. The board can be
supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or
the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the
regulator, and can damage your board. We don't advise it.
 GND. Ground pins.
 IOREF. This pin on the Arduino board provides the voltage reference with which the
microcontroller operates. A properly configured shield can read the IOREF pin voltage and

9
select the appropriate power source or enable voltage translators on the outputs for working
with the 5V or 3.3V.

2. INPUT AND OUTPUT:


Each of the 14 digital pins on the Uno can be used as an input or output, using pinMode(),
digitalWrite(), and digitalRead() functions. They operate at 5 volts. Each pin can provide or receive
a maximum of 40 mA and has an internal pull-up resistor (disconnected by default) of 20-50
kOhms. In addition, some pins have specialized functions:

 Serial: 0 (RX) and 1 (TX). Used to receive (RX) and transmit (TX) TTL serial data. TThese
pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL Serial chip .
 External Interrupts: 2 and 3. These pins can be configured to trigger an interrupt on a low
value, a rising or falling edge, or a change in value.
 PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analogWrite() function.
 SPI: 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication,
which, although provided by the underlying hardware, is not currently included in the
Arduino language.
 LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH value,
the LED is on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, each of which provide 10 bits of resolution (i.e. 1024 different values).
By default they measure from ground to 5 volts, though is it possible to change the upper end of their range
using the AREF pin and the analogReference() function. Additionally, some pins have specialized
functionality:

 2C: 4 (SDA) and 5 (SCL). Support I2C (TWI) communication using the Wire library.
There are a couple of other pins on the board:

 AREF. Reference voltage for the analog inputs. Used with analogReference().
 Reset. Bring this line LOW to reset the microcontroller. Typically used to add a reset button to shields
which block the one on the board.

3. Memory:
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of SRAM and 1
KB of EEPROM (which can be read and written with the EEPROM library).

10
4. COMMUNICATION:
The Arduino Uno has a number of facilities for communicating with a computer, another Arduino,
or other microcontrollers. The ATmega328 provides UART TTL (5V) serial communication, which
is available on digital pins 0 (RX) and 1 (TX). An ATmega8U2 on the board channels this serial
communication over USB and appears as a virtual com port to software on the computer. The '8U2
firmware uses the standard USB COM drivers, and no external driver is needed. However, on
Windows, an *.inf file is required.
The Arduino software includes a serial monitor which allows simple textual data to be sent to and
from the Arduino board. The RX and TX LEDs on the board will flash when data is being
transmitted via the USB-toserial chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).

A SoftwareSerial library allows for serial communication on any of the Uno's digital pins

The ATmega328 also support I2C (TWI) and SPI communication. The Arduino software includes a
Wire library to simplify use of the I2C bus; see the documentation for details. To use the SPI
communication, please see the ATmega328 datasheet.

5. Automatic (Software) Reset:


Rather than requiring a physical press of the reset button before an upload, the Arduino Uno is
designed in a way that allows it to be reset by software running on a connected computer. One of the
hardware flow control lines (DTR) of theATmega8U2/16U2 is connected to the reset line of the
ATmega328 via a 100 Nano farad capacitor. When this line is asserted (taken low), the reset line
drops long enough to reset the chip. The Arduino software uses this capability to allow you to upload
code by simply pressing the upload button in the Arduino environment. This means that the boot
loader can have a shorter timeout, as the lowering of DTR can be well-coordinated with the start of
the upload.
This setup has other implications. When the Uno is connected to either a computer running
Mac OS X or Linux, it resets each time a connection is made to it from software (via USB). For the
following half-second or so, the bootloader is running on the Uno. While it is programmed to ignore
malformed data (i.e. anything besides an upload of new code), it will intercept the first few bytes of

11
data sent to the board after a connection is opened. If a sketch running on the board receives one-time
configuration or other data when it first starts, make sure that the software with which it
communicates waits a second after opening the connection and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on either side of
the trace can be soldered together to re-enable it. It's labeled "RESETEN". You may also be able to
disable the auto-reset by connecting a 110 ohm resistor from 5V to the reset line; see this forum
thread for details.

6. USB Overcurrent Protection:


The Arduino Uno has a resettable poly fuse that protects your computer's USB ports from shorts
and overcurrent. Although most computers provide their own internal protection, the fuse provides an
extra layer of protection. If more than 500 mA is applied to the USB port, the fuse will automatically
break the connection until the short or overload is removed.

7. Physical Characteristics:
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively, with the
USB connector and power jack extending beyond the former dimension. Four screw holes allow the
board to be attached to a surface or case. Note that the distance between digital pins 7 and 8 is 160 mil
(0.16"), not an even multiple of the 100 mil spacing of the other pins.
3.2 GSM - Global System for Mobile communication:

GSM is the most widely used network technology in Internet of Things (IoT) applications for its simplicity,
affordability, and accessibility. It uses the 2G network band. Our project uses GSM network to make the phone
call during an emergency. The project has a nano sim-card which gets registered on the 2G network and uses GSM
network to make the phone call. Structure of GSM networks –

 Mobile Station (MS): The Mobile Station is essentially the access point someone uses to connect to the
network. It’s a device (such as an alarm system) with a Subscriber Identity Module (SIM). The SIM
associates the device with an individual subscriber, which allows the device to connect to the nearest Base
Station Subsystem.

 Base Station Subsystem (BSS): The BSS contains Base Transceiver Stations and a Base Station Controller.
The Base Transceiver Stations include components like receivers and antenna, which allows connected
devices to send and receive signals, and the Base Station Controller allows the Base Transceiver Stations to
relay signals through the network, via the Network and Switching Subsystem

12
 Network and Switching Subsystem (NSS): The Network and Switching Subsystem is a term for the major
components of a 2G core network. The NSS originally helped facilitate connection-oriented voice calls
with the Home Location Register (HLR), Authentication Center (AuC), Message Service Center (MSC),
and Visitor Location Register (VLR). With the introduction of the GPRS core network and its support
nodes (GGSN and SGSN), the NSS began playing a role in data connections as well.

 Operations Support System (OSS): The Operations Support System is a conglomeration of processes, data,
applications, and tech that allows providers to manage their network.

Fig.No.3.2.1. GSM Module

GSM played a foundational role in modern cellular communications. While some operators are transitioning to
newer networks, this technology is still immensely popular for its global availability and extremely low-cost
connectivity.

3.3 ULTRASONIC SENSOR:

Ultrasonic transmitter emitted an ultrasonic wave in one direction, and started timing when it launched. Ultrasonic
spread in the air, and would return immediately when it encountered obstacles on the way. At last, the ultrasonic
receiver would stop timing when it received the reflected wave. The principle of ultrasonic distance measurement
used the already-known air spreading velocity, measuring the time from launch to reflection when it encountered
obstacle, and then calculate the distance between the transmitter and the obstacle according to the time and the
velocity. Thus, the principle of ultrasonic distance measurement is the same with radar.

13
Fig.No.3.3.1. Ultrasonic Sensor

The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It operation is not
affected by sunlight or black material like. It comes complete with ultrasonic transmitter and receiver module.

A. PRODUCT FEATURES
Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement function, the
ranging accuracy can reach to 3mm. The modules includes ultrasonic transmitters, receiver and control circuit.
The basic principle of work: Using IO trigger for at least 10us high level signal, The Module automatically
sends eight 40 kHz and detect whether there is a pulse signal back. IF the signal back, through high level , time
of high output IO duration is the time from sending ultrasonic to returning.

B. ULTRASONIC APPLICATION
Ultrasonic Application Technology is the thing which developed in recent decades. With the ultrasonic
advance, and the electronic technology development, especially as high-power semiconductor device
technology matures, the application of ultrasonic has become increasingly widespread:
 Ultrasonic measurement of distance, depth and thickness
 Ultrasonic testing
 Ultrasound imaging; Ultrasonic machining, such as polishing, drilling
 Ultrasonic cleaning
 Ultrasonic welding

C. APPLICATION AREAS
 Robotics barrier
 Object distance measurement
 Level detection
 Public security

14
D. MODULE OPERATING PRINCIPLE
Set low the Trig and Echo port when the module initializes , firstly, transmit at least 10us high level pulse
to the Trig pin (module automatically sends eight 40K square wave), and then wait to capture the rising edge
output by echo port, at the same time, open the timer to start timing. Need to supply a short 10uS pulse to the
trigger input to start the ranging, and then the module will send out an 8 cycle burst of ultrasound at 40 kHz
and raise its echo. The Echo is a distance object that is pulse width and the range in proportion. You can
calculate the range through the time interval between sending trigger signal and receiving echo signal.
Formula: uS / 58 = centimeters or uS / 148 =inch; or: the range = high level time * velocity (340M/S) / 2; we
suggest to use over 60ms measurement cycle, in order to prevent trigger signal to the echo signal.

15
CHAPTER 4

REQUIREMENT ANALAYSIS

16
4. Requirement Analysis

4.1. Hardware Components:

The hardware used for the project:

1. Arduino Uno

2. GSM Module,

3. Ultrasonic Sensor

4. Piezo Buzzer

5. Breadboard

6. Jump Wires.

7. Micro USB

 Piezo Buzzer

A buzzer is used to alert the persons nearby. The buzzer produces a same noisy sound irrespective of the
voltages -applied to it. When potential is applied to it, they push on one conductor and pull on the other. This
results in producing sound. It can produce voltage of 2 to 4kHz.

Fig.No. 4.1.1. Piezo Buzzer

 Bread Board

A thin plastic board used to hold electronic components (transistors, resistors, chips, etc.) that are wired
together. Used to develop prototypes of electronic circuits, breadboards can be reused for future jobs. They can
be used to create one-of-a-kind systems but rarely become commercial products.

17
Fig.No.4.1.2. Bread Board

 Jump Wires

A jump wire (also known as jumper, jumper wire, jumper cable, DuPont wire or cable) is an
electrical wire, or group of them in a cable, with a connector or pin at each end which is normally used to
interconnect the components of a breadboard or other prototype or test circuit, internally or with other
equipment or components, without soldering.

 MALE TO MALE:

Fig.No.4.1.3. Male To Male

 MALE TO FEMALE:

Fig.No.4.1.4. Male To Female

18
 Micro USB

Micro USB is a miniaturized version of the USB (Universal Serial Bus) interface developed for connecting
compact and mobile devices such as your smartphones, MP3 players, GPS devices, photo printers, and
digital cameras. USB was designed to standardize the connection of peripherals to personal computers,
both to communicate with and to supply electric power. It has largely replaced interfaces such as serial
ports and parallel ports, and has become commonplace on a wide range of devices.

Fig.No.4.1.5. Micro USB

4.2. Software Requirements:

The software used for the project:

 Arduino IDE

The Arduino integrated development environment (IDE) is a cross platform application written in Java, and
is derived from the IDE for the Processing programming language and the Wiring projects. It is designed to
introduce programming to artists and other newcomers unfamiliar with software development. It

includes a code editor with features such as syntax highlighting, brace matching, and automatic indentation, and is
also capable of compiling and uploading programs to the board with a single click.

A program or code written for Arduino is called a sketch Arduino programs are written in C or C++. The Arduino
IDE comes with a software library called "Wiring" from the original Wiring project, which makes many common
input/output operations much easier. Users only need define two functions to make a runnable cyclic executive
program:

 The Arduino IDE uses the GNU tool chain and AVR Library to compile programs, and uses avrdude to
upload programs to the board.
 As the Arduino platform uses Atmel microcontrollers, Atmel's development environment, AVR Studio or
the newer Atmel Studio, may also be used to develop software for the Arduino

19
20
CHAPTER 5

SYSTEM DESIGN

21
5. System Design And Coding

5.1 Working of Ultrasonic Sensor

when a pulse of at least 10 µS (10 microseconds) in duration is applied to the Trigger pin. In
response to that the sensor transmits a sonic burst of eight pulses at 40 KHz. This 8-pulse pattern makes the
“ultrasonic signature” from the device unique, allowing the receiver to differentiate the transmitted pattern
from the ambient ultrasonic noise.

The eight ultrasonic pulses travel through the air away from the transmitter. Meanwhile the Echo pin goes
HIGH to start forming the beginning of the echo-back signal.

In case, If those pulses are not reflected back then the Echo signal will timeout after 38 mS (38 milliseconds)
and return low. Thus a 38 mS pulse indicates no obstruction within the range of the sensor.

Fig.No.5.1.1. Ultrasonic Sensor

If those pulses are reflected back the Echo pin goes low as soon as the signal is received. This produces a pulse
whose width varies between 150 µS to 25 mS, depending upon the time it took for the signal to be received.

22
Fig.No.5.1.2. Ultrasonic Sensor Received Signal

The width of the received pulse is then used to calculate the distance to the reflected object. This can be worked
out using simple distance-speed-time equation, we learned in High school. In case you forgot, an easy way to
remember the distance, speed and time equations is to put the letters into a triangle.

Let’s take an example to make it more clear. Suppose we have an object in front of the sensor at an unknown
distance and we received a pulse of width 500 µS on the Echo pin. Now let’s calculate how far the object
from the sensor is. We will use the below equation.

Distance = Speed x Time

Here, we have the value of Time i.e. 500 µs and we know the speed. What speed do we have? The speed of
sound, of course! Its 340 m/s. We have to convert the speed of sound into cm/µs in order to calculate the
distance. A quick Google search for “speed of sound in centimeters per microsecond” will say that it is 0.034
cm/µs. You could do the math, but searching it is easier. Anyway, with that information, we can calculate
the distance!

Distance = 0.034 cm/µs x 500 µs

But this is not done! Remember that the pulse indicates the time it took for the signal to be sent out and
reflected back so to get the distance so, you’ll need to divide your result in half.

Distance = (0.034 cm/µs x 500 µs) / 2

Distance = 8.5 cm

23
 Flowchart of Ultrasonic Sensor:

Fig.No.5.1.3. Flowchart of Ultrasonic Sensor

 Connection of Ultrasonic sensor

Now that we have a complete understanding of how HC-SR04 ultrasonic distance sensor works, we can
begin hooking it up to our Arduino!

Connecting the HC-SR04 to the Arduino is pretty easy. Start by placing the sensor on to your breadboard.
Connect VCC pin to the 5V pin on the Arduino and connect GND pin to the Ground pin on the Arduino.

When you’re done you should have something that looks similar to the illustration shown below.

VCC -> Arduino +5V pin

GND -> Arduino GND pin

Trig -> Arduino Digital Pin 9

Echo -> Arduino Digital Pin 10

24
Fig.No. 5.1.4. Connection of Ultrasonic sensor

5.2 Working of BUZZER

Buzzers can be both fun and useful in electric circuits.We’ll use them a lot in MakeCrate projects, so let’s
take a look at what is going on inside a buzzer to produce sound.

The buzzer consists of an outside case with two pins to attach it to power and ground.

Inside is a piezo element, which consists of a central ceramic disc surrounded by a metal (often
bronze)vibration disc.

When current is applied to the buzzer it causes the ceramic disk to contract or expand. Changing the  This
then causes the surrounding disc to vibrate.  That’s the sound that you hear.  By changing the frequency of
the buzzer, the speed of the vibrations changes, which changes the pitch of the resulting sound.

25
 Flowchart of Buzzer

Fig.No.5.2.1. Flowchart of Buzzer

 Connection of BUZZER

s -> Arduino pin 8

GND -> Arduino GND pin

Fig.No.5.2.2. Connection of Buzzer

26
5.3 Working of GSM

Global System for Mobile Communications (GSM) uses a combination of Time Division Multiple Access
(TDMA) and Frequency Division Multiple Access (FDMA).

Frequency Division Multiple Access: It involves dividing a frequency band into multiple bands such that
each sub-divided frequency band is allotted to a single subscriber. FDMA in GSM divides the 25MHz
bandwidth into 124 carrier frequencies each spaced 200 KHz apart. Each base station is allotted one or more
carrier frequencies.

Time Division Multiple Access: It involves allotting same frequency channel to different subscribers by
dividing the frequency band into multiple time slots. Each user gets his/her own timeslot, allowing multiple
stations to share same transmission space.

For GSM, each sub divided carrier frequency is divided into different time slots using TDMA technique. 
Each TDMA frame lasts for 4.164 milliseconds (ms) and contains 8 time slots. Each time slot or a physical
channel within this frame lasts for 577 microseconds and data is transmitted in the time slot in form of
bursts.

 Flowchart of GSM

Fig.No.5.3.1. Flowchart of GSM

27
 Connection of GSM

GND -> Arduino GND pin

TX -> Arduino Digital Pin 2

RX -> Arduino Digital Pin 3

Fig.No.5.3.2. Connection of GSM

5.4 Working Of Security System

This system is a basic motion activated alarm. It is built around an Arduino Microcontroller. It is connected
to an Ultrasonic sensor, a buzzer, GSM module, and a pairs of jumper wires. The whole system is battery powered
so that it is easily portable. Once you have the code, you can connect all the external parts. The easiest way to do
this is with a breadboard. This will let you make temporary connections to test everything out.

If the Ultrasonic Sensor sense the object, Then Buzzer will start buzzing and GSM module will send text to
the smartphone.

28
 Flowchart

Fig.No.5.4.1. Flowchart Of Security System

Connection of all system:

 Ultrasonic to Arduino:
VCC -> Arduino +5V pin
GND -> Arduino GND pin
Trig -> Arduino Digital Pin 9
Echo -> Arduino Digital Pin 10
 Connection to Buzzer:
s -> Arduino pin 8

GND -> Arduino GND pin

29
 Connection of GSM:
GND -> Arduino GND pin
TX -> Arduino Digital Pin 2
RX -> Arduino Digital Pin 3

OVERVIEW:

Fig.No.5.4.2. Overview of project

30
CHAPTER 6

SOFTWRAE CODE DEVELOPMENT

31
6 SOFTWARE CODE DEVELOPMENT

1] Introduction

Location Tracker using GSM module uses several hardware components connected with each other to track
location data and transmit it over GPRS network. However, in order for the hardware components to function, the
instruction need to be hardcoded into the ESP32 chip. The steps used in developing various elements of the code
are explained below along with a brief overview of all concepts used throughout the code.

2] What is Arduino?

Arduino is an open-source electronics platform based on easy-to-use hardware and software. The Arduino
software is easy-to-use for beginners, yet flexible enough for advanced users. It runs on Mac, Windows, and Linux
as well.

Fig.No.6.2.1. Arduino

3] Arduino Software IDE

The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains a text editor for writing
code, a message area, a text console, a toolbar with buttons for common functions and a series of menus. It
connects to the Arduino hardware to upload programs and communicate with them. Programs written using
Arduino Software (IDE) are called sketches. These sketches are written in the text editor and are saved with the
file extension .ino. The editor has features for cutting/pasting and for searching/replacing text. The message area
gives feedback while saving and exporting and also displays errors. The console displays text output by the
Arduino Software (IDE) if any, including complete error messages and other information.
32
Fig.No.6.3.1. Arduino Software IDE

4] #include

#include is used to include outside libraries in the sketch. This gives the programmer access to a large group of
standard C libraries (groups of pre-made functions), and also libraries written especially for Arduino. It is also
used to use code from any local files in the code.

Syntax

#include <LibraryFile.h>

#include "LocalFile.h"

Parameters:

1. LibraryFile.h: When the angle brackets syntax is used, the libraries paths will be searched for the file.
2. LocalFile.h: When the double quotes syntax is used, the folder of the file using the #include directive will
be searched for the specified file, then the libraries paths if it was not found in the local path. This syntax is
usually used for header files in the sketch’s folder.

Example:
#include <SoftwareSerial.h>

The Arduino hardware has built-in support for serial communication on pins 0 and 1 (which also goes to the
computer via the USB connection). The native serial support happens via a piece of hardware (built into the
chip) called a UART. This hardware allows the Atmega chip to receive serial communication even while
working on other tasks, as long as there room in the 64 byte serial buffer.

33
The SoftwareSerial library has been developed to allow serial communication on other digital pins of the
Arduino, using software to replicate the functionality (hence the name "SoftwareSerial"). It is possible to
have multiple software serial ports with speeds up to 115200 bps. A parameter enables inverted signaling for
devices which require that protocol.

5] #define

#define is a useful C++ component that allows the programmer to give a name to a constant value before the
program is compiled. Defined constants in Arduino don’t take up any program memory space on the chip. The
compiler will replace references to these constants with the defined value at compile time. This can have some
unwanted side effects though, if for example, a constant name that had been #defined is included in some other
constant or variable name. In that case the text would be replaced by the #defined number (or text).

Syntax:

#define constantName value

6] User-Defined Methods in the Code:

6.1] setup36()

The setup() function is called when a sketch starts. It is used to initialize variables, pin modes, start using libraries,
etc. The setup() function will only run once, after each powerup or reset of the board. The setup and loop functions
are mandatory. Trying to compile a code with one of these functions missing, results in an error. The code inside
the void setup will be executed once, and only once, at the beginning of the program.

Syntax:

void setup() {

body;

The method calls we used in setup() for the project are enlisted below along with their precise description and
syntax used.

 Serial.begin(speed): It sets the data rate in bits per second (baud) for serial data transmission.
 delay(ms):- Pauses the program for the amount of time (in milliseconds) specified as parameter. (There are
1000 milliseconds in a second.)

 pinMode(pin, mode):- Configures the specified pin to behave either as an input or an output. See the
description of digital pins for details on the functionality of the pins.
34
As of Arduino 1.0.1, it is possible to enable the internal pullup resistors with the mode
INPUT_PULLUP. Additionally, the INPUT mode explicitly disables the internal pullups.

Modes:-INPUT, OUTPUT, or INPUT_PULLUP

6.2] loop()

After creating a setup() function, which initializes and sets the initial values, the loop() function does precisely
what its name suggests, and loops consecutively, allowing the sketch to change and respond accordingly. It doesn’t
stop iterating until the board is powered off or the Arduino program is restarted by pressing the reset button /
uploading a new sketch / re-opening the Serial Monitor on the ESP32 board.

The method calls we used in loop() for the project are enlisted below along with their precise description and
syntax used.

 digitalWrite(pin, value):- Write a HIGH or a LOW value to a digital pin.If the pin has been configured as
an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V (or 3.3V on 3.3V
boards) for HIGH, 0V (ground) for LOW.
 delayMicroseconds(us):- Pauses the program for the amount of time (in microseconds) specified by the
parameter. There are a thousand microseconds in a millisecond and a million microseconds in a second.

35
6.7.Uploading Code to the Board

After sketch is complete, the last yet an important step is Uploading the sketch onto the board. The steps used to
upload this sketch to the Arduino Uno are as follows:

Step 1:Type the code in Arduino software.

Step 2: Connect the Arduino Uno module to the computer using a cable.

Step 3: Then Upload code to the Arduino Uno Using Arduino IDE.

Step 4: After Uploading code to Arduino compile the code, check if any error is there.

Step 5: If there is no error, then it will show done compiling downside.


36
Step 6: If there is no error, Click on Upload Button.

37
ADVANTAGES

• The given system is handy and portable, and thus can be easily carried from one place to another.
• The circuitry is not that complicated and thus can be easily troubleshooted.
• The given system sets off a powerful buzzer, and it is effective as any other alarm system available in the
market.
• This sensor is not affected due to atmospheric dust, rain, snow etc.
• It can work in any adverse conditions.

DISADVANTAGES

• It is very sensitive to variation in the temperature.


• It has more difficulties in reading reflections from soft, curved, thin and small objects.
• The given alarm system determines the presence of the intruder only, and does not determine how many
persons are in there actually.
• The alarm activates only when the person cuts through the line of the IR sensor.

38
Conclusion

Thus, we have designed a home security alarm system using Arduino and Ultrasonic sensor, which is
handy, portable, cost-effective and highly effective as well. Such alarm systems are hugely in demand for security
purposes, and thus the given system can be proved useful and effective in view of the above features.

The sensors placed on the door informs the home owner as soon as the door is opened by sending a Push
notification. The user will get this notification irrespective of whether the phone is locked or unlocked or even if
any other app is opened at the moment. This was the main objective of the project, which is the user feels safe and
not worry about any intrusion or break-ins when he is away from home. This setup can also be used in commercial
offices where some areas are restricted for certain personnel, such a system will immediately inform the
administrator of any unauthorized personnel trying to access such an area.

39
References

 Books
[1] Michael Mcroberts, Beginning Arduino.
 Software
[2] Arduino IDE 1.0.6 from https://www.arduino.cc/en/main/software.
 World Wide Web
[3] www.circuitstoday.com
[4] www.engineersgarage.com
[5] www.learn.adafruit.com
[6] www.instructables.com

40
Appendices

#include<SoftwareSerial.h>
#define trigPin 9
#define echoPin 10
#define piezoPin 8
SoftwareSerial mySerial(2, 3);
int normalDistance;
boolean triggered = false;
long duration, distance;
void setup()
{
mySerial.begin(9600);
Serial.begin (9600);
delay(100);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(piezoPin, OUTPUT);
digitalWrite(piezoPin, HIGH);
long duration, distance;
while (millis() < 5000)
{
digitalWrite(piezoPin, HIGH);
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
normalDistance = distance;
Serial.print("Distance: ");
Serial.println(distance);
digitalWrite(piezoPin, LOW);
}
}
void loop()
{
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);

41
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
Serial.print("Distance: ");
Serial.println(distance);
if (distance < normalDistance-5)
{
triggered = true;
}
else
{
triggered = false;
}
if (triggered)
{
tone(piezoPin, 635);
delay(500);
tone(piezoPin, 912);
delay(250);
mySerial.println("AT+CMGF=1");
delay(1000);
mySerial.println("AT+CMGS=\"+918850230418\"\r");
delay(1000);
mySerial.println("Someone Entered!!!");
mySerial.println((char)26);
delay(1000);
}
}

42
43

You might also like