Home Automation Using Arduino and PIR
Home Automation Using Arduino and PIR
Project report
On
BACHELOR OF TECHNOLOGY
In
ELECTRONICS AND COMMUNICATION ENGINEERING
By
SUBMITTED TO
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
CERTIFICATE
This is to certify that the Project report entitled “HOME AUTOMATION
USING ARDUINO AND PIR SENSOR” That is being submitted by
M. V. N. D. S. VAMSHI (166F1A0443), T. PRASANNA (166F1A0460),
K. SRINIKA (166F1A0433), P. RAKESH (166F1A0450). In partial fulfillment of
the requirements for the award of BACHELOR OF TECHNOLOGY to
Jawaharlal Nehru Technological University, Hyderabad. is a record of bonafide
work carried out by our Guidance and Supervision. The results embodied in this
work have not been submitted to any other University or Institute for the award of
any degree or diploma .
First we would like to thank our project guide Mr. P. ANIL KUMAR,
Asst. Professor. In Department of E.C.E., for his inspiration, adroit guidance and
constructive criticism for completion of my degree.
We are very much thankful to our beloved management members for their
help in providing good facilities in our college.
M.V.N.D.S.VAMSHI (166F1A0443)
T. PRASANNA (166F1A0460)
K. SRINIKA (166F1A0433)
P. RAKESH (166F1A0450)
ABSTRACT
This paper reports on a system that can save electricity. Many times, we leave
the room and hall without switching off lights and fans, thus electricity is waste. In
this work, we have presented a system in which energy will be saved based on the
number of people entering or leaving out of the room. If there is no person in the
room, then light and fan will be switched OFF. On the other hand, as soon as any
person enters the room, light and fan will be switched ON.
The main components used in this system are Arduino Uno, PIR sensor and
Relay Module. Out of these components, the operation of system mainly depends on
PIR sensor which helps in detecting human presence. Experimental results show that
at least 50% of power can be saved by using the proposed system. Simultaneously we
can vary the speed of the fan sensing the room temperature. The more temperature the
more speed of the fan. A smoke sensor module is used for detecting any smoke within
the room and provides safety by alarming the audio device.
CONTENTS
Page No.
LIST OF CONTENTS I
LIST OF TABLES IV
GLOSSARY V
1 INTRODUCTION 1
1.1 Introduction 1
2 LITERATURE SURVEY 4
2.4 Objective 7
2.11 Breadboard 22
2.13 Resistor 23
I
3.5 Working 27
4.1 Result 28
5 SOFTWARE TOOLS 30
5.3 Libraries 31
II
LIST OF FIGURES
Figure No Name of the figure Page No.
2.1 Description of Arduino nano 8
2.11 LED 19
2.14 Breadboard 22
III
LIST OF TABLES
Table No Name of the table Page No.
1.1 Required intensity of light of various environments 2
IV
GLOSSARY
ACRONYM DESCRIPTION
PLC Programmable Logic Controller
IR Infrared Radiation
V
Home Automation Using Arduino and PIR Sensor
CHAPTER-1
INTRODUCTION
1.1 INTRODUCTION
Scientific inventions have made this world worth living. They have provided
us comforts and luxuries. Technology has become an important and necessary part of
our lives. In the last few years, there is tremendous advancement in technology. So,
human life becomes more dependent on these technologies. The invention of
Electricity is one of the greatest of all its inventions. Electricity has become an
indispensable part of human life. Electricity is considered as the soul or the life
without which the entire world remains dead and dormant. To provide more comforts
to human there is a technology called as Home Automation. When there is control of
all household amenities and appliances together with the use of technology then it is
termed as Home Automation. As non-renewable sources are decreasing day by day,
there is need of conservation of energy. Electricity is the most important to all the
activities of modern society. Hence, wise use of non-renewable energy sources must.
Home Automation gives energy efficient room by observing and controlling different
devices. Now a days, the issues related to energy become main problem. In this
modern world people are in a hurry and hence forget to turn OFF the lights and fans.
Power saving has become a necessary thing in our day-to-day life. Many
conventional power saving methods such as using electrical devices which consumes
very less energy or cutting off the entire power supply for a scheduled time for a
particular area are not efficient and there will be a lot of discomforts to the users and
cost may also increase to use a low power electrical device. Buildings are responsible
for up to 40% of energy usage. Most part of this energy is used mainly for maintaining
good lighting such that the workers feel comfortable. Nowadays the newly constructed
modernized or automated buildings may have lighting system to improve the comfort
of occupants and to save energy. However, there are a greater number of old
buildings, which contains the traditional lighting system. To reduce the energy
consumption in those types of buildings and to help the owners of that building in
terms of saving electricity bill an intelligent and an effective method is to discuss in
this paper. Because of advancement in Sensor technology a very cheap and portable
methods to measure our surroundings are available.
Painting 750lux
Classrooms 300lux
Auditorium 500lux
Assembly(Industry) 1000lux
sensors are used to the heat of the human body and it will turn on the electrical appliances.
Arduino mini pro is used to control the PIR sensor and electrical appliances. Relay modules
are used to control the electrical appliances.
In such a situation, this project which is a part of ho saves electricity. On the basis of
human presence in a particular area of the room, the electrical appliances can be switched
ON or OFF automatically. This is the main advantage of this system.
CHAPTER-2
LITERATURE SURVEY
2.1 LITERATURE REVIEW
Literature survey is the study of already established systems and collection of
information which helps in doing new tasks.
Vibhuti
A system which operates with control of relays and with the use of WAGO
PLC (Programmable Logic Controller) and Arduino Uno. Switching operation of
devices such as tube light, fan, AC, etc. can be operated spontaneously by using PIR
sensor and on the basis of environmental conditions. In real-time implementation,
automatic control is done by sensor data and manual control is done by android
application.But, difficulty in this paper is the controlling and monitoring of devices
done by WAGO PL and Arduino Uno both. These operations can be done by using
only Arduino Uno.
Maslekar
A proposed a smart lighting system in which Raspberry Pi has used.
Raspberry Pi is monitoring lights and fans simultaneously. In the absence of person
room lights and fans will automatically turns OFF. Energy is preserved by using this
smart lighting system. The experimental results of this system have shown that 50%
energy is conserved. But the difficulty is Raspberry Pi is more expensive than
Arduino Uno.
Automatic Lighting and Control System for Classroom in which electrical
light is controlled by Bluetooth, PIR sensor and relay. To switch ON or OFF the light
Bluetooth module is connected to Arduino Uno which sends voice command from
Arduino Uno by using the mobile android application. The experimental results have
shown the 50% energy is conserved. But this paper can be implemented by removing
the Bluetooth module as well.
In the disquisitions speak about automatic room light system by using visitor
counters operation. Depending upon the human presence, the room lights ON or OFF.
There is no need of manual operation for switching. The PIR sensor is used to the
human presence which is at the entrance of room. As visitor counter is used, there is
increment in the counter when a person enters into the room and this leads to turn ON
the room light which is controlled by micro controller program. If a person exits the
room, the counter decremented and this leads to turn OFF the lights. When all persons
left the room then only lights in the room switched OFF. The difficulty in this system
is that the door of room should not allow more than one person at a time.
Vahid
A proposed system whose control is dependant on Arduino micro
controller,network communications and Mod bus industrial protocol. Arduino
Ethernet shield and a wireless router device is used to build the network
communication. The specific Android application is used to load the Mod bus
program into mobile or Windows software named "mypro" and on Arduino board,
Arduino code loaded through USB (Universal Serial Bus) cable. There is inter-
connection between Arduino Ethernet Shield and mobile through Ethernet cable and
router. By connecting to the router, users can control and monitor the appliances
easily.The Table 2 summarizes the available methods in Literature survey.
that energy loss is occurred with a lighting system when the lighting system
illuminates a light which is an area which is not being used currently at that particular
time or when it illuminates a light even though sufficient lighting is available to work.
The most commonly used lighting systems are explained below.
resistors are lower in cost, bi-directional and offer moderate response time. Photo-
diodes offer quick response time, lower in cost and provide digital output. Photo-
transistors are very fast and provide immediate output compared to photo-
resistors.Photo-transistors generate high current compared to photo-diodes.
2.4 OBJECTIVE
● To study the design procedure of automatic room light control.
● Study different electrical parts and elements.
● Study about Arduino uno.
● Study Arduino programming language.
● To control lighting system ON/OFF.
2.5 THEORY OF THE PROJECT
To implement the desired project,our target is to arrange all the required
components and modules as per the circuit diagram and practical functioning status
observation of components.The required components and description are as follows-
2.6 REQUIRED COMPONENTS
● Arduino UNO
● PIR(Passive Infra-red) sensor
● Relay module
● Breadboard
● LED
● Power supply
● Connecting wires
If you do not have a relay module use the following components:
● 5V Relay
● 2N2222 (or BC547) NPN Transistor
● 1N4007 PN Junction Diode
● 1KΩ Resistor (1/4 Watt).
2.7 ARDUINO NANO
The Arduino Nano is a small, complete, and breadboard-friendly board based
on the ATmega328 (Arduino Nano 3.0) or ATmega168 (Arduino Nano 2.x). It has
more or less the same functionality of the Arduino Duemilanove, but in a different
package.
component Specification
2.7.4 COMMUNICATION
The Arduino Nano has a number of facilities for communicating with a
computer, another Arduino, or other microcontrollers. The ATmega168 and
ATmega328 provide UART TTL (5V) serial communication, which is available on
digital pins 0 (RX) and 1 (TX). An FTDI FT232RL on the board channels this serial
communication over USB and the FTDI drivers (included with the Arduino software)
provide a virtual com port to software on the computer. 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 FTDI chip and USB connection to the computer (but not for serial
communication on pins 0 and 1).
radiation can be detected by electronic devices designed for such a purpose. PIR
sensors are called passive devices as they do not emit any energy to detect the
presence of objects.PIRs are basically made of a pyroelectric sensor which can detect
levels of infrared radiation. Everything emits some low-level radiation, and the hotter
something is, the more radiation is emitted. The sensor in a motion detector is actually
split in two halves. The reason for that is that we are looking to detect motion (change)
not average IR levels. The two halves are wired up so that they cancel each other out.
If one half sees more or less IR radiation than the other, the output will swing high or
low.
your Arduino. Power the PIR with 5V and connect ground to ground. Then connect
the output to a digital pin.
preference will be given to reduce the noise of the whole circuit. For high voltage
applications, they are mainly designed to reduce a phenomenon called arcing.
2.9.5 RELAY APPLICATIONS
Relays are used to protect the electrical system and to minimize the damage to
the equipment connected in the system due to over currents/voltages. The relay is
used for the purpose of protection of the equipment connected to it. These are used to
control the high voltage circuit with low voltage signal in applications audio
amplifiers and some types of modems.
These are used to control a high current circuit by a low current signal in the
applications like starter solenoid in automobile. These can detect and isolate the faults
that occurred in power transmission and distribution system. Typical application areas
of the relays include
● Lighting control systems
● Telecommunication
● Industrial process controllers
● Traffic control
● Motor drives control
● Protection systems of electrical power system
● Computer interfaces
● Automotive
● Home appliances
2.10 LED(Light Emitting Diode)
Light Emitting Diodes (LEDs) are the most widely used semiconductor diodes
among all the different types of semiconductor diodes available today. Light emitting
diodes emit either visible light or invisible infrared light when forward biased. The
LEDs which emit invisible infrared light are used for remote controls. Light Emitting
Diode (LED) is an optical semiconductor device that emits light when a voltage is
applied. In other words, LED is an optical semiconductor device that converts
electrical energy into light energy.
Figure.2.11: LED
2.10.1 LAYERS OF LED
A Light Emitting Diode (LED) consists of three layers: p-type semiconductor
and n-type semiconductor and depletion layer. The p-type semiconductor and the n-
type semiconductor are separated by a depletion region or depletion layer.
● P-type semiconductor
When trivalent impurities are added to the intrinsic or pure semiconductor, a p-
type semiconductor is formed. In p-type semiconductor, holes are the majority charge
carriers and free electrons are the minority charge carriers. Thus, holes carry most of
the electric current in p-type semiconductor.
● N-type semiconductor
When pentavalent impurities are added to the intrinsic semiconductor, an n-
type semiconductor is formed. In this, free electrons are the majority charge carriers
and holes are the minority charge carriers. Thus, free electrons carry most of the
electric current in n-type.
2.11 BREADBOARD
A breadboard is a circuit board that is used to make temporary circuits. It is a
device having electronics and test circuit designs. The electronic elements inside the
electronic circuits can be interchanged by inserting the terminals and leads into holes
and later connecting it with the help of appropriate wires. The device has stripes of
metal below the board that connects the holes placed on the top of the board. The
connections of the breadboard are mostly temporary and the elements can further be
reassembled and reused without any damage. Breadboards are generally used in
electrical engineering. Engineers make use of breadboards in order to test different
products made by them. Using breadboard is the most efficient way of testing and
also they are cost effective. They can be reused again and again for the purpose of
testing. Today, starting from tiny analog, digital circuits to big complicated CPU’s
everything can be tested with the help of this.
Figure.2.14: Breadboard
Breadboards earlier were made of copper wires or terminal strips. These days
it is made up of white plastic and is a breadboard that can be plugged. Breadboards
are solderless and they are made of two kinds of strips i.e. terminal and bus strips.
Terminal strips help in holding the electronic elements while the bus strip is used to
power electric power to all the electronic components.
2.11.1 CONNECTIONS ON BREADBOARD
Breadboards have many tiny sockets (called 'holes') arranged on a 0.1" grid.
The leads of most components can be pushed straight into the holes. ICs are inserted
across the central gap with their notch or dot to the left. Wire links can be made with
single-core plastic coated wire of 0.6mm diameter (the standard size). Stranded wire
is not suitable because it will crumple when pushed into a hole and it may damage the
board if strands break off.
The diagram shows how the breadboard holes are connected.
CHAPTER-3
DESIGN AND IMPLEMENTATION
3.1 BLOCK DIAGRAM
Here we present the block diagram and circuit diagram,also given the circuit
description or working principle of the circuit diagram.
3.4 FLOWCHART
The following figure describes the flowchart of the home automation using
arduino and PIR sensor. Firstly, PIR sensor starts detecting whether any person is
there in the surrounding areas. When the person is detected then lights will be ON
otherwise lights will be switched OFF.
CHAPTER-4
RESULT & ANALYSIS
4.1 RESULT
In this project designing of hardware circuit is successfully done.The hardware
design and software dumping is successfully completed.
4.2 IMAGE OF THE PROJECT
CHAPTER-5
SOFTWARE TOOLS
5.1 ARDUINO IDE(1.8.9)
IDE stands for “Integrated Development Environment” :it is an official
software introduced by Arduino.cc, that is mainly used for editing, compiling and
uploading the code in the Arduino Device. Almost all Arduino modules are
compatible with this software that is an open source and is readily available to install
and start compiling the code on the go.
Arduino IDE is an open source software that is mainly used for writing and
compiling the code into the Arduino Module. It is an official Arduino software,
making code compilation too easy that even a common person with no prior technical
knowledge can get their feet wet with the learning process. It is easily available for
operating systems like MAC, Windows, Linux and runs on the Java Platform that
comes with inbuilt functions and commands that play a vital role for debugging,
editing and compiling the code in the environment. A range of Arduino modules
available including Arduino Uno, Arduino Mega, Arduino Leonardo, Arduino Micro
and many more. Each of them contains a microcontroller on the board that is
actually programmed and accepts the information in the form of code. The main code,
also known as a sketch, created on the IDE platform will ultimately generate a Hex
File which is then transferred and uploaded into the controller on the board.
The IDE environment mainly contains two basic parts: Editor and Compiler
where former is used for writing the required code and later is used for compiling
and uploading the code into the given Arduino Module. This environment supports
both C and C++ languages.
5.2 DETAILS ON IDE
The IDE environment mainly distributed into three sections:
● Menu bar
● Text Editor
● Output Plane
● SPI - for communicating with devices using the Serial Peripheral Interface
(SPI) Bus.
● Software Serial - for serial communication on any digital pins. Version 1.0
and later of Arduino incorporate Mikal Hart's NewSoft Serial library as
Software Serial.
● Stepper - for controlling stepper motors.
● TFT - for drawing text , images, and shapes on the Arduino TFT screen.
● WiFi - for connecting to the internet using the Arduino WiFi shield.
● Wire - Two Wire Interface (TWI/I2C) for sending and receiving data over a
net of devices or sensors.
5.4 PROGRAM STRUCTURE
● variables: Whenever you’re using Arduino, you need to declare global
variables and instances to be used later on. In a nutshell, a variable allows you
to name and store a value to be used in the future. For example, you would
store data acquired from a sensor in order to use it later. To declare a variable
you simply define its type, name and initial value.
● Instances: In software programming, a class is a collection of functions and
variables that are kept together in one place. Each class has a special function
known as a constructor, which is used to create an instance of the class. In
order to use the functions of the class, we need to declare an instance for it.
● Setup(): Every Arduino sketch must have a setup function. This function
defines the initial state of the Arduino upon boot and runs only once.Here
we’ll define the following:
1.Pin functionality using the pinMode function
2.Initial state of pins
3. Initialize classes
4.Initialize variables
5.Code logic
● Loop() The loop function is also a must for every Arduino sketch and
executes once setup() is complete. It is the main function and as its name hints,
it runs in a loop over and over again. The loop describes the main logic of
your circuit.
5.5 SELECTING A BOARD
In order to upload the sketch, we need to select the relevant board we are
using and the ports for that operating system. As we click the Tools on the Menu, it
will open like the figure below.
After correct selection of both Board and Serial Port, click the verify and then
upload button appearing in the upper left corner of the six button section or you
can go to the Sketch section and press verify/compile and then upload. The sketch
is written in the text editor and is then saved with the file extension .ino. It is
important to note that the recent Arduino Modules will reset automatically as you
compile and press the upload button the IDE software, however, older version may
require the physical reset on the board. As we upload the code, TX and RX LEDs will
blink on the board, indicating the desired program is running successfully.
5.6 SERIAL MONITOR
It is a separate pop-up window that acts as a separate terminal that
communicates by receiving and sending Serial Data. See the icon on the far right of
the image above. Serial Data is sent over a single wire and consists of a series of 1's
and 0's sent over the wire. Data can be sent in both directions.
FUTURE SCOPE
In our system we are taking decision based on Human presence but we can
also interface LDR (Light Dependent Resistor) Sensor and Temperature sensor for
better working of the system. This system can be also interfaced with the Bluetooth
module so we can control the whole system from the mobile itself. Applications of
our device are listed below
1. It can be used in college and schools (Turn of lights and fans when no one is there)
2. It can be used for home security purpose also we can fit at the main door of the
house.
CONCLUSION
It is not an easy task to design this system as PIR sensor is generally used
for the motion detection. We have done coding in such a way that little movement of
the human is detected by the sensor. We have put some time delay and adjusted the
sampling period for the sensor output for the precise detection.
In this digital world, Technology is very advanced and we prefer things
to be done automatically without any human efforts. This project also helps to reduce
human efforts. In addition, it is very useful to conserve resources. It is very useful in
Schools, hospitals, malls, offices, auditoriums.
REFERENCES
● Subitha M.B “Microcontroller based tracking system for the detection of
Human presence in critical Areas” vol.2,Issue 4, IJEDR 2014 .
● Saravana Kumar K , Priscilla P, Germiya K Jose , Balagopal G , “Human
Detection Robot using PIR Sensors”,International Journal of Science,
Engineering and Technology Research (IJSETR) Volume 4, Issue 3, March
2015
● Jaeseok Yun and Sang-Shin Lee, “Human Movement Detection and
Identification Using Pyroelectric Infrared Sensors” Sensors 2014
● K Sravani, Md Parvez Ahmed, N Chandra Sekhar, G Sirisha, V Prasad,
“Human Motion Detection Using Passive Infra-Red Sensor”, International
Journal of Research in Computer Applications & Information Technology,
Volume2, Issue 2, March April, 2014.
● Dey, S., Roy, A., & Das, S. (2016). Home automation using Internet of Thing.
2016 IEEE 7th Annual Ubiquitous Computing, Electronics & Mobile
Communication Conference (UEMCON).
● Jerabandi, M., & Kodabagi, M. M. (2017). A review on home automation
system. 2017 International Conference On Smart Technologies For Smart
Nation (SmartTechCon)
● Goyal, R., & Arya, L. (2017). Home automation and intelligent light control
system using microcontroller. 2017 International Conference on Computing,
Communication and Automation (ICCCA).
● Urfaliglu, O., Soyer, E. B., Toreyin, B. U., & Cetin, A. E. (2008). PIR-sensor
based human motion event classification. 2008 IEEE 16th Signal Processing,
Communication and Applications Conference.
● Sukmana, H. T., Farisi, M. G., & Khairani, D. (2015). Prototype utilization of
PIR motion sensor for real time surveillance system and web-enabled lamp
automation. 2015 IEEE Asia Pacific Conference on Wireless and Mobile
(APWiMob).
Appendix-A
⚫ SOURCE CODE
int pir=4;
int led=2;
int relay=3;
int val;
void setup() {
pinMode(pir,INPUT);
pinMode(led,OUTPUT);
pinMode(relay,OUTPUT);
Serial.begin(9600);
void loop() {
val=digitalRead(pir);
Serial.print(val);
Serial.print(" ");
if(val==1)
t1=millis()+10000;
Serial.print(t1);
Serial.print(" ");
Serial.println(millis());
if(millis()<t1)
digitalWrite(led,1);
digitalWrite(relay,0);
else
digitalWrite(led,0);
digitalWrite(relay,1);