Physics
Physics
SAKAYO MUOKI
MASTER OF SCIENCE
(Physics)
2023
Design and Fabrication of an Integrated Microcontroller Security
System
Sakayo Muoki
2023
DECLARATION
This thesis is my original work and has not been presented for a degree in any other
University
Signature…………………………..…………………. Date………………………….
Sakayo Muoki
This thesis has been submitted for examination with our approval as the University
Supervisors
Signature…………………………..…………………. Date………………………….
Prof. Joseph N. Mutuku, PhD
JKUAT, Kenya
Signature…………………………..…………………. Date………………………….
Dr. James. M. Ngaruiya, PhD
JKUAT, Kenya
ii
DEDICATION
This thesis is dedicated to my parents Mr. and Mrs. Joseph Kavoi for their inspiration in
my world of academics from my tender age. They have really modelled and triggered
my thoughts throughout. They have made me realize the potential I have and I will
always be indebted to you. In addition, the late Dr. Nicholas Muthama Mutua, had been
more than a mentor. I lack precious words to use, but may you continue resting in peace.
iii
ACKNOWLEDGEMENT
My true and sincere appreciation goes to all those who contributed towards the
achievement of this research work. I appreciate Prof. Mutuku J.N. and Dr. Ngaruiya
J.M. under whom I had the special honor to be instructed. Truly grateful I am to them
for their guidance in research development and their socializing me in the art of
scientific scholarship.
I appreciate so much my beloved wife for her continued strong inspirational support,
encouragement and patience. My special thanks to the late Dr. Mutua and Dr. Kiroe for
moral support and encouragement throughout. Words cannot adequately express how
much I am indebted to the staff in the department of Physics and Chemistry at large for
their great deal of contributions to this research activity.
iv
TABLE OF CONTENTS
DECLARATION ............................................................................................................. ii
ACKNOWLEDGEMENT ............................................................................................. iv
v
1.3 Statement of the problem ....................................................................................... 12
2.3 The hardware design modules of the proposed microcontroller security system. . 15
2.3.2 Design and instrumentation of simulation circuit of the MQ-4 gas sensor
module. ......................................................................................................... 18
vi
2.3.1 Introduction ..................................................................................................... 22
2.3.5 PIR sensor characteristics for objects at different distances and heights ....... 25
vii
3.1 Introduction ............................................................................................................ 35
REFERENCES .............................................................................................................. 64
APPENDICES ............................................................................................................... 67
viii
LIST OF TABLES
Table 1.1: The structural and molecular formula for methane, ethane, propane and
butane .............................................................................................................. 8
ix
LIST OF FIGURES
Figure 1.1: (a) Structure of methane molecule, (b) Illustration of bonding angles in
methane molecule (Walker, 2008). ............................................................... 9
Figure 2.3: Simplified circuit of MQ-4 gas sensor. RL and RS resistors are connected in
series. .......................................................................................................... 17
Figure 2.5: Flowchart diagram of the MQ-4 sensor sensitivity adjustment process....... 21
Figure 2.6: Ideal sensitivity characteristics of MQ-4 gas sensor (Pololu robotics and
electronics) .................................................................................................. 22
Figure 2.11: (a) Pin out diagram of LM35 temperature sensor (b): Schematic diagram of
LM35 temperature sensor connected to ADC0831 converter .................... 29
Figure 2.13: Circuit diagram of the Arduino Uno based security system ...................... 33
x
Figure 3.1: A graph of voltage, VRL (mV) versus concentration (ppm) of methanol for
the MQ-4 gas sensor for methanol under ideal conditions. ........................ 36
Figure 3.2: Graph of output voltage (mV) versus concentration of methanol (ppm) in
different exposure-time after 24 hours of heating MQ-4 gas sensor. ......... 38
Figure 3.3: Graph of output voltage (mV) versus concentration of methanol (ppm) in
different exposure-times after 2 days of heating MQ-4 gas sensor. ........... 39
Figure 3.4: Graph of output voltage (mV) versus concentration of methanol (ppm) in
different exposure-times after 3 days of heating MQ-4 gas sensor. ........... 40
Figure 3.5: Graph of output voltage (mV) versus concentration of methanol (ppm) in
different exposure-times after 4 days of heating MQ-4 gas sensor. ........... 41
Figure 3.6: Graph of output voltage (mV) versus concentration of methanol (ppm) in
different exposure-times after 5 days of heating MQ-4 gas sensor. ........... 42
Figure 3.7: The root mean square value of detector voltage at different distances at
different walking speed for PIR placed 0.5 m above the ground ............... 44
Figure 3.8: The root mean square value of detector voltage at different distances and
different walking speed for PIR placed 1.0 m above the ground. .............. 45
Figure 3.9: The root mean square value of detector voltage at different distances at
different walking speed for PIR placed 1.5 m above the ground ............... 46
Figure 3.10: The root mean square value of detector voltage at different distances at
different walking speed for PIR placed 1.8 m above the ground ............... 47
Figure 3.11: Detector sensitivity at different angles when the subject walked towards
the detector at different walking speeds sensor placed at 0.5 m above the
ground ......................................................................................................... 48
xi
Figure 3.12: Detector sensitivity at different angles when the subject walked towards
the detector at different walking speeds sensor placed at 1 m above the
ground. ........................................................................................................ 49
Figure 3.13: Detector sensitivity at different angles when the subject walked towards
the detector at different walking speeds sensor placed at 1.5 m. ................ 50
Figure 3.14: Detector sensitivity at different angles when the subject walked towards
the detector at different walking speeds sensor placed at 1.8 m. ................ 51
Figure 3.15: Detector sensitivity at different angles when the subject walked away from
PIR sensor at different angles with the PIR sensor positioned 0.5 m above
the ground. .................................................................................................. 52
Figure 3.16: Detector sensitivity at different angles when the subject walked away from
PIR sensor at different angles with the PIR sensor positioned 1.0 m above
the ground. .................................................................................................. 53
Figure 3.17: Detector sensitivity at different angles when the subject walked away from
PIR sensor at different angles with the PIR sensor positioned 1.5 m above
the ground. .................................................................................................. 54
Figure 3.18: Detector sensitivity at different angles when the subject walked away from
PIR sensor at different angles with the PIR sensor positioned 1.8 m above
the ground. .................................................................................................. 55
Figure 3.19: A graph of Temperature (0C) against Output voltage (mV) of the LM3
temperature Sensor. .................................................................................... 56
xii
LIST OF PLATES
Plate 2.1: Diagram showing how MQ-4 was heated up. ................................................. 19
Plate 3.1: The experimental arrangement set up to measure voltage drop across resistor
R L when the MQ-4 gas sensor is exposed to different concentrations of
methanol. ......................................................................................................... 37
Plate 3.2: MQ-4 gas sensor and the PIR sensor connected to the Arduino UNO. .......... 57
Plate 3.3: The Arduino UNO security system connected to the power supply. .............. 58
Plate 3.4: The LCD display when the system under normal conditions of temperature
and gas concentration. ..................................................................................... 59
Plate 3.5: a. The temperature is above 40 0C and the buzzer goes on and the red signal
light goes on continuously to indicate there is a danger. b. The short message
of fire sent to home owner mobile phone ........................................................ 60
xiii
LIST OF APPENDICES
Appendix I: The program for running the software for the integrated Arduino
microcontroller based security system. .................................................... 67
xiv
LIST OF SYMBOLS
c speed of light
E energy
h Planck’s constant
k Boltzmann constant
T Absolute temperature
ε emissivity
λ wavelength
Stefan-Boltzmann constant
xv
M mass
Density
V Volume
RS sensing resistance,
RL loading resistance,
xvi
ABBREVIATIONS AND ACRONYMS
AC Alternating Current
IC Integrated circuit
I/O Input/output
IR Infra-Red
LM Linear Monolithic
MO Molecular Orbital
xvii
PIN Personal Identification Number
xviii
ABSTRACT
xix
CHAPTER ONE
1.1 Introduction
The need to secure our homes, commercial complexes, industries and other related
properties is of much concern. A home security system should provide security and
safety features for a home by alarming the residents from natural and accidental dangers
such as; fire, flooding, theft, invading animals and leakage of cooking gas. Considering
the high rate of crime and insecurity, there is an urgent need to design a security system
that takes proper measure to prevent intrusion, unwanted and unauthorized user(s).
1
The design of the monitoring system has been influenced by today’s technological
advancements. There are different kinds of home security systems, but the basic types
are wireless security alarms, microcomputer based security system, motion sensor,
access control gates and wireless global service for mobile (GSM) based communication
system.
A wireless security alarm security system sends an alarm to the property owner before
intruders get in and summons help immediately. The microcomputer based security
system senses the presence of an intruder and alerts the user on the obstruction detected
and it also displays the position of the intruder on a screen. A motion sensor detects a
change in infrared light intensity and produces a signal which is used to raise an alarm.
This makes it hard for the intruder to get on the secured property by surrounding the
home with a high fence and installing an automatic access control gate. It also gives
specific points of entry onto the property and one can monitor the entry points from
inside. Wireless GSM communication system provide security from natural, incidental,
intended, unintended accidental and human made problems by continuously monitoring
homes with different sensory systems like motion, smoke, gas, temperature, glass break
or door break detectors and fire alarm systems, (Lakra,2015).
Many types of home security systems have been developed. Home or office automation
is the control of any or all electrical devices in our homes or offices (Kaur, 2010). This is
one of the most exciting developments in technology that has come along in decades.
There are hundreds of products available today that allow the control of devices
automatically either by remote control or bio-data such as face, prints etc. Most of these
systems are based on microprocessors or microcontrollers (Kaur, 2010). Microcontroller
is designed for a very specific task to control a particular system.
Some microprocessor and microcontroller based systems have been designed to control
the opening and closing of doors and gates and alert the owner in case of an intruder and
2
fire outbreaks. Lau and Choo (1989) designed a microprocessor based gate security
system. This system automatically controlled the visitors at the gate by use of a
password. The system design used microprocessor based card which used software to
control the password keys. There were four modules which included data module,
management mode, tenant mode and the alarm module
Another design and implementation of a smart home enabled the control of home
electronic devices remotely and produced an alert on intrusion or movement around the
restricted premises (Luitel, 2013). The devices were controlled by a mobile phone using
the short message service (SMS) and alerts were received as SMS message describing
the activity occurring around the premises.
From research conducted by Visa and Victor (2012), it was found that majority of the
existing car security systems use only alarm, and do not send text message to the car
owner let alone demobilizing the car. They designed a microcontroller based car anti-
theft security system using GSM network with text message as feedback. The need for
this arose due to the increasing rate at which parked cars are stolen. With this design a
parked car is monitored irrespective of where it is parked, provided there is GSM
network coverage. Diarah et al., (2014), describes a microcontroller code locking
systems with alarm. Code based locking system is best suited for most applications
because of its simplicity and reliability. Since such a system is always resident in the
area being protected, there are fewer chances of security breaches unlike the keycard
lock system in which the access card can fall into unauthorized hands. Furthermore, in
the issue of maintenance, the access code can easily be changed at will with lesser cost
unlike the keycard system where a new set of access cards are required.
3
Nwankwo and Nsionu, (2013) presented both design and the implementation of a
microcontroller based security door system using a mobile phone and a computer set.
The security door could either receive command through the mobile phone or through
the computer system configured to output data through the parallel port.
Hui, (2013) worked on a microcontroller-based lock using color security code. This
microcontroller based lock used the color sequence code as password to unlock the
system. The major drawback of this color code is the insensitivity of button since some
of the buttons have to be pressed using more force causing delay in the time for the
button scanning, data logging and mobile communication as this lock system used only
stored data in form of password. As this lock only operated with the random colour, it
would not suit the users who suffer from colour blindness. Another microcontroller
based home security system designed by Agarwal and Nayak (2012), utilized wireless
alerts using radio frequency (RF) signals as communication standards.
a. Intruder detection
In most of the security systems, detectors are used to achieve a secured home or office.
Passive infrared detector is widely used in presence detectors as a means of human
detection (Moghavvemi and Seng (2004). They worked on application of pyro electric
infrared sensor (PIR) and the application of processing algorithm in handling sensor
information so as to provide real time occupancy map on computer. The PIR sensor was
used to detect the presence of human in a protected room. Wireless communications
network using frequency modulation technique was developed to handle data
transmission through the air. The personal computer played a significant role in
providing the intelligent centralized controls of the entire system. A software package
was developed for visual display, control mechanism configuration, and embedded
server-client application. Alkhathami et al., (2015), researched on various border
intrusions detection systems with emphasis on wireless sensor detection method. The
system detects human and non-human intruders such as objects and animals. Thus, their
4
study aimed at ascertaining the intruder crossing a specified border or perimeter under
surveillance before raising an alarm.
Kumar, (2013) in his research developed an Arduino® based wireless intrusion detection
using IR sensor and GSM. This intrusion detection system (IDS) involves a software and
hardware tool used to detect unauthorized access of a computer system or network. A
wireless IDS performs this task exclusively for the wireless network through sensor
controlling with different workstations via internet. An IDS usually performs this task in
one of two ways, with either signature-based or anomaly based detection. Almost every
IDS today is at least in part signature-based. Attacks, which are unwanted intrusions,
and their tools usually have a unique signature that can be detected and/or found. This
means that known attacks can be detected by looking for these signatures. The drawback
with these systems is that they are easy to fool and can only detect attacks for which it
has a signature. These are not often implemented, mostly because of the high amount of
false alarms. An anomaly-based system develops a baseline of what it considers normal
traffic. Any time it detects traffic which deviates from what it considers normal an alert
is generated. The advantage is that it can catch many attacks that are new or unknown
and that would never be seen by signature-based IDS (Kumar, 2013).
MQ-4 gas sensor is made of porous SnO2 films with a high surface to volume ratio.
During operation the gas sensing material is heated. The exact fundamental mechanisms
that cause a gas response are still controversial, but essentially trapping of electrons at
adsorbed molecules and band bending induced by these charged molecules are
responsible for a change in conductivity. When a molecule adsorbs at the surface
electrons can be transferred to this molecule if the lowest lying unoccupied molecular
orbitals of the adsorbate complex lie below the Fermi level (acceptor levels) of the solid
and vice versa electrons are donated to the solid if the highest occupied orbitals lie above
the Fermi-level of the solid (donor levels). Thus molecular adsorption may result in a net
charge at the surface causing an electric field. This electrostatic field causes a bending of
5
the energy bands in the solid. A negative surface charge bends the bands upward, i.e.
pushes the Fermi level into the band gap of the solid, effectively reducing the charge
carrier concentration and resulting in an electron depletion zone. Depleting electrons
causes a positive space charge region that compensates for the negative surface charge.
The charge density distribution in the depletion zone can be determined by solving the
one dimensional Poisson equation:
𝑝(𝑧)=𝑒[𝑝(𝑧)−𝑛(𝑧)+,𝐷-+.(𝑧)−,𝐴-−.(𝑧)]=, Ɛ-𝑟.,Ɛ𝑜.,𝑑-2.𝑉/𝑑𝑧2........................................1.1
Where e is the elementary charge, p and n are the charge carrier densities, i.e. the
number of holes and electrons, and D+ and A are the densities of singly charged donors
and acceptors and Ɛr is the dielectric constant of the material. Charge neutrality of the
system invokes that integration of the charge q (z) over the entire volume has to be equal
to the surface charge trapped in the adsorbed molecule. Generally, the Poisson equation
cannot be solved analytically, but for the simplest case with negligible acceptor and hole
concentration (n-type semiconductor) and complete ionization of the donors, i.e. D+(z)
=D+= constant., the Poisson equation can be rewritten as
e n( z ) D r 0
d 2V
dz 2
............................................................................................. 1.2
Abrupt transition of the charges with n(z) = D+ in the bulk and n(z) = 0 in the space
charge region makes the first integration of Equation 4.2 straight forward and yields a
linear relationship of the electric field E:
dV eD ( z D)
E( z) ............................................................................................... 1.3
dz r 0
Where D is the Debye length or depth of the space charge region. Charge neutrality of
the system requires that the space charge is equal to the surface charge, i.e.
6
𝐷-+.𝐷=𝑁𝑠.........................................................................................................................1.4
molecules) per unit area. To find the variation of the potential in the space charge region
V eD z D 2 ............................................................................................................ 1.5
2 r 0
If we define the potential to be zero within the bulk V (z > D) = 0 and by using equation
4.5 to eliminate D the surface (z = 0) potential can be written as:
eD D 2
2
eN s
Vs ............................................................................................... 1.6
2 r 0 2 r 0 D
As a consequence of the charge carrier depletion zone in the presence of surface charges
the sheet conductivity r of the surface is altered. This change in conductivity is
commonly used as the signal in gas sensing devices and hence accounting of the shift of
the heating curves.
A gas detector detects the presence of gases in an area, often as part of a safety system.
A gas detector can sound an alarm to operators in the area where the leak is occurring,
giving them the opportunity to react to the leakage. Several authors have designed gas
detection systems (Williams and Keeling, 1998; Pregeij and Mozetic, 1999; Ichoku and
Kaufman, 2005; Priya et al., 2014). A gas leak detector circuit that detects the leakage of
liquid petroleum gas (LPG) and alerts the user through audio-visual indications has been
constructed (Priya et al., 2014). Further, the Mine Safety Appliances (MSA) Company
designed a ultrasonic gas leak detectors based on robust microphone technology that
7
detect leaks by sensing the distinct high frequency ultrasound emitted by all high
pressure gas leaks (www.msasafety.com accessed on 17th October 2021).
Murvay and Silea, (2012) in their work, identified a state-of-the-art method in leak
detection. They evaluated the capabilities of the techniques in order to identify the
advantages and disadvantages of using the leak detection solution.
In general, a molecule with N atoms has 3N – 6 normal modes of vibration, but a linear
molecule has 3N – 5 such modes, as rotation about its molecular axis cannot be observed
(Walker, 2008).
Table 1.1 shows the first four elements of alkane group of organic compounds and their
formulas. They are mostly used as fuels hence form high percentage of natural gas.
Cooking gas mostly consists of methane gas. Methane molecule consists of one carbon
and four hydrogen atoms (CH4). In methane C-atom is sp3-hybridized. One s-orbital and
three p-orbitals (2px, 2py, 2pz) of carbon atom undergo sp3-hybridization to produce four
sp3-hybrid orbitals. These sp3-hybrid orbitals are 109.5o apart. Each sp3-hybrid orbital
overlaps 1s-orbital of H-atoms. In this way four s-bonds are produced between C and
four H-atoms.
Table 1.1: The structural and molecular formula for methane, ethane, propane and
butane
The structure of a methane gas molecule is shown in Figure 1.2 (a and b).
8
Figure 1.1: (a) Structure of methane molecule, (b) Illustration of bonding angles in
methane molecule (Walker, 2008).
It is tetrahedral in structure, in which carbon is the central atom and four H-atoms are
surrounding it .in three-dimensions. The structure of any molecule is unique for all
molecules. Due to this uniqueness the infrared radiation interacts with the molecules
with different absorptions and transmittances.
The absorption of the infrared by these gases will be set as the values within which the
outputs will be active. This is described through the diffusion principle. The MQ-4 gas
sensor is an electrochemical gas detector operating under diffusion controlled
conditions. Sensitive material of MQ-4 gas sensor is tin (IV) oxide (SnO2) which has
lower conductivity in clean air. When the target combustible gas exist, the sensor’s
conductivity is higher along with the gas concentration rising. The principle of operation
is described as follows: gas molecules from the sample are adsorbed on an electro
catalytic sensing electrode, after passing through a diffusion medium, and are
electrochemically reacted at an appropriate sensing electrode potential. This reaction
generates an electric current directly proportional to the gas concentration. This current
is converted to a voltage for meter or recorder l readout.
9
The diffusion limited current, ilim, is directly proportional to the gas concentration
according to the simplified equation 1.7 (Wang, 1999).
nFADC
ilim .....................................................................................................................1.7
where ilim is the diffusion limited current in amps, F is the Faraday constant (96,500
coulombs), A is the reaction interfacial area in cm2, n is the number of electrons per
mole reactant, δ is the diffusion path length, C is the gas concentration in moles/cm3, and
D is the gas diffusion constant, representing the product of the permeability and
solubility coefficients of the gas in the diffusion medium.
An external voltage bias maintains a constant potential on the sensing electrode, relative
to a non-polarizable reference counter electrode in the two-electrode inter scan sensor.
Non-polarizable means that the counter electrode can sustain a current flow without
suffering a change in potential. Thus, the counter electrode acts also as a reference
electrode, eliminating the need for a third electrode and a feedback circuit, as would be
required for sensors using a polarizable air counter electrode.
10
factors can easily be adapted to the LM35. The LM35 has an output of linearity of +
10mV/°C with non-linearity of only ±¼°C over a temperature range of −55°C to 150°
and is accurate to within 0.5°C (at 25°C typically at room temperature). The LM35’s
low output impedance and linear output characteristic make interfacing with readout or
control circuitry easy. An inherent strength of the LM35 over other currently available
temperature sensors is that it is not as susceptible to large errors in its output from low
level leakage currents to readout or control circuitry especially easy. The device is used
with single power supplies, or with plus and minus supplies. As the LM35 device draws
only 60 μA from the supply and has very low self-heating of less than 0.1°C in still air.
The LM35 device is rated to operate over a −55°C to 150°C temperature range, while
the LM35C device is rated for a −40°C to 110°C range (−10° with improved accuracy).
Kaushik and Celler, (2006) in their paper states that all objects constantly exchange
thermal energy in the form of electromagnetic radiations with their surroundings. The
characteristics of the radiations depend on the object and its surroundings’ absolute
temperature.
Human bodies also emit radiation and the wavelength of these radiations can be
calculated using Wien’s law which is given in equation,
2898
max (cm) ............................................................................................................1.8
Temperature( K )
11
1.3 Statement of the problem
Gas leakages, fire outbreaks and human intrusion are some of the problems faced in our
homes and industries. Several advancements to solve these security problems have been
identified. Among the advancements is the use of MQ-4 gas sensor in gas leakage. The
sensor has been developed and tested under ideal conditions of its sensitivity. However,
different environments correlate differently on its sensitivity. The output sensitivity of
the MQ-4 gas sensor depends on the conductivity which in turn depends on environment
and correlate with ideal characterization. Therefore, the need to investigate its
characterization in real environment is key for optimum output. This research will
investigate the characterization of MQ-4 gas sensor in real environment in relation to
ideal sensitivity characterization. Intrusion to offices, homes and industries is a great
menace in our today world. PIR has played a key role in security advancement, but
further investigation on characterization of PIR sensor aimed at assessing the impact of
three factors; proximity, placement point of the PIR sensor for high recognition rate and
the sensors sensitivity are key. Fire outbreaks have been a great threat to both lives and
infrastructures hence, its prevention is paramount. The sensors over time have been
developed, but environmental factors especially air-mass has made them to fail
severally. The need to characterize the sensor depending on environment is key in
realisation of optimum results. The interfacing of these key sensors through a
microcontroller is key for the optimization of the home security system.
1.4 Justification
This research seeks to develop an integrated microcontroller based home security system
to detect intruders, fire outbreaks and gas leakage. The characterization of the MQ-4 gas
sensor will allow the sensor to adapt to different environments since its sensitivity
depends on the conductivity which in turn depends on environment. The characterization
of PIR sensor aimed at assessing the impact of three factors; proximity, placement point
of the PIR sensor for high recognition rate and the sensors sensitivity are key. This will
allow the system to optimize on intruder detection. The success of the research will build
12
a platform for upgrading the conventional security system to automated system that will
require little of human intervention. Additionally, it will provide a cost effective and
more efficient security system in areas such as homes as well as industries.
There is no optimization of the sensors in the security enhancement from the developed
integrated microcontroller based home security system.
The characterization and optimization of MQ-4 gas sensor, PIR sensor and temperature
sensor in an integrated microcontroller based home detection security system.
1. To characterize the MQ-4 gas sensor using standard prepared alcohol fluid and
correlation with ideal sensitivity characteristics of MQ-4 gas sensor.
2. To characterize the PIR sensor through the measurement of absorption of IR
radiation at different spatial positions and speeds in correlation with their
outputs in PIR sensor.
3. To optimize temperature sensor at different voltage levels.
4. To integrate the characterized and optimized sensors with a microcontroller and
output devices and test its performance
13
CHAPTER TWO
2.1 Introduction
This chapter discusses the instruments and procedures used in the design and calibration
of the MQ-4 gas sensor, the infrared sensor, the temperature sensor and integration of
these modules into a microcontroller based home security system.
An experimental set-up was designed in the laboratory. Data using the sensors was
captured and recorded. A programmed code was formulated for the integration of the
three sensors. Data recorded was analyzed and results presented.
The block diagram of Figure 2.1 shows the various modules which were integrated to
form the proposed home security system.
14
The system is composed of gas, fire/temperature and intrusion sensors. The gas sensor
detected any gas leakage and produced a signal which was fed to the comparator which
compared the gas concentration with a predetermined value. The signal strength was
dependent on the concentration of the leaked gas. If the signal was above the optimum
value for the sensor, the buzzer went on and the owner was alerted. The gas
concentration was then displayed on an LCD display. Simultaneously an SMS was send
to a configured SIM card for mobile alert.
The intruder sensor consisted of an IR source and two IR detector slots separated by a
distance in which the infrared rays from source were equally received. If any of the IR
rays directed from the slots was obstructed, the negative differential of IR intensity was
fed to the microcontroller as a signal. This signal was fed to the outputs which alerted
the owner through switch ON of buzzer, display on LCD and sending of short message.
The fire sensor detects any possible fire outbreak in the house. This is done by use of
piezoelectric disc. Once the predetermined value of the temperature was reached, a
signal code was fed into the microcontroller and an alert was send to the outputs. The
LCD displayed ‘FIRE’ and the buzzer went ON. A short message was sent to the
configured SIM card to alert the home owner.
The sensors experimental processes were set up and observations made over time. The
performance parameters for each sensor were put into consideration as discussed in the
methodology part. Results obtained were tabulated, analyzed and graphs drawn for
interpretation in chapter three.
2.3 The hardware design modules of the proposed microcontroller security system.
This section discusses modules shown in the Figure 2.1 in more details.
15
2.3.1 Gas sensor module
The gas sensor used was MQ-4 semiconductor sensor for cooking gas. Tin (IV) oxide
(SnO2) is the sensitive material of MQ-4 gas sensor which has a low conductivity in
clean air. When a target combustible gas exists, the sensor’s conductivity increases as
the gas concentration rises. Figure 2.2 shows a schematic diagram of the set up for
testing the MQ-4 gas sensor.
The heating voltage VH, supplies working temperature to the sensor, while VCC is the
source voltage and VRL is voltage drop across load resistance (RL). Internal resistance
A-B between points A and B of the gas sensor, varies with the concentration of the
target cooking gas. Point H-H represents the heating filament. The circuit can be
simplified as shown in Figure 2.3, where Rs is the MQ-4 gas sensor internal resistance.
The pin to Arduino sensor is used to get digital output from this pin, by setting a
threshold value.
16
Figure 2.3: Simplified circuit of MQ-4 gas sensor. RL and RS resistors are
connected in series.
Table 2.1 shows the datasheet of sensitivity characteristics of the MQ-4 gas sensor from
which the information was utilized in pre heating of the MQ-4 gas sensor.
17
2.3.2 Design and instrumentation of simulation circuit of the MQ-4 gas sensor
module.
Figure 2.4 shows the schematic diagram of the circuit topology designed and simulated
in electronic work bench software. The circuit consists of a battery (5V) which is the
voltage source of the circuit, resistor (R1) which represents the internal resistance of the
MQ-4 gas sensor and the variable resistor (R2) connected in series with R1. This
procedure was necessary in order to investigate the optimum resistance, R2 of the design
and establish their working values. The voltage drop across RL was measured at different
resistances and displayed on a digital display as shown in Figure 2.4. The virtual circuit
was thereafter tested by mounting it on a solder-less breadboard and the real data
collected for comparison with the synthetic data.
The resistance value of MQ-4 is different for various kinds and concentrations of gases
(Hanwei Electronics). So, when using this components, sensitivity adjustment was very
necessary. The manufacturer recommends the calibration of the detector for 5000 ppm
of CH4 concentration in air and value of load resistance (RL) about 20 KΩ (10 KΩ to 47
KΩ) be used. When accurately measuring, the proper alarm point for the gas detector
should be determined after considering the temperature and humidity influence.
18
The MQ-4 gas sensor hence needed heat-up time before the first usage. The enveloped
MQ-4 has 6 pins, four of them are used to fetch signals, and other 2 are used for
providing heating current. The two central pins of the MQ-4 gas sensor were used to
Eleven different methanol solutions of concentrations (ppm) 500, 1000, 2000, 3000,
4000, 5000, 6000, 7000, 8000, 9000 and 10000 were prepared through the procedure as
outlined by Tinas (2008). Volumes of 99.8% concentrated methanol were measured
using graduated pipette fitted with rubber pipette filler and solutions prepared using de-
ionized water. The measured concentrated methanol was added to a 250 ml volumetric
flask which contained de-ionized water. The mixture was stirred for 5 minutes so as to
ensure formation of homogenous solution. The solution was then topped up with de-
ionized water up to the mark. The concentration is a measure of the volume of methanol
in 1000 ml/l of the aqueous solution with de-ionized water. In this case, de-ionized water
is considered 0% concentration. The proportion of methanol in 1000 ml of the solution is
19
taken as the parts per million concentrations. The volume of methanol to be added to
make the required concentrations was deduced through several steps. The density, mass
and volume calculation can be done in the following way:
M V ......................................................................................................................................2.1
M V C................................................................................................................................2.2
M
V .........................................................................................................................................2.3
C
In this step, 1 liter 10000 PPM standard concentration of methanol fluid is mixed.
According to equation 2.1, the purpose is to get 1 liter 10000 PPM standard fluid and
10000 PPM equal to 10000 mg/l. Therefore; there is 10000 mg pure methanol in the
fluid. The mixing process will consider the mass of pure methanol, the density of
methanol at 20 degrees Celsius and the concentration of methanol fluid. Using equation
2.3 V equals to 12.6 ml. So, 12.6 ml of methanol was mixed with de-ionized water until
the whole volume was 1 liter. Now, there is a 1 liter 10000 PPM standard concentration
of methanol fluid mixed. This fluid includes 10000 mg pure alcohol and it follows that
10000 PPM equal to 10000 mg/l.
20
2.2.5 Experimental set up for gas sensor module
The diagram below shows the flow chart of the MQ-4 sensor sensitivity adjustment
process.
Collect data
Figure 2.5: Flowchart diagram of the MQ-4 sensor sensitivity adjustment process
An almost closed glass pot was used to create a closed and stable measurement
environment. An aluminum foil was used to totally cover the open of the glass pot. The
glass pot had a volume of 250 ml so as to provide space for the gas sensor and the
connecting wires of the circuit. Knowing the latent heat of vaporization of methanol at
25°C to be 37.43 kJmol-1, the normal room temperature could vaporize the methanol
solution. The ideal data sheet is as shown in figure 2.6 below.
21
Figure 2.6: Ideal sensitivity characteristics of MQ-4 gas sensor (Pololu robotics and
electronics)
2.3.1 Introduction
22
2.3.2 The PIR Sensor
The PIR sensor's internal design is depicted in Figure 2.7. The extremely high
impedance of the sensors is buffered by a junction gate field-effect transistor (JFET),
which has a very low noise floor. To increase its tolerance to noise, temperature and
humidity, the infrared radiation (IR) sensor utilized in this project is placed in a
hermetically sealed metal container. The sensor element is shielded by a window formed
of IR-trans missive material, which is generally coated silicon because it is relatively
accessible. The two balancing sensors are located behind the window.
23
concurrently affect both elements and cause them to create the same amount of output
but with opposing polarities, they will cancel each other out. When one of the sensor's
elements is exposed to a change in radiation while the other is at rest, the output voltage
of the sensor changes. The intruder's path is shown by the arrows A and B.
A positive differential shift between the two slots is recognized as a signal and recorded
as soon as the move of a heated body is observed. The sensor will produce a negative
differential change that can be observed once the heated body has left the sensing area.
What is detected are these change pulses.
The lens may quickly and simply alter the width, range, and sensing pattern. The
infrared light can trigger a signal in the sensor because of the substantially bigger
detecting area. Without a lens in front of the sensor, if an IR emitting body moves across
the sensor's front at a distance of 3 to 4 feet from the sensor, the radiated IR will expose
one element more than the other, producing a voltage output. There is no voltage output,
however, when the IR emitting body is farther from the sensor and its radiation pattern
blurs, exposing both elements more equally. The detection range of the sensor is
increased by placing a lens in front of it. The infrared light can trigger a signal in the
sensor because of the substantially bigger detecting area when an IR emitting body
rather than a lens is placed in front of a sensor. The sensors are actually Fresnel lenses as
24
a result. The Fresnel lens concentrates light, giving the sensor access to a wider range of
infrared radiation. Utilizing the materials at hand is essential to the project; one example
is the comparison of sensitivity and area coverage using basic lenses like those used in
cameras.
2.3.5 PIR sensor characteristics for objects at different distances and heights
The purpose of this study was to evaluate the effects of three variables on the proximity
and placement point of the PIR sensor for high recognition rate and sensor sensitivity,
namely the height of sensor location, the vertical distance between the PIR node, and
movement of the human body, including (i) across the detection area at different
distances for different walking speeds, (ii) walking towards the detector, and (iii)
walking away from the detector at different angles. The space is 7 m by 7 m in size. The
heights of the sensors are 0.5, 1.0, 1.5, and 1.8 m. The portions of the human knee, hand
swing, chest, and head are represented by heights of 0.5, 1.0, 1.5, and 1.8 m,
respectively. The test objects were asked to walk along the established six lines
indicated as 1,2,3,4 and 5 at various speeds. The heights of various human bodies are
shown in Table 2.2.
The output from all the items is captured when the subject passes over each arc or radial
line of the PIR detector. The detector's five analog signals are detected, and each signal
is given equal weight. Using equation 3.1, the results taken into consideration for the
analysis are computed.
25
X i X1 X 2 X 3 X 4 X 5 .....................................................................................................2.7
Where the raw output voltages for objects A, B, C, D, and E are X1, X2, X3, X4, and
X5. Equation 3.2 is used to determine the root mean square value of a detector output
voltage over an arc or radial line.
n
X i2
Vi i 1
...............................................................................................................................2.8
n
Where Xi is the detector output from equation 3.1 over an arc / radial line; and N is the
number of detector data points on a given arc/radial line.
Without requiring a lot of operator input, the temperature in the kitchen was monitored
and managed using the LM35 integrated circuit (IC) sensor. With an electrical output
o
proportional to the temperature (in C), the LM35 is an integrated circuit sensor that
may be used to measure temperature.
Precision integrated-circuit (IC) temperature sensors of the LM35 series have an output
voltage that is linearly proportional to the temperature in Celsius (Centigrade). Thus,
compared to linear temperature sensors calibrated in Kelvin, the LM35 has an advantage
because the user does not need to deduct a significant constant voltage from its output to
obtain suitable Centigrade scaling. The LM35 can give typical accuracies of 0.25°C at
room temperature and 0.75°C over the entire temperature range of 55 to +150°C without
the need for any external calibration or trimming. Trimming and calibration at the wafer
level ensure low cost. It is particularly simple to interface to reading or control circuitry
thanks to the LM35's low output impedance, linear output, and excellent intrinsic
calibration. It can be used with a positive or a single power source. Both a single power
26
supply and positive and negative power supplies can be utilized with it. It only draws 60
A from its supply, therefore it self-heats very slowly—less than 0.1 C in calm air. The
operating temperature range for the LM35 is 55 to 150 C, whereas that for the LM35C is
40 to 110 C. Hermetic TO-46 transistor packages are available for the LM35 family.
Figure 2.9 displays the LM35 IC's schematic diagram. The positive voltage supply pin,
known as +Vs, ranges in voltage from 4 to 20 volts. The analog output pin for the
temperature sensor is labelled OUTPUT. Its temperature range is between +2 o C to 150
o
C
An analogue to digital converter (ADC) is needed since the LM35's output is an analog
voltage that must be transformed into a digital signal before the microcontroller can
process it. For this procedure, an ADC 0831 analogue to digital converter will be
employed. Figure 2.10 displays the ADC 0831 IC's schematic diagram.
27
Figure 2.10: A schematic diagram of the ADC0831 ADC
The ADC0831's inputs and outputs are represented by the following notation: Vin (+)
serves as the analog input, while Vin (-) and Vref are utilized to bias the IC. D0 serves
as the serial output. For powering the IC, Vcc and GND are used. GND equates to Vss,
while Vcc is nearly the same as Vdd. Active low chip select (CS) and clock (CLK) are
the respective abbreviations. For binary control signals, both serve as inputs. The -CS
pin needs to receive a signal that starts high and goes low from the BASIC Stamp in
order to prime the ADC0831 for taking a measurement. Throughout the conversion, this
signal must remain low. The conversion should then begin at the subsequent clock pulse,
which must be indicated by sending one clock to the CLK input. A clock pulse for this
IC begins low, rises to a high, and then falls back to low. The conversion requires eight
more clock pulses to be completed. The CLK input receives a clock pulse, while the D0
output sends another serial bit each time.
The analogue digital converter's (ADC) primary use is to digitize a temperature sensor's
output. The LM35 is a simple-to-use temperature sensor. The LM35 produces a voltage
that is temperature-related. The most popular model of this measures temperatures
between 0 and 100°C by providing an output voltage equal to 10 mV times the
temperature in degrees Celsius. Therefore, 20 °C would result in 20 mV.
28
The device has three terminals i.e. 5V, ground and output as shown in the diagram of
Figure 2.11.
Figure 2.11: (a) Pin out diagram of LM35 temperature sensor (b): Schematic
diagram of LM35 temperature sensor connected to ADC0831 converter
The output acts like a voltage source whose voltage is proportional to temperature in
degrees Celsius, i.e.
To connect a potentiometer to an ADC converter and adjust the upper limit of the ADC
range, see Figure 2.10 (b). A display subroutine is created to print out the temperature in
degrees Celsius while Vref is set to be 0.51 V.
A little device that collects data and stores it for later retrieval can be useful at times.
The stamp may be quickly converted into a temperature logger that can be installed
somewhere to record temperatures at regular intervals. Other than its 9V battery, the
micro-controller doesn't require connection to any other computer or power source.
29
The data can then be downloaded onto another computer for analysis and long-term
storage when it is later brought back to the lab. The WRITE instruction is used in the
program below to store data permanently in EEPROM. For 1000 s (16.7 min), it records
temperatures every 10 s, and then it quits. The data must be obtained using a different
software, although downloading the retrieval program does not affect the recorded data.
The processor (the CPU), non-volatile memory for the program (ROM or flash), volatile
memory for input and output (RAM), a clock, and an input/output (I/O) control unit are
all found on a single chip in a microcontroller. A general block diagram of an Arduino
microcontroller is displayed in Figure 2.12. Before transferring the information to the
output devices, it receives the data or information from various sensors and compares it
with the relevant predefined limits.
A serial channel can be used by an Arduino to send or receive data. The Arduino can
communicate with any device that is capable of serial communication. Whatever
30
programming language is powering the other device is irrelevant. The "main" serial port
on the Arduino can be used, or one can reserve that channel for programming (and the
serial monitor in the development environment) and utilize two other pins for a second
serial link just for the external device. Some applications lack native serial capabilities,
such as Flash. They can still communicate with Arduino by using a middleman who acts
as a sort of "translator" and lets them speak to one another.
The on-board LED may be turned ON or OFF using an external switch and the Arduino
board. When the push button is not depressed, a switch coupled with a resistor ensures
that the Arduino's digital input pin 7 is always linked to a steady voltage of +5V. The
signal on pin 7 goes to ground (GND) when the push button is pressed. The Arduino's
+5V supply is simultaneously connected to GND, and a current resistor of 1 to 10 K is
employed to prevent short circuits. The input pin would act as though it were "floating"
anytime the pushbutton was not depressed if there was absolutely no connection
between pin 7 and +5V. This indicates that it is not connected to either GND or +5V,
allowing electrostatic noise to collect and cause an input to falsely trigger. The gas,
intrusion, and temperature sensors send analogue voltage signals to the Arduino Uno
microcontroller. After converting to digital signals, it determines if the received values
are within the microcontroller's predetermined range. If the signals fall within the
predetermined ranges, no alerts are sent to the owner; however, if they rise above the
predetermined ranges, signals are sent to the buzzer, LCD display, and authorized GSM
module.
The Arduino Uno microcontroller receives the analogue voltage signals coming from the
gas, intruder and temperature sensors. After conversion into digital signals, it checks
where the values received are within the set values for the microcontroller.
If the signals are within the set values the outputs the do not alert the owner, but if they
are above the set ranges then it sends signals to the buzzer, LCD display and to the
authorized GSM module.
31
2.6 LCD display
In order to display the data from the microcontroller, a liquid crystal display (LCD) is
used. Results from the gas sensor, intrusion detector, and fire/temperature sensor are
displayed on the 16*2 LCD monitor, which is part of the system.
2.7 Buzzer
When the sensor temperature reaches 40 °C or higher, when gas detection exceeds
697.01678 mV ppm, or when an intruder is discovered inside the sensor's detection
range, a buzzer is utilized to produce a sound. This buzzer was selected since it is
affordable, dependable, and easily accessible.
Short message transmission (SMS) over a GSM module is required to deliver this
information to the home owner or authorized agent in the event of a fire, intruder, or gas
leak detection.
The Figure 2.13 shows all connections of sensors and outputs to the Arduino Uno
microcontroller to implement the proposed microcontroller based home security system.
The 5V is supply voltage pin. The GND is ground pin. So, the gas sensor, temperature
32
sensor, and intruder sensor supply voltage, were provided by 5V. And all these three
devices should be connected to GND to consist a complete circuit.
Figure 2.13: Circuit diagram of the Arduino Uno based security system
Figure 2.14 flowchart shows how the sensors operate. The signal is transferred to the
programmable peripheral interface for comparison processing before being handed on to
the output devices by the MQ-4 gas sensor when it detects gas leakage and the threshold
point has been exceeded. The PIR detector and the fire/temperature sensor follow the
same pattern. The security system is said to be in a "idle" condition when there is no
detection. Figure 2.13: Circuit diagram of the Arduino Uno based security system.
33
2.11 System circuit diagram of the Software design
34
CHAPTER THREE
3.1 Introduction
This chapter presents and discusses the results of the data collected about the gas, PIR
and temperature sensors. According to the methodology information in the chapter 2, the
collected data has been presented in graphical forms. The sensors are then integrated
with the microcontroller to form the integrated security system.
Figure 2.4 shows a simplified circuit of calibrating the MQ-4 gas sensor as given by the
manufacturer and has been described in methodology in Chapter 2.
The formula of the sensing resistance RS, of the gas sensor is deduced from the data
sheet of MQ-4 gas sensor as:
V
RS CC 1 R L ...................................................................................................... 3.1
V RL
Resistor RL was carefully chosen using the data sheet to optimize the output results. The
value of RL was found to be 2.0 kΩ. According to Figure 2.6, methanol was used to
substitute for methane, since their sensitivity characteristics are similar. RS is the sensing
resistance of the gas sensor and it has a range depending on the type of the gas and
concentration. From the Figure 2.6 the ratio of Rs/Ro was found to be 4.5 in air. In order
to get the RS value, Ro was calculated in advance. The output voltage (VRL) was
measured in clean air and was equal to 0.6 V. Supply voltage (VCC) was measured to be
5.1V. Then according to equation 3.3, RS was calculated to be 15 k Ω in clean air. Since
Rs/Ro = 4.5 in clean air, RO becomes 3.33 k Ω. Because the value of Ro is constant
values of Rs are given in Figure 2.6 for different concentration. Finally, the output
35
voltage of the gas sensor, VRL, was calculated using equation. 2.6. From the ideal
characteristics, the ratio of Rs/Ro of the alcohol were obtained and used in calculation of
Rs using equation 3.3. From Figure 2.3, RL resistor and RS resistor are in a series
circuit. Ro is a constant of 3.33 kΩ as calculated in equation 3.3. Figure 2.6 shows the
ideal characteristics of the MQ-4 gas sensor as provided by the manufacturer. This is
before the MQ-4 is exposed to the methanol at different concentration in parts per
million.
The data of the MQ-4 gas sensor from the manufacturer is plotted in Figure 3.1 as a
graph of output voltage against the concentration in ideal conditions.
860
840
820
800
voltage (mV)
780
760
740
720
700
concentration (ppm)
Figure 3.1: A graph of voltage, VRL (mV) versus concentration (ppm) of methanol
for the MQ-4 gas sensor for methanol under ideal conditions.
The line of the best fit of Figure 3.1 is given by the equation𝑦=0.01599𝑥+697.02. From
the equation it follows that the MQ-4 gas sensor registered a voltage of 697 mV when it
was not exposed to alcohol.
36
3.2 Calibration of the MQ-4 gas sensor using methanol.
The plate below shows how the calibration of MQ-4 gas sensor was done. The methanol
gas which has similar characteristics as the LPG gas was used to collect the data.
Plate 3.1: The experimental arrangement set up to measure voltage drop across
resistor R L when the MQ-4 gas sensor is exposed to different concentrations of
methanol.
Figures 3.4 to 3.8 show the results for voltage of the MQ-4 gas sensor for one, two,
three, four and five days of pre-heating. In each figure the data is compared with the
theoretical value. The pre-heated MQ-4 gas sensor is exposed to methanol for five,
fifteen, thirty, and forty-five minutes and voltage recorded respectively.
37
after 5 mins
after 15 mins
850 after 30mins
after 45 mins
theoritical
800
750
voltage (mV)
700
650
600
550
500
0 2000 4000 6000 8000 10000
concentration (ppm)
Figure 3.2: Graph of output voltage (mV) versus concentration of methanol (ppm)
in different exposure-time after 24 hours of heating MQ-4 gas sensor.
From the graph profile the theoretical and experimental values differ so much hence the
optimum value could not be obtained after one day of pre- heating. After two days of the
pre-heating the MQ-4 sensor the results are plotted in Figure 3.3 were obtained. The
results shown is after the sensor was exposed to methanol gas for five, fifteen, thirty and
forty-five minutes respectively.
38
after 5mins
900 after 15mins
after 30 mins
after 45 mins
850 theoritical
800
voltage (mV)
750
700
650
concentration (ppm)
Figure 3.3: Graph of output voltage (mV) versus concentration of methanol (ppm)
in different exposure-times after 2 days of heating MQ-4 gas sensor.
From Figure 3.3 the graph the theoretical values and experimental values obtained after
2 days pre-heating of MQ-4 gas sensor were very close. The exposure time between 15-
30 minutes gave a close tally to our ideal conditions hence a high agreement between the
theoretical value and experimental value.
39
950 theoritical
after 5 mins
after 15 mins
900
after 30 mins
after 45 mins
850
voltage (mV)
800
750
700
concentration (ppm)
Figure 3.4: Graph of output voltage (mV) versus concentration of methanol (ppm)
in different exposure-times after 3 days of heating MQ-4 gas sensor.
A graph of voltage (mV) versus concentration of methanol (ppm) three days in different
heat-time. Figure 3.4 shows some deviation between the ideal conditions and the real
conditions. This may be attributed to a long pre-heating time of the MQ-4 gas sensor.
40
1000
950
900
voltage (mV)
850
800
after 5 mins
after 15 mins
750 after 30mins
after 45 mins
theoritical
700
Figure 3.5: Graph of output voltage (mV) versus concentration of methanol (ppm)
in different exposure-times after 4 days of heating MQ-4 gas sensor.
The results from Figure 3.5 shows a deviation of the theoretical results from the real
results. This may be attributed to more pre-heat up time of the MQ-4 gas sensor hence
not giving more optimum temperature.
41
after 5 mins
after 15mins
1000
after 30mins
after 45 mins
950 theoritical
900
voltage (mV)
850
800
750
700
concentration (ppm)
Figure 3.6: Graph of output voltage (mV) versus concentration of methanol (ppm)
in different exposure-times after 5 days of heating MQ-4 gas sensor.
Generally, the output voltage is almost stable after two days of pre-heating the MQ-4 gas
sensor which is shown in Figure 3.3. In Figure 3.2, the output voltage increase depends
on time and concentration. The methanol fluid is not easy to volatilize. Hence the more
the time allowed the more it volatilizes. The MQ-4 gas sensor will be ideal to use it after
exposing it to real environment for two days.
The formula of the sensing resistance RS, of the gas sensor is deduced from the data
sheet of MQ-4 gas sensor as shown in equation 3.3. The exposure of the gas to the MQ-4
gas sensor varies its conductivity hence the necessity to characterize it to the suitability
of environment. In our characterization the theoretical value was 697.02 mV. In our pre
heating process, this value is close after two days of heating. The optimum value in our
characterization is 699.00 mV. Methane sensor shares the same character with alcohol
sensor, which could be applied only after the same calibration procedure with alcohol
sensor. From the research, it can be inferred that the output voltage is almost stable after
48 hours of heating the MQ-4 gas sensor which is shown in figure 3.4. In figure 3.4 the
output voltage increase depends on time and concentration. The methanol fluid is not
42
easy to be volatilized. Hence the more time is allowed the more it volatilizes. After the
calculations of the gradients of the best fit lines of all the curves that the curve obtained
after 5 minutes exposure time and 2 days heat up time was close to the theoretical value
giving equation (4.1) It is within this curve the optimum value of concentration of the
gas is obtained so as to be used in the programming of the Arduino (UNO). Comparing
with the theoretical equation
The gradient percentage error is 1.75%. This may be attributed to: volatilization time
and diffusion rate of the gas.
This section presents results of PIR sensor after conducting to find the optimal values of
the height above the ground and horizontal distance for the placement of the PIR sensor
to detect intruders. This has been achieved through different placement points and use of
people with different heights and walking at different speeds. The results were collected
and recorded as tabulated in different tables discussed below. Figures 3.7 to 3.11 show
the PIR sensor outputs when walking at difference distances from the PIR sensor for
slow, normal and fast walking of the intruders.
43
2.0
1.8
voltage
1.6
(V)
1.4
Slow walking
1.2
Normal walking
Fast walking
0.0
0 1 2 3 4 5 6
Length (m)
Figure 3.7: The root mean square value of detector voltage at different distances at
different walking speed for PIR placed 0.5 m above the ground
In Figure 3.7 detector output for slow and normal walking rates between 1 to 3 meters
increase with increase in distance. From 3 to 6 meters the output is inversely
proportional to distance. This shows that detector sensitivity and recognition rate is quite
high when the object is walking at slow speed and in between 1 to 3 meters. The output
of fast walking shows detector sensitivity and recognition rate is quite low. The output
of all walking rates decrease from 3 m to 6 m. This show that the detector sensitivity and
recognition rate is quite low as the distance increases from 4 meters.
44
2.8
Slow walking
2.7 Normal walking
Fast walking
2.6
2.5
2.4
Voltage (V)
2.3
2.2
2.1
2.0
1.9
1 2 3 4 5 6
0
Arc Radius ( )
Figure 3.8: The root mean square value of detector voltage at different distances
and different walking speed for PIR placed 1.0 m above the ground.
Figure 3.8 shows the output characteristics of the sensor when placed at 1.0 m above the
ground. The characteristics of the walking rate curves tend to be similar to the ones of
Figure 3.9 but differ with the output values. The detector sensitivity and recognition rate
when the sensor is placed at 1-meter height is higher compared to when is placed at 0.5
meters. This may be contributed by the hands movement. The hands are also a source of
the infrared radiation hence higher detection.
45
2.20 Slow walking
Normal walking
2.15 Fast walking
2.10
2.05
Voltage (V)
2.00
1.95
1.90
1.85
1.80
1.75
1 2 3 4 5 6
0
Arc Radius ( )
Figure 3.9: The root mean square value of detector voltage at different distances at
different walking speed for PIR placed 1.5 m above the ground
Figure 3.9 shows that detector sensitivity and recognition rate is quite high when the
object is walking at slow speed and in between 1 to 3 meters for a PIR placed 1.5 m
above the ground. The output is higher than when the sensor is placed at 0.5 meters but
less than when the sensor is placed at 1.0 meters. This may be attributed to the fact that
at 1.5 m fewer body parts are being detected by the PIR sensor.
46
Slow walking
1.20 Normal walking
Fast walking
1.15
1.10
1.05
Voltage (V)
1.00
0.95
0.90
0.85
0.80
1 2 3 4 5 6
distance (m)
Figure 3.10: The root mean square value of detector voltage at different distances
at different walking speed for PIR placed 1.8 m above the ground
The output trend of the sensor placed at 1.8 meters differs with the ones of 0.5, 1.0 and
1.5 meters. This is because it only corresponds to the human head. The detector
sensitivity and recognition rate is below 1.2 V hence quite low. The sensitivity for the
movements towards and moving away from the detector was tested for slow, normal and
fast walking speed.
The PIR output voltage (mV) for different arc radii of motion of intruder when walking
towards the PIR sensor at different angles for PIR positioned 0.5 m above the ground.
Figures 3.13 to 3.16 show the output voltages (mV) when walking towards the PIR
sensor different angels when the PIR sensor was positioned at 0.5 m, 1.0 m, 1.5 and 1.8
m, respectively above the ground.
47
Slow walking
Normal walking
1.40 Fast walking
1.35
1.30
1.25
Voltage (V)
1.20
1.15
1.10
1.05
1.00
0 20 40 60 80 100
0
Arc radius ( )
Figure 3.11: Detector sensitivity at different angles when the subject walked
towards the detector at different walking speeds sensor placed at 0.5 m above the
ground
Figure 3.11 shows that the detector sensitivity is relatively constant from 30o to 70o
when the movement is towards the detector at slow and normal walking speed and is
quite poor at the extreme ends. The highest output of all walking rates is at 50o. The
sensor output is reduced for fast walking speed compared to the normal or slow walking.
This is due to minimized interaction between the sources (intruders) of the infrared with
the detector.
48
Slow walking
1.5 Normal walking
Fast walking
1.4
1.3
1.2
Voltage (V)
1.1
1.0
0.9
0.8
0.7
0.6
0 20 40 60 80 100
0
Arc Radius ( )
Figure 3.12: Detector sensitivity at different angles when the subject walked
towards the detector at different walking speeds sensor placed at 1 m above the
ground.
Figure 3.12 shows a steady increase of sensitivity to arc radius of 600 and a drop towards
1000. This shows it is within this angle of 450-600 that it gives high output signal.
49
Slow walking
1.4 Normal walking
Fast walking
1.2
1.0
Voltage (V)
0.8
0.6
0.4
0 20 40 60 80 100
0
Arc radius ( )
Figure 3.13: Detector sensitivity at different angles when the subject walked
towards the detector at different walking speeds sensor placed at 1.5 m.
The sensitivity output seems to be high in between the angle 450 to 600. The slow
walking seems to give the highest output.
50
Slow walking
Normal walking
1.2 Fast walking
1.0
Voltage (V)
0.8
0.6
0.4
0 20 40 60 80 100
0
Arc radius ( )
Figure 3.14: Detector sensitivity at different angles when the subject walked
towards the detector at different walking speeds sensor placed at 1.8 m.
From Figure 3.13 the sensitivity of the detector decreases. This may be due to the
position of the detector above the ground.
Figures 3.15 to 3.18 show the output voltages (mV) when walking away from the PIR
sensor at different angels when the PIR sensor was positioned at 0.5 m, 1.0 m, 1.5 and
1.8 m, respectively above the ground.
51
Slow walking
Normal walking
Fast walking
1.6
1.4
Voltage (V)
1.2
1.0
0.8
0 20 40 60 80 100
Figure 3.15: Detector sensitivity at different angles when the subject walked away
from PIR sensor at different angles with the PIR sensor positioned 0.5 m above the
ground.
52
Slow walking
1.6 Normal walking
Fast walking
1.5
1.4
Voltage (V)
1.3
1.2
1.1
1.0
0 20 40 60 80 100
0
Arc radius ( )
Figure 3.16: Detector sensitivity at different angles when the subject walked away
from PIR sensor at different angles with the PIR sensor positioned 1.0 m above the
ground.
Figure 3.16 shows the output is higher when the detector is placed at 1.0 m. in addition
at slow walking the output is higher than normal and fast walking. This may be
attributed by the fact that more interactive time of the radiation and detector is allowed
during slow walking.
53
slow walking
1.5 normal walking
fast walking
1.4
1.3
1.2
1.1
voltage (V)
1.0
0.9
0.8
0.7
0.6
0.5
0 20 40 60 80 100
angle(0)
Figure 3.17: Detector sensitivity at different angles when the subject walked away
from PIR sensor at different angles with the PIR sensor positioned 1.5 m above the
ground.
Figure 3.17 shows the output is slightly less than when it is placed at 1.0 m above the
ground. Slow walking also gives more output than normal and fast.
54
Slow walking
1.2
Normal walking
1.1 Fast walking
1.0
0.9
0.8
0.7
Voltage (V)
0.6
0.5
0.4
0.3
0.2
0.1
0.0
0 20 40 60 80 100
0
Arc Radius ( )
Figure 3.18: Detector sensitivity at different angles when the subject walked away
from PIR sensor at different angles with the PIR sensor positioned 1.8 m above the
ground.
From figure 3.11 to 3.12 the output voltage increases with the height of the sensor above
the ground and is maximum for a distance of 1.0 m (Figure 3.14) and starts to decrease
with increase in height.
Generally, from all the graphs the PIR sensor gives higher output during slow walking
and is least for fast walking. Comparatively normal walking has higher output compared
to the fast walking. From figures 3.15 to 3.18 it can be seen that the output voltage
increases as the height of the PIR sensor is increased from 0.5 m (Figure 3.15) a distance
of 1.0 m (Figure 3.16) and then decreases to 3.20 been highest at Figure 3.16 when the
detector is placed 1.0 m above the ground. Generally the output is higher when the
object walks towards than when it walks away. A passive infrared sensor (PIR sensor)
being an electronic sensor that measures infrared (IR) light radiating from objects in its
field of view. And mostly are used in PIR-based motion detectors. From figures 3.8 to
3.19 shows the trend of increase and decrease of the voltage output when objects walk
55
away and towards the sensor. The maxima arc radiation range is 550 - 600. The y-
intercept range is below the curves of the walk towards. The maxima output voltage is at
1.46 V which may be attributed to the object direction. In both cases, (object walking
away and towards) there is an increase of the voltage output, but the object walking
towards is greater than walking away.
The LM 35 is an analog linear temperature sensor. The LM35 was connected to the
Arduino UNO through the breadboard. The Vcc pin was connected to the 5V pin, the
Vout was connected to the analogue pins while the GND was also connected to the GND.
Table 3.19 shows the temperature against voltage when LM35 was exposed to different
temperatures. This data is plotted in the graph of Figure 3.21.
voltage
700
600
voltage (mV)
500
400
300
200
20 30 40 50 60 70
o
temp T ( C)
Figure 3.19: A graph of Temperature (0C) against Output voltage (mV) of the LM3
temperature Sensor.
56
Figure 3.19 shows that the voltage is directly proportional to the temperature change.
This is to the fact that the voltage is directly proportional to resistance. Increase in
temperature causes more vibrations of molecules of a conductor hence increase in
resistance. Temperature is a parameter which has been measured in three major ways:
air, ground, and via satellite observation. Most of the fires ignite from temperatures as
low as 40 0C. The calibrated temperature sensor threshold was put at 40 0C so as to alert
the owner at temperatures above.
The calibrated sensors were then integrated into the microcontroller as shown in plate
3.1 and 3.2.
Plates 3.1 and 3.2 show all connections of calibrated sensors and outputs to the Arduino
Uno microcontroller connected to a power supply. The PIR and MQ-4 sensors were
connected to ground (GND) to make the complete circuit.
Plate 3.2: MQ-4 gas sensor and the PIR sensor connected to the Arduino UNO.
57
Plate 3.3: The Arduino UNO security system connected to the power supply.
The calibrated gas sensor detected any gas leakage and produced a signal which was fed
to the Arduino UNO which compared the gas concentration with an optimal calibrated
value. The signal strength was dependent on the concentration of the leaked gas. If the
signal is above the optimum value for the MQ-4 gas sensor, the buzzer went on and the
owner was alerted through an SMS written ‘FIRE’. The gas concentration is then
displayed on an LCD display. Sample results obtained are displayed in Plate 3.4 for a
gas concentration of 590 ppm, temperature of 28 0C and humidity of 50%. This shows
the security conditions are within the normal range therefore no message was sent to the
mobile phone.
58
Plate 3.4: The LCD display when the system under normal conditions of
temperature and gas concentration.
When the temperature was above the threshold (40 0C) and the gas concentration was
below the concentration threshold, (697 ppm), the buzzer goes ON and the display is
shown in Plate 3.5 (a) and message ‘FIRE’ is sent to the mobile phone number as in
Plate 3.5 (b), to warn the home owner.
59
Plate 3.5: a. The temperature is above 40 0C and the buzzer goes on and the red
signal light goes on continuously to indicate there is a danger. b. The short message
of fire sent to home owner mobile phone
When an intruder was detected, the PIR sensor signal fed to the Arduino UNO compared
the output data with the optimal value of the calibrated sensor. If the value surpassed the
optimal value a signal is send to the outputs which alerted the owner in two modes: the
buzzer goes ON and a short message written ‘INTRUDER’ is send to the home owner as
shown on Plate 3.6.
60
Plate 3.6: The picture of short message of intruder send to home owner mobile phone.
The integrated security system of the sensors was able to execute the signal as expected.
The gas sensor signal was fed to the Arduino Uno and if the threshold limit was above,
the output devices alerted the home owner through raising of an alarm, sending an SMS
and displaying it on LCD display. In case of an intruder or fire outbreak the same
process of the signal sending would be repeated and the owner alerted.
61
CHAPTER FOUR
4.1 Conclusion
The above calculated variations of the space charge, electric field, and potential energy
indicates that the amount of band bending depends only on the surface charges and the
concentration of ionized donor atoms or defects hence the concentration of the leaked
gas was key if a signal was to surpass the threshold voltage .
The spectrum of a single PIR sensor’s temporal signal (analogue feature) is used to
represent the human motion features. Decreased sensitivity to walking speeds, is been
realized. The higher the speed of the object, the low the output of the signal and vice
versa. The coverage area in which the intrusion is suspected to take place the PIR should
be placed in such a manner the angles of in between 550- 600 faces it. Temperature at
which the operation of the security system was taking place was monitored. Any fire
outbreak alertness was on high percentage of preciseness.
Generally the home security system was functional and the sensors worked at very high
precision.
4.3 Recommendations
The home security system has considered only one point of placement of the PIR sensor,
where else if more of the PIR sensors can be placed at different points more precise
results may be realised. In addition, the placement point the MQ-4 gas sensor is key. The
identification performance in the PIR sensor can be improved by increasing spatial
sampling frequency.
62
The temperature sensor may be integrated further with the house fan so as to switch it on
to incorporate more aeration. Integration of more sensors to the security system will
make it more helpful and reliable to home owners.
63
REFERENCES
Agarwal, N., & Nayak, S.G. (2012). Microcontroller based Home Security System with
Remote Monitoring, International Journal of Computer Applications, 38-41.
Alkhathami, M., Alazzawi L., & Elkateeb A. (2015). Model and Technique analysis of
boarder intrusion detection systems. Global journal of researchers in
engineering 15(7), 1-11
Celeste, Tholen, (2021). Gate Control Automatic gates, Smart Home Automation
Brigadier Sea l Master, 755.
Diarah, R.S., Egbun,e D.O.,& Adedayo, B.A. (2014). Design and Implementation of a
Microcontroller Based Automatic Door and Visitors Counter, International
Journal of Scientific Research and Education, 2, 532–552
Gwagwa, O.T. (2010). Design and construction of microcontroller mains switch control
system, Master’s thesis, Nnamdi Azikiwe University, Nigeria.
Hui, T.D. (2013). Microcontroller-based lock using colour security code. Undergraduate
project paper, University of Malaysia.
Ichoku, C., & Kaufman Y.J. (2005). A method to derive smoke emission rates from
MODIS fire radiative energy measurements, Geoscience and Remote Sensing,
IEEE Transactions, 43, (11).
Kaufman, Y.J., Justice, C.O., Flynn, L.P., Kendall, J.D., Prins, E.M., Giglio L., …&
Setzer A.W. (1998). Potential global fire monitoring from EOS-MODIS, Journal
of Geophysical Research, 103, 10-15
64
Kaur, I. (2010). Microcontroller Based Home Automation System with Security,
International Journal of Advanced Computer Science and Applications, 1(6),
2360-2363
Kumar, P., & Kumar P. (2013). Arduino based wireless intrusion detection using IR
sensor and GSM. International Journal of computer science and mobile
computing. 2(5), 417-424
Kaushik, A. R., & Celler, B. G. (2006). Characterization of passive infrared sensors for
monitoring occupancy pattern. Conference proceedings: Annual International
Conference of the IEEE Engineering in Medicine and Biology Society. IEEE
Engineering in Medicine and Biology Society. Annual Conference, 2006, 5257–
5260. https://doi.org/10.1109/IEMBS.2006.260207
Lakra, P., & Gupta, D.R. (2015). Microcontroller Based Automatic Control Home
Appliances. Retrieved from https://www.semanticscholar.org/paper
Lau, K.T., & Choo, Y.K. (1989). A microprocessor-based gate security system, Institute
of Electrical and Electronics Engineering Transactions on Consumer
Electronics, 35(4), 858-862.
Liu, S., Keeler, G. A., Reno, J. L., Sinclair, M. B., & Brener, I. (2016). III–V
semiconductor Nano resonators—a new strategy for passive, active, and
nonlinear all‐dielectric met materials. Advanced Optical Materials, 4(10), 1457-
1462.
Luitel, S. (2013). Design and Implementation of a Smart Home System. Thesis, Helsinki
Metropolia University of Applied Sciences, Finland.
Moghavvemi, M., and Seng, L. (2004). Pyroelectric infrared sensor for intruder
detection in Malaysia. Department of electrical and Telecommunications
65
Engineering. Proceedings of November 21-24, University of Malaysia, Malaysia,
656-659
Murvay, P., & Silea, L. (2012). The state-of-the-art in leak detection and localization
methods, Journal of loss prevention in the process industries, 25(6):966-973
Nwankwo N., & Nsionu, I., (2013). Design and Implementation of Microcontroller
Based Security Door System (Using Mobile Phone & Computer Set), Journal of
Automation and Control Engineering, 1(1), 65-69
Pregeij, A., & Mozetic, M. (1999). Leak Detection Methods and Defining the Sizes of
Leaks. In the 4th International Conference of Slovenian Society for
Nondestructive Testing, 4(2).
Priya, K.P., Surekha, M., Preethi, R., Devika, T., & Dhivya, N. (2014). Smart Gas
Cylinder Using Embedded System, International Journal of Innovative Research
in Electrical, Electronics, Instrumentation and Control Engineering, 2, 958-962.
Visa, M.I., & Victor, A.A. (2012). Microcontroller Based Anti-theft Security System
Using GSM Networks with Text Message as Feedback, International Journal of
Engineering Research and Development, 2(10), 18-22
Walker, J. (2008). Fundamentals of Physics. (8th Ed.). John Wiley and Sons.
Williams, E.W., & Keeling, A.G. (1998). Thick film tin oxide sensors for detecting
carbon monoxide at room temperature, Journal of Materials Science: Materials
in Electronics, 9(1); 51-54.
Zeng, W. (2011). High performance piezoelectric materials and devices for multilayer
low temperature cofired ceramic based micro fluids systems. Ph.D. Thesis,
University of Kentucky, Kentucky.
66
APPENDICES
Appendix I: The program for running the software for the integrated Arduino
microcontroller based security system.
67
68
69
70
Appendix II: List of Publications
1. Sakayo N.M., Mutuku J.N and Ngaruiya J.M. (2019). Design and Calibration of
a Microcontroller Based MQ-4 Gas Sensor for Domestic Cooking Gas System.
2. Sakayo N.M., Mutuku J.N and Ngaruiya J.M. (2019). Design and Calibration of
71