Вы находитесь на странице: 1из 47

MICROCONTROLLER BASED HOME

AUTOMATION SYSTEM

UNIVERSITY OF ENGINEERING
&
MANAGEMENT, JAIPUR
Microcontroller Based Home Automation System
Submitted in the partial fulfillment of the degree of
BACHELOR OF TECHNOLOGY
In
ELECTRICAL ENGINEERING
Under
UNIVERSITY OF ENGINEERING & MANAGEMENT, JAIPUR
By

KUNTAL BAG University Roll No.: 12014002011001

SHUVAM DAS University Roll No.: 12014002007001

SIDDHARTHA BHUNIA University Roll No.: 12014002005001

RUPAM DAS University Roll No.: 12014002005002

PRITAM DAS University Roll No.: 12014002007007

DEBJIT PATTANAYAK University Roll No.: 12014002005006

UNDER THE GUIDANCE OF

PROF. PRABRIT BANDYOPADHYAY

ELECTRICAL ENGINEERING

UNIVERSITY OF ENGINEERING & MANAGEMENT, JAIPUR


Approval Certificate

This is to certify that the project report entitled ―Microcontroller Based Home Automation
System‖ submitted by Kuntal Bag (Roll:12014002011001) in partial fulfillment of the
requirements of the degree of Bachelor of Technology in Electrical Engineering from
University of Engineering and Management, Jaipur was carried out in a systematic and
procedural manner to the best of our knowledge. It is a bona fide work of the candidate and
was carried out under our supervision and guidance during the academic session of 2014-
2018.

_______________________ _______________________

Prof. P. Bandyopadhyay Prof. Aniruddha Mukherjee


Project Guide & Assistant Professor (EE) HOD (EE) & Dean
UEM, JAIPUR UEM, JAIPUR
ACKNOWLEDGEMENT

The endless thanks go to Lord Almighty for all the blessings he has showered
onto us, which has enabled us to write this last note in our research work.
During the period of our research, as in the rest of our lives, we have been
blessed by Almighty with some extraordinary people who have spun a web of
support around us. Words can never be enough in expressing how grateful we
are to those incredible people in our lives that made this thesis possible. We
would like an attempt to thank them for making our time during our research in
the Institute a period we will treasure.
We are deeply indebted to our research supervisor, Professor P. Bandyopadhyay
for presenting us such an interesting thesis topic. Each meeting with him added
invaluable aspects to the implementation and broadened our perspective. He has
guided us with his invaluable suggestions, lightened up the way in our darkest
times and encouraged us a lot in the academic life.

Kuntal Bag
Shuvam Das
Siddhartha Bhunia
Rupam Das
Pritam Das
Debjit Pattanayak
ABSTRACT
The objective of this project is to make a Microcontroller based model to count
the number of persons visiting a particular room and accordingly light up the
room. The project ―Microcontroller Based Home Automation System‖ is made
using Microcontroller Arduino UNO that takes over the task of controlling the
room lights using the relay board as well as counting the number of
persons/visitors in the room very accurately. The model will receive the signals
from the Passive Infrared Sensors and this signal will be operated under the
control of software which is stored in ROM. The project is a real life model
which has the ability to perform the task of counting at both the entry as well as
the exits of the room when someone enters or exits the room. In today’s world,
there is a continuous need for automatic appliances with the increase in standard
of the living. There is a sense of urgency for developing circuits that would ease
the complexity of life. This thesis merely serves the purpose of allowing one to
enter the world of IOT just with the help of a few basic components thus
allowing them to get a deeper insight into the world of Automation. This project
introduces the use of App Inventor that allows one to create apps with ease
simply by connecting few built-in blocks of data in cascade manner. This
project also uses a Bluetooth Module to communicate with the Android app thus
showing the counter value as well as allowing the user to remotely control the
lights and fans of the room from the Android device itself.
Table of Contents

List of Figures…………………………………………………………………………………………………………………………7
1. CHAPTER……………………………………………………………………………………………………………………………8
INTRODUCTION………………………………………………………………………………………………………………8
1.1 Predecessors to Electronic Android people Counter……………………….8
1.2 A Possible Alternative…………………………………………………………………………………………8
1.3 Overview of the Project……………………………………………………………………………………..8

2. CHAPTER…………………………………………………………………………………………………………………………..11
DESIGN AND IMPLEMENTATION…………………………………………………………………………………….11

2.1 Input or Sensor Layer…………………………………………………………………………………………11

2.1.1 IR Sensor (Infrared)…………………………………………………………………………………..12

2.2 Control Layer……………………………………………………………………………………………………..19

2.2.1 Arduino UNO (Microcontroller)………………………………………………………………..19

2.2.2 Android App by using APP INVENTOR……………………………………………………….25.

2.2.3 HC-05 Bluetooth Module………………………………………………………………………….29

2.3 Actuator Layer…………………………………………………………………………………………………..33

2.3.1 Relay Board………………………………………………………………………………………………34.

3. CHAPTER………………………………………………………………………………………………………………………….40
CIRCUIT OPERATION……………………………………………………………………………………………………40

3.1 Stages of Operation………………………………………………………………………………………….40

3.2 ARDUINO Code…………………………………………………………………………………………………40

4. CHAPTER………………………………………………………………………………………………………………………….45
RESULTS AND DISCUSSION………………………………………………………………………………………….45

5. CHAPTER…………………………………………………………………………………………………………………………46
CONCLUSION………………………………………………………………………………………………………………46

BIBLIOGRAPHY………………………………………………………………………………………………………………………47
List of Figures

Figure 1—Overview of the Project...........................................................................................09


Figure 2—The Three Layer Architecture of Sensor, Control and Actuator………………….11
Figure 3—Infrared Sensor……………………………………………………………………12
Figure 4—Internal Circuit of the IR sensor…………………………………………………..12
Figure 5—Circuit Diagram of an IR sensor……………………………...…………………..13
Figure 6—Basic Operating Principle of the IR sensor……………………………………….14
Figure 7—The IR Sensor operating in television remote controllers……………………..….15
Figure 8—IR Transmitter/Receiver Waveforms…….……………………………………….15
Figure 9—A Typical IR module sensing block diagram…………………………………….15
Figure 10—Transmitted and Received Infrared rays in an IR Sensor……………………….17
Figure 11—IR Sensor specifications…………………………………………………………18
Figure 12—IR Sensor Applications…………………………………………………………..18
Figure 13—Arduino UNO…………………………………………………………………...19
Figure 14—Pin-Out Configuration of Arduino UNO………………………………………..20
Figure 15—Arduino UNO software IDE…………………………………………………….22
Figure 16—An Arduino program to blink a LED repeatedly……….……………………….23
Figure 17—Arduino based home automation………………….…………………………….24
Figure 18—Arduino based auto intensity control……………………...…………………….24
Figure 19—Arduino UNO Applications……………………………………………………..25
Figure 20—MIT App Inventor Site………………………………………………………….26
Figure 21—Screenshot of the Android App…………………………………………………27
Figure 22—Screen 1 of the App Creation……………………………………………………27
Figure 23—Screen 2 of the App Inventor……………………………………………………28
Figure 24—Bluetooth Module Screenshot of the App………………………………………28
Figure 25—App Screen showing Counter value and on/off switching of lights…………….29
Figure 26—The PIN configuration of HC05 Bluetooth Module…………………………….30
Figure 27—The connection of Bluetooth Module with the Arduino UNO board…………..32
Figure 28—Bluetooth Module Calibration…………………………………………………..32
Figure 29—A 4 Channel Relay Module……………………………………………………..34
Figure 30—Schematic Diagram of a Relay Circuit………………………………………….36
Figure 31—Hardware Installation of the Relay Module…………………………………….36
Figure 32—PIN Configuration of a 4 Channel Relay Module………………………………38
Figure 33—Actual Circuit Arrangement in the Bread Board………………………………..44
1. CHAPTER

INTRODUCTION

1.1 Predecessors to Electronic Android people Counters

Manually operated people counters were in use before the invention of electronic people
counters. These required an employee to stand near the entrance of the building and press a
counting device each time a person enters the store. This was considered to be highly inaccurate
due to the high level of human error, as well as a laborious usage of human resource. Pressure
sensors that count persons based on the number of footsteps on a pressure sensitive base or mat
were used as well. However that was considered to be ineffective as well, as there was a high
possibility that there would be an error in counting the accurate number of footsteps though.

1.2 A Possible Alternative

As an alternative to the outdated electronic people counters, the new and improved simpler form
of counter is a single, horizontal infrared beam across an entrance which is typically linked to a
small LCD display unit at the side of the door. When the beam is broken, a tick is 'recorded'.
Since a person normally enters and exits by the same door, dividing the value of the count by
two gives a measure of the number of visitors. Beam counters usually require a receiver or a
reflector mounted opposite the unit with a typical range from 2.5 meters (8 ft. 2 in) to 6 meters
(20 ft.). Despite the limitations, infrared counters are still widely used due to their low cost and
simplicity of installation.

This project ―Microcontroller Based Home Automation System‖ is a highly improved version of
the outdated 1st generation Infrared Beam Counters. It uses Microcontroller as a reliable circuit
that takes over the task of controlling the room lights as well as counting the number of
persons/visitors in the room very accurately. When somebody enters the room the counter will be
incremented by one and an LED will be switched on indicating that the user can now switch on
or off the desired number of lights using the Android app that is connected to the circuit using a
Bluetooth Module. The lights will automatically be switched off when all the persons in the
room will go out or the room is empty. The total number of persons in the room is also indicated
on the android device used by the user.

1.3 Overview of the Project

The Sensors and the relay board are connected to the Microcontroller Arduino UNO board which
acts as an intermediate device thereby controlling the switching on or off of the lights and fans
connected. .The Sensors sends a signal out to the microcontroller Arduino UNO thus the
Microcontroller acts according to the Code written. When any person or object passes through
the receiver’s end of the Microcontroller then the beam of light that was being continuously
transmitted and received is now broken. Thus the Sensors send a signal to the Microcontroller
which in turn acts according to the uploaded code.

Fig. 1 Overview of the Project

The infrared sensors can detect the motion or movement at an angle of 90 degrees to the sensors
or the tangential movement particularly well. If there is any radial movement or motion then the
sensors face trouble in detecting those movements as the heat in those directions cannot block
the infrared transmitted and received waves. The sensors should not be tampered with or
disturbed by at the point in which they are placed or else they will not be able to detect motion
accurately.

The surrounding heat radiation is grouped by a segment lens and guided to the pyro-detector. If a
heat source moves in the detection area, the heat radiation changes and the pyro sensor releases a
voltage. This voltage is assessed by the downstream electronics. This voltage is sensed by the
Arduino UNO and immediately it sends an incrementing signal to the counter which is displayed
on the Android App. When the counter value changes from zero to one, then the LED glows
indicating the user that he or she can switch on or off the lights in the room freely according to
his or her choice. When the last person leaves the room then the counter value again reaches zero
and the lights in the room are switched off automatically. This entire phenomenon is governed
by the Arduino and the display is the android device off the user which is also the remote control
device for switching on or off the lights connected to the relay board. Homes of the 21st century
will become more and more self-controlled and automated. Simple devices such as a timer to
turn on one’s coffee maker in the morning have been around for many years, but much more
sophisticated mechanisms will soon be prevalent in homes around the world. Imagine walking
into our home and being greeted at the door with lights illuminating our path without us ever
having to touch a light switch, with our favorite music streaming through the speakers in
whichever room we enter (because our home recognized that it was us and not some other
household member), all while having the peace of mind knowing that our home automation
system took care of activating our security system. Furthermore, such a system could allow the
user to schedule events to occur at recurring intervals.

This report describes an approximation of such a home automation system that was designed and
built as a final project for B.Tech at UEM, Jaipur. This system was designed to be flexible and
generally programmable, extensible such that adding additional features is relatively simple, and
modular and forward-compatible, so that new components can be added without redesigning the
entire system. To achieve these goals, the system runs a user-defined program on a special-
purpose processor, using real-world sensor inputs as operands.

Previously there had been many works or projects on Arduino based people counters but none of
the projects involve the use of Android application in the users mobile to control the entire
operation of switching on or off the devices. Thus this project is not a very complex one rather a
unified and simple topic that can be altered easily and without any tampering with the original
code or app. There is a lot of scope of future improvement in the circuit which is displayed later
in this report.

The rest of this paper is organized as follows. In Chapter 2, details of the design and
implementation are thoroughly discussed. In Chapter 3 discusses the testing strategy that was
used to get the system up and running. Finally, Chapter 4 concludes the paper.
2. CHAPTER

DESIGN AND IMPLEMENTATION

Chapter 1 motivated the importance of an extensible and flexible system. This section describes
the resulting top-level design that reflects these goals.

This Home Automation System (HAS) has three logical levels, as seen in Figure 2.

1. The top-most layer is the input/sensor layer, which can be from sensors, clock modules,
remote controls, or any other kind of input.

2. The control unit comprises the next layer. This layer reads the inputs and performs actions
depending on the values of the inputs and the control program specified by the user.

3. Finally, the control unit outputs commands to the actuator layer. The actuator layer is
responsible for forming and sending commands to the real-world systems such as lights,
HVAC systems, security systems, and music systems.

The details and corresponding subcomponents of each of these layers are described in the
remainder of this chapter.

Fig. 2 Three Layer Architecture of Sensor, Control and Actuator

2.1 Input or Sensor Layer

The input/sensor layer is responsible for acquiring data and formatting the data to a digital signal
that the control layer understands. In our implementation, such a format is simply an 8-bit digital
active-high signal. This section describes the design and implementation of each of the sensor
inputs in detail
2.1.1 IR Sensor ( Infrared Sensor)

An infrared sensor (IR sensor) is an electronic sensor that measures infrared (IR) radiation that
is being emitted from objects that comes in its field of view. They are most often used in IR-
based motion detectors.

Fig.3 IR (Infrared) Sensor

Heat Energy in the form of radiation is emitted by all objects with temperatures above
absolute zero temperature. As this radiation is in the range of wavelengths greater than the
visible spectrum so it is invisible to the Human eyes, but it can be detected by electronic
devices that are designed for the sole purpose of detecting those wavelengths of radiations.

Fig.4 Internal Circuit of IR Sensor


The IR sensor module consists of two photodiodes that act as transmitters and receivers. The
transmitter sends out or transmits radiation in the range of the infrared wavelengths and the
receiver receives the wavelengths after being reflected from the person or object that is in
motion in front of the sensors transmitter and receivers end. Typically, the sensors are
approximately 1/4 inch square (40 mm2), and take the form of a thin film. Materials
commonly used in PIR sensors include gallium nitride (GaN), caesium
nitrate (CsNO3), polyvinyl fluorides, derivatives of phenyl pyridine,
and cobalt phthalocyanine. The sensor is often manufactured as part of an integrated circuit.

Fig.5 Circuit Diagram of an IR Sensor


An IR-based motion sensor is used to sense movement of people, animals, or other objects.
They are used in burglar alarms and automatically-activated light systems. They are
commonly called simply "IR", or sometimes "ID", for "infrared detector".
An individual IR sensor detects changes in the amount of infrared radiation impinging upon
it, which varies depending on the temperature and surface characteristics of the objects in
front of the sensor. When an object, such as a human, passes in front of the background, such
as a wall, the temperature at that point in the sensor's field of view will rise from room
temperature to body temperature, and then back again. The sensor converts the resulting
change in the incoming infrared radiation into a change in the output voltage, and this triggers
the detection. Objects of similar temperature but different surface characteristics may also
have a different infrared emission pattern, and thus moving them with respect to the
background may trigger the detector as well.
The Infrared sensor module consist of a transmitter photodiode, a receiver photodiode, a
distance or proximity changer some resistors and a unit of 3 pins. One pin is Vcc, another pin
is for the ground and the third pin is the output pin all of these three pins are to be connected
to the Arduino UNO board so that when these sensors detect movement or motion in front of
them then they can send a signal to the Microcontroller which in turn operates the rest of the
circuit connected with it according to the code that is being uploaded into it.
Fig.6 Basic Operating Principle of IR Sensor

There are different types of IR sensors working in various regions of the IR spectrum but the
physics behind "IR sensors" is governed by three laws:
1. Planck’s radiation law:
Every object at a temperature T not equal to 0 K emits radiation. Infrared radiant energy is
determined by the temperature and surface condition of an object. Human eyes cannot detect
differences in infrared energy because they are primarily sensitive to visible light energy
from 400 to 700 nm. Our eyes are not sensitive to the infrared energy.

2. Stephan Boltzmann Law


The total energy emitted at all wavelengths by a black body is related to the absolute
temperature as

3. Wein’s Displacement Law


Wein’s Law tells that objects of different temperature emit spectra that peak at different
wavelengths. It provides the wavelength for maximum spectral radiant emittance for a given
temperature.
The relationship between the true temperature of the black body and its peak spectral
existence or dominant wavelength is described by this law
The world is not full of black bodies; rather it comprises of selectively radiating bodies like
rocks, water, etc. and the relationship between the two is given by emissivity (E).

Fig.7 The IR sensors operating in television Remote Controllers

Fig.8 IR Transmitter/Receiver Waveforms

A typical system for detecting infrared radiation is given in the following block diagram:

Fig.9 A typical IR module sensing block Diagram


1. Infrared Source

All objects above 0 K radiate infrared energy and hence are infrared sources. Infrared sources
also include blackbody radiators, tungsten lamps, silicon carbide, and various others. For
active IR sensors, infrared Lasers and LEDs of specific IR wavelengths are used as IR
sources.

2. Transmission Medium

Three main types of transmission medium used for Infrared transmission are vacuum, the
atmosphere, and optical fibers.

The transmission of IR – radiation is affected by presence of CO2, water vapor and other
elements in the atmosphere. Due to absorption by molecules of water carbon dioxide, ozone,
etc. the atmosphere highly attenuates most IR wavelengths leaving some important IR
windows in the electromagnetic spectrum; these are primarily utilized by thermal imaging/
remote sensing applications.

• Medium wave IR (MWIR:3-5 µm)

• Long wave IR (LWIR:8-14 µm)

Choice of IR band or a specific wavelength is dictated by the technical requirements of a


specific application.

3. Optical Components.

Often optical components are required to converge or focus infrared radiations, to limit
spectral response, etc. To converge/focus radiations, optical lenses made of quartz, CaF2, Ge
and Si, polyethylene Fresnel lenses, and mirrors made of Al, Au or a similar material are
used. For limiting spectral responses, band pass filters are used. Choppers are used to pass/
interrupt the IR beams.

4. Infrared detectors.

Various types of detectors are used in IR sensors. Important specifications of detectors are

• Photosensitivity or Responsivity
Responsivity is the Output Voltage/Current per watt of incident energy. Higher the better.

• Noise Equivalent Power (NEP)

NEP represents detection ability of a detector and is the amount of incident light equal to
intrinsic noise level of a detector.

• Detectivity (D*: D-star)

D* is the photosensitivity per unit area of a detector. It is a measure of S/N ratio of a detector.
D* is inversely proportional to NEP. Larger D* indicates better sensing element.

In addition, wavelength region or temperature to be measured, response time, cooling


mechanism, active area, no of elements, package, linearity, stability, temperature
characteristics, etc. are important parameters which need attention while selecting IR
detectors.

5. Signal Processing

Since detector outputs are typically very small, preamplifiers with associated circuitry are
used to further process the received signals. They can be made to modulate or demodulate the
signals according to the desired output range.

Fig.10 Transmitted and Received Infrared Rays in an IR Sensor


Fig.11 IR Sensor Specifications

The IR sensor is typically mounted on a printed circuit board containing the necessary
electronics required to interpret the signals from the sensor itself. The complete assembly is
usually contained within housing, mounted in a location where the sensor can cover area to
be monitored.

Fig.12 IR Sensors Applications


2.2 Control Layer

The middle layer of the Home Automation system involves the control layer. Here the
Microcontroller comes into play. The PIR sensor senses the motion of the visitors and sends an
actuating signal to the Arduino UNO microcontroller. It can be programmed using the Arduino
Software IDE and can be made to send the necessary signals as and when required. In this
project, after sensing the motion the Entry PIR sensor sends a signal to the Arduino and then it
increments the value of the counter by one. As soon as the counter increments by one, the LED
glows indicating that the user is ready to switch on or off the lights of the room according to his
desire and can remotely control the relay board using the Bluetooth module connected to the
Android app on the device. So the control layer consist of two components- Arduino Uno and the
Android app containing both the display of the counter value and the on or off buttons of the
lights.

2.2.1 Arduino UNO (Microcontroller)

The Arduino UNO is a widely used open-source microcontroller board based on the
ATmega328P microcontroller and developed by Arduino.cc. The board consists of many digital
and analog input and output pins that can be programmed or interfaced to be connected to other
input and output circuits that will work according to the Arduino software programming tool
IDE. 14 Digital pins and 6 Analog pins are present on the board. It is programmable with
the Arduino IDE (Integrated Development Environment) via a type B USB cable. It can be
powered by a USB cable or by an external 9 volt battery as it accepts voltages between 7 and 20
volts. In this chapter, we will learn about the different components on the Arduino board. We
will study the Arduino UNO board because it is the most popular board in the Arduino board
family. In addition, it is the best board to get started with electronics and coding. Some boards
look a bit different from the one given below, but most Arduino have majority of these
components in common.

Fig.13 Arduino UNO


Fig.14 Pin out Configuration of Arduino UNO

Technical Specifications-

Microcontroller ATmega328
Operating Voltage 5V
Input Voltage (recommended) 7-12V
Input Voltage (limits) 6-20V
Digital I/O Pins 14 (of which 6 provide PWM output)
Analog Input Pins 6
DC Current per I/O Pin 40 mA
DC Current for 3.3V Pin 50 mA
Flash Memory 32 KB (ATmega328) of which 0.5 KB used by bootloader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 MHz

Power USB

Arduino UNO can be supplied or powered by using the USB cable from the computer or
laptop. It can also be powered by using an external 9V battery as it can accept voltages
between 7 and 20V.

Voltage Regulator
The function of the voltage regulator is to control the voltage given to the Arduino board and
stabilize the DC voltages used by the processor and other elements.

Crystal Oscillator

The crystal oscillator helps Arduino in dealing with time issues. How does Arduino calculate
time? The answer is, by using the crystal oscillator. The number printed on top of the
Arduino crystal is 16.000H9H. It tells us that the frequency is 16,000,000 Hertz or 16 MHz.

Arduino Reset

We can reset the Arduino UNO board, i.e., start the programs from the beginning. We can
reset the UNO board in two ways. Firstly by using the reset button on the board and
secondly, we can connect an external reset button to the Arduino pin labelled RESET.

Pins (3.3, 5, GND, Vin)

 3.3V − Supply 3.3 output volt

 5V − Supply 5 output volt

 Most of the components used with Arduino board works fine with 3.3 volt and 5 volt.

 GND (Ground) − There are several GND pins on the Arduino, any of which can be used to
ground the circuit.

 Vin − This pin also can be used to power the Arduino board from an external power source,
like AC mains power supply.

Analog pins
The Arduino UNO board has five analog input pins A0 through A5. These pins can read the
signal from an analog sensor like the humidity sensor or temperature sensor and convert it
into a digital value that can be read by the microprocessor.

Power LED indicator

This LED should light up when we plug the Arduino UNO into a power source to indicate
that the board is powered up correctly. If this light does not turn on, then there is something
wrong with the connection.

TX and RX LEDs

On the board, two labels can be found: TX (transmit) and RX (receive). They appear in two
places on the Arduino UNO board. Firstly the digital pins 0 and 1 are used to indicate the
pins responsible for serial communication. Secondly the TX and RX led. The TX led flashes
with different speed while sending the serial data. The speed of flashing depends on the baud
rate used by the board. RX flashes during the receiving process.
Digital I/O

The Arduino UNO board has 14 digital I/O pins (15) (of which 6 provide PWM (Pulse
Width Modulation) output. These pins can be configured to work as input digital pins to read
logic values (0 or 1) or as digital output pins to drive different modules like LEDs, relays,
etc. The pins labeled ―~‖ can be used to generate PWM.
PWM
Pins 3, 5, 6, 9, 10, and 11. They provide 8-bit PWM output with the analogWrite () function.
SPI
10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK). These pins support SPI communication using the
SPI library.

Arduino Programming Tools

Any programming language with compilers that produce binary machine code for the target
processor may be used to write the code for the Arduino UNO board that will help to control
the circuits that are connected to the microcontroller. Atmel provides a development
environment for their microcontrollers, AVR Studio and the newer Atmel Studio.
Sketches are the name given to the programs that are written using the Arduino Software
IDE. These sketches are written in the text editor and are saved with the file extension .ino.
The editor has features for cutting/pasting and for searching/replacing text. The message area
gives feedback while saving and exporting and also displays errors. The console displays text
output by the Arduino Software (IDE), including complete error messages and other
information. The bottom right-hand corner of the window displays the configured board and
serial port. The toolbar buttons allow you to verify and upload programs, create, open, and
save sketches, and open the serial monitor.

Fig.15 Arduino UNO Software IDE


The open-source nature of the Arduino project has facilitated the publication of many free
software libraries that other developers use to augment their projects.

A minimal Arduino C/C++ program consists of only two functions:

 Setup ():This function is called once when the sketch is powered up or made reset using
the power button or the reset button using the 9 volts battery or by using a computer.
 Loop (): After setup () has been called, function loop () is executed repeatedly in the main
program. It controls the board until the board is powered off or is reset.

Most Arduino boards contain a light-emitting diode (LED) and a load resistor connected
between pin 13 and ground, which is a convenient feature for many tests and program
functions. A typical program for a beginning Arduino programmer blinks a LED repeatedly.

#define LED_PIN 13 // Pin number attached to LED.

void setup() {
pinMode(LED_PIN, OUTPUT); // Configure pin 13 to be a digital output.
}

void loop() {
digitalWrite(LED_PIN, HIGH); // Turn on the LED.
delay(1000); // Wait 1 second (1000 milliseconds).
digitalWrite(LED_PIN, LOW); // Turn off the LED.
delay(1000); // Wait 1 second.
}

Fig.16 An Arduino program to blink an LED repeatedly

This program uses the functions pinMode(), digitalWrite(), and delay(), which are provided by
the internal libraries included in the IDE environment. The program is usually loaded in the
Arduino by the manufacturer.

Real-Time Applications of Arduino Uno Board

Arduino Based Home Automation System

The project is designed by using Arduino Uno board for the development of home automation
system with Bluetooth which is remotely controlled and operated by an Android OS smart
phone. Houses are becoming smarter and well developed by using such kind of advanced
technologies. Modern houses are gradually increasing the way of design by shifting to
centralized control system with remote controlled switches instead of conventional switches.

Fig. 17 Arduino Based Home Automation

In order to achieve this, a Bluetooth module is interfaced to the Arduino Uno board at the
receiver end while on the transmitter end, a Graphical User Interface application on the cell
phone sends ON/OFF commands to the receiver where loads are connected. By touching the
identified location on the Graphical User Interface, lamps are used as loads in this project can
be turned ON/OFF remotely by using this technology. The loads are operated by using
Arduino Uno board through thyristors using triacs and OPTO-Isolators.

Arduino based Auto Intensity Control of Street Lights

As the intensity is cannot be controlled by using High Intensity Discharge (HID) lamps power
saving is not possible in street lights with these lamps as the density on roads is decreasing
from peak hours of nights to early morning.

Fig. 18 Arduino Based Auto Intensity Control

Thus, this system overcomes this problem by controlling the intensity of LED lights on street
by gradually reducing intensity by controlling the voltage applied to these lamps. This system
uses Arduino board to produce PWM pulses and it is programmed in such a way that it
decreases the voltage applied to these lamps gradually till late nights and completely
shutdowns at morning.
Thus, Arduino development board can sense the environment by receiving input from different
sensors and affects its surroundings by controlling motors, lights and other actuators. The
microcontroller on the board is programmed using the Arduino programming language.

Fig.19 Arduino UNO applications

2.2.2 Android App by using APP INVENTOR

App Inventor for Android is an open-source web application originally provided


by Google, and now maintained by the Massachusetts Institute of Technology (MIT).
It allows newcomers to computer programming to create software applications for
the Android operating system (OS). It uses a graphical interface, very similar to Scratch and
the Star Logo TNG user interface, which allows users to drag-and-drop visual objects to
create an application that can run on Android devices. In creating App Inventor, Google drew
upon significant prior research in educational computing, as well as work done within Google
on online development environments.
Just like MATLAB, MIT App inventor gives the speciality rather functionality to create
complex applications with ease. It has built in pre-coded blocks of applications in miniature
or small sizes that can be connected in series, parallel or cascade manner to form a larger and
more complex structure of programs. Suppose someone wants to create an application
consisting of Bluetooth connectivity software. Then he or she just requires a Bluetooth Client
and a Bluetooth Server. There are already blocks of Bluetooth client and Bluetooth Server
existing on the Library. One just has to drag these blocks from the library to the editor in
order to be able to connect them in the way they desire. Then they have the option to rename
the blocks, give shape to the blocks in the way they desire, change the font size, font style
and design the blocks in the way they like. Now the second page coming is the blocks page
where they have to connect the blocks in series, parallel or one after the other in a way that
one click of the button in the app can enable the user to access sub-blocks in an orderly
fashion. Suppose on clicking a button called the LOGIN, one has to enter a particular
password and then the further deeper portions of the app can be accessed. By clicking a
button like ON or OFF the user can directly control a device that is connected to the relays.
They can add pictures, frames, Backgrounds and many more and successfully design the app.

Fig.20 MIT app Inventor Site


Open Blocks is distributed by the Massachusetts Institute of Technology's Scheller Teacher
Education Program (STEP) and is derived from master's thesis research by Ricarose Roque.
Professor Eric Klopfer and Daniel Wendel of the Scheller Program supported the distribution
of Open Blocks under an MIT License. Open Blocks visual programming is closely related
to StarLogo TNG, a project of STEP, and Scratch, a project of the MIT Media Lab's Lifelong
Kindergarten Group. App Inventor 2 replaced Open Blocks with Blockly, a blocks editor that
runs within the browser.

 The MIT AI2 Companion app enables real-time debugging on connected devices via Wi-
Fi, not just USB.
As of May 2014, were 87 thousand weekly active users of the service and 1.9 million
registered users in 195 countries for a total of 4.7 million apps built.
As December 2015, had 140k weekly active users and 4 million registered users in 195
countries, run total of 12 million built applications.

Creating the App

There are a lot of different ways to create an android app such as converting codes from
HTML to Java or programming the app with Python. However, the MIT App Inventor is
the easiest way because of its structure of drag and drop when we want to make an
android app .People Counter! Is the name of the app and it includes two screens named
Screen1 and Screen2.
In the first screen, the page has been designed in such a way that it will be asking for the
password to login. The default password is ―COUNTER‖. After entering the password
the dialogue box that appears will say that the entered password is correct and whether
the user wants to access the further menus in the screen 2. If yes then the user clicks on
OK. Thus the actual screen of the application comes in the second where the value of the
counter variable and the controls of the 4 Channel relay module is listed. Here the user
can decide as to switch on or off the relays by pressing the buttons on the app.

Fig.21 Screenshot of the Android App

Screen 1-

Fig.22 Screen 1 of the App Creation


It is the home screen to continue to the main screen but firstly, the password which is set
in the MIT App Inventor must be entered correctly. (The default password that I set is
"counter".)
Screen 2-

Fig.23 Screen 2 of the App inventor


It is the main screen and the menu to control Arduino board and the result of the people
counter which is sent by Arduino is displayed on this screen.
We can choose which laser is on or whether the alarm is open or not, on this screen
furthermore we can see the result of the people counter and set it to start from zero.

Fig.24 Bluetooth Module Screenshot of the App


Fig.25 App screen showing counter value and on/off switching of lights
When the microcontroller Arduino UNO receives a signal from the PIR sensor t hen it
increments the value of the counter by one which is displayed on the app installed on the
android device. Now as soon as the value of the counter changes from zero to one, then
the user is free to use the on and off buttons on the app which is indic ated by the glowing
of the LED. The app is connected to the circuit using a HC-05 Bluetooth module which
in turn is connected to the android device of the user by the help of Bluetooth. Thus the
app acts as a control device helping in switching the devices on or off.

2.2.3 HC-05 Bluetooth Module

HC‐05 module is an easy to use Bluetooth SPP (Serial Port Protocol) module, designed for
transparent wireless serial connection setup. For wireless communication the HC-05
Bluetooth module is the most widely used module as it can be configured in the Master-Slave
configuration very easily. This serial port Bluetooth module is fully qualified Bluetooth
V2.0+EDR (Enhanced Data Rate) 3Mbps Modulation with complete 2.4GHz radio
transceiver and baseband. It uses CSR Bluecore 04‐External single chip Bluetooth system
with CMOS technology and with AFH (Adaptive Frequency Hopping Feature).
The Bluetooth module HC-05 is a MASTER/SLAVE module. SLAVE configuration is by
default the factory setting for the .AT COMMANDS can only be used to configure either the
SLAVE module or the MASTER module. The slave modules cannot initiate a connection to
another Bluetooth device, but can accept connections. Master module can initiate a
connection to other devices. The user can use it simply for a serial port replacement to
establish connection between MCU and GPS, PC to your embedded project, etc.

Hardware Features

 Typical ‐80dBm sensitivity.


 Up to +4dBm RF transmits power.
 3.3 to 5 V I/O.
 PIO (Programmable Input/Output) control.
 UART interface with programmable baud rate.
 With integrated antenna.
 With edge connector.

Software Features

 Slave default Baud rate: 9600, Data bits:8, Stop bit:1,Parity:No parity.
 Auto‐connect to the last device on power as default.
 Permit pairing device to connect as default.
 Auto‐pairing PINCODE:‖1234‖ as default.

Fig.26 The PIN configuration of HC05 Bluetooth Module


PIN Description
The HC-05 Bluetooth Module has 6pins. They are as follows:
ENABLE:
When enable is pulled LOW, the module is disabled which means the module will not turn
on and it fails to communicate. When enable is left open or connected to 3.3V, the module
is enabled i.e. the module remains on and communication also takes place.
Vcc:
Supply Voltage 3.3V to 5V
GND:
Ground pin
TXD & RXD:
These two pins acts as an UART interface for communication
STATE:
It acts as a status indicator. When the module is not connected to / paired with any other
Bluetooth device, signal goes Low. At this low state, the led flashes continuously which
denotes that the module is not paired with other device. When this module is connected
to/paired with any other Bluetooth device, the signal goes high. At this high state, the led
blinks with a constant delay say for example 2s delay which indicates that the module
is paired.
BUTTON SWITCH:
This is used to switch the module into AT command mode. To enable AT command mode,
press the button switch for a second. With the help of AT commands, the user can change the
parameters of this module but only when the module is not paired with any other BT device.
If the module is connected to any other Bluetooth device, it starts to communicate with that
device and fails to work in AT command mode.

How to connect HC05 Bluetooth Module with the Arduino UNO

Hardware and Software Required

 HC-05 Bluetooth Module


 Arduino Uno
 Arduino IDE(1.0.6V)
Hardware Connections

As we know that Vcc and Gnd of the module goes to Vcc and Gnd of Arduino. The TXD pin
goes to RXD pin of Arduino and RXD pin goes to TXD pin of Arduino i.e.(digital pin 0 and
1).The user can use the on board Led. But here, Led is connected to digital pin 12 externally
for betterment of the process.
Fig.27 The connection of Bluetooth module with the Arduino UNO board

The program given below is the HC-05 Bluetooth module program. This process is quite
different from others since we are going to use android mobile to control and communicate
with Arduino. Here the Bluetooth module acts as an interface between our mobile and
Arduino board. Before getting into the execution process, follow the given procedure:

 First of all, the user should install an application called Bluetooth SPP PRO from the
play store which is a free application.
 After installation, pair the Bluetooth module to your mobile as like connecting one
device to other using Bluetooth. The default pairing code is 1234.
 Upload the given program to the Arduino Uno board. After uploading the code,
unplug the USB from the Arduino.
 Now use external power adapter to power the Uno board.
 The Bluetooth SPP PRO has three types of communication mode. Here Byte stream
mode is used to communicate. So select that mode and give the input as 1,as soon as the input
has given the led will turn on and for 0 led will turn off.

Fig.28 Bluetooth Module Calibration


#include <SoftwareSerial>
SoftwareSerial mySerial (0, 1);
int ledpin=12;
int Data;
void setup ()
{
mySerial.begin (9600);
pinMode (ledpin, OUTPUT);
}
void loop ()
{
if (mySerial.available())
{
Data=mySerial.read ();
if (Data=='1')
{
digitalWrite (ledpin,HIGH);
mySerial.println ("LED On! ");
}
else if (Data=='0')
{
digitalWrite (ledpin, LOW);
mySerial.println("LED Off! ");
}
}
}

The Bluetooth Module is used to establish communication with the android app that controls
the switching on or off of the lights and shows the value of the counter. So it acts as a control
mechanism allowing the PIR sensors to communicate with the lights via the microcontroller
and the android app.

2.3 Actuator Layer

The lowest level of the control system or the home automation system is the actuator layer.
When the entry and exit PIR sensors detects motion then they send a signal to the Arduino UNO
and as a result the microcontroller activates the counter increment and gives the control of the
relay board to the user also displaying the value of the counter. Now the actuator part of this
circuit is the Relay board that activates the lights on or off connected to it. The entire mechanism
of the relay and its configuration and connection is shown in this actuator layer.

2.3.1 Relay Board

AN electrically operated switch is called a relay. Many relays use an electromagnet to


mechanically operate a switch, but other operating principles are also used, such as solid-state
relays. Relays are used where it is necessary to control a circuit by a separate low-power
signal, or where several circuits must be controlled by one signal. The first relays were used in
long distance telegraph circuits as amplifiers: they repeated the signal coming in from one
circuit and re-transmitted it on another circuit. Relays were used extensively in telephone
exchanges and early computers to perform logical operations.
The detection of fault and the disconnection of a faulty section or apparatus can be achieved by
using fuses or relays in conjunction with circuit breakers.
In a power system consisting of generators, transformers, transmission and distribution
circuits, it is inevitable that sooner or later some faults will occur in some or other parts of the
system. Whenever such a failure occurs it is necessary for the user to disconnect or isolate the
system from the rest of the circuit efficiently and quickly otherwise it may lead down to the
destruction of the entire system at hand. In this chapter we shall focus our attention on the
various types of relays and the relay module circuit that will help us to operate the lights and
fans of our system using a 5 volts supply to convert it into 230v ac mains supply.

Fig.29 A 4 Channel Relay Module

A protective relay is a device that detects the faults and initiates the operation of the circuit
breaker to isolate the defective element from the rest of the system.

There are only four main parts in a relay. They are

 Electromagnet
 Movable Armature
 Switch point contacts
 Spring

A relay connection is divided into 3 parts-


1. First part is the primary winding of a current transformer which is connected in series with the
line to be protected.
2. Second part consists of secondary windings of the Current Transformer and the relay operating
coil.
3. Third part is the tripping circuit which may be either a.c. or d.c. It consists of a source of supply
the trip coil of the circuit breaker and the relay stationary contacts.

When an electric current is passed through the coil it generates a magnetic field that activates the
armature and the consequent movement of the movable contact either makes or breaks
(depending upon construction) a connection with a fixed contact. If the set of contacts was
closed when the relay was de-energized, then the movement opens the contacts and breaks the
connection, and vice versa if the contacts were open. When the current to the coil is switched
off, the armature is returned by a force, approximately half as strong as the magnetic force, to its
relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in
industrial motor starters. Most relays are manufactured to operate quickly. In a low-voltage
application this reduces noise; in a high voltage or current application it reduces arcing.
When the coil is energized with direct current, a diode is often placed across the coil to dissipate
the energy from the collapsing magnetic field at deactivation, which would otherwise generate
a voltage spike dangerous to semiconductor circuit components. Such diodes were not widely
used before the application of transistors as relay drivers, but soon became ubiquitous as
early germanium transistors were easily destroyed by this surge. Some automotive relays
include a diode inside the relay case.
If the relay is driving a large, or especially a reactive load, there may be a similar problem of
surge currents around the relay output contacts. In this case a snubber circuit (a capacitor and
resistor in series) across the contacts may absorb the surge. Suitably rated capacitors and the
associated resistor are sold as a single packaged component for this commonplace use.
If the coil is designed to be energized with alternating current (AC), some method is used to split
the flux into two out-of-phase components which add together, increasing the minimum pull on
the armature during the AC cycle. Typically this is done with a small copper "shading ring"
crimped around a portion of the core that creates the delayed, out-of-phase component, which
holds the contacts during the zero crossings of the control voltage.
Contact materials for relays vary by application. Materials with low contact resistance may be
oxidized by the air, or may tend to "stick" instead of cleanly parting when opening. Contact
material may be optimized for low electrical resistance, high strength to withstand repeated
operations, or high capacity to withstand the heat of an arc. Where very low resistance is
required, or low thermally-induced voltages are desired, gold-plated contacts may be used, along
with palladium and other non-oxidizing, semi-precious metals. Silver or silver-plated contacts
are used for signal switching. Mercury-wetted relays make and break circuits using a thin, self-
renewing film of liquid mercury. For higher-power relays switching many amperes, such as
motor circuit contactors, contacts are made with a mixture of silver and cadmium oxide,
providing low contact resistance and high resistance to the heat of arcing. Contacts used in
circuits carrying scores or hundreds of amperes may include additional structures for heat
dissipation and management of the arc produced when interrupting the circuit. Some relays have
field-replaceable contacts, such as certain machine tool relays; these may be replaced when
worn out, or changed between normally open and normally closed state, to allow for changes in
the controlled circuit.
Fig.30 Schematic Diagram of a Relay Circuit

Fig.31 Hardware Installation of a Relay Module


Relays are used wherever it is necessary to control a high power or high voltage circuit with a
low power circuit, especially when galvanic isolation is desirable. The first application of
relays was in long telegraph lines, where the weak signal received at an intermediate station
could control a contact, regenerating the signal for further transmission. High-voltage or
high-current devices can be controlled with small, low voltage wiring and pilots switches.
Operators can be isolated from the high voltage circuit. Low power devices such
as microprocessors can drive relays to control electrical loads beyond their direct drive
capability. In an automobile, a starter relay allows the high current of the cranking motor to
be controlled with small wiring and contacts in the ignition key.

Relays are also named with designations like

 Single Pole Single Throw (SPST) – This type of relay has a total of four terminals. Out of
these two terminals can be connected or disconnected. The other two terminals are needed for
the coil.
 Single Pole Double Throw (SPDT) – This type of a relay has a total of five terminals. Out f
these two are the coil terminals. A common terminal is also included which connects to either
of two others.
 Double Pole Single Throw (DPST) – This relay has a total of six terminals. These terminals
are further divided into two pairs. Thus they can act as two SPST’s which are actuated by a
single coil. Out of the six terminals two of them are coil terminals.
 Double Pole Double Throw (DPDT) – This is the biggest of all. It has mainly eight relay
terminals. Out of these two rows are designed to be change over terminals. They are designed
to act as two SPDT relays which are actuated by a single coil.

The different types of relays that are in use today widely for the protection of the systems
concerned are-

 Electromagnetic Attraction type Relays


 Electromagnetic Induction type relays
 Induction type Overcurrent Relays
 Induction type Reverse Power Relays
 Distance Relays
 Differential Relays
 Translay Scheme

Programming the Relay Module


void setup ()
{
pinMode (7, OUTPUT);
}

void loop ()
{
digitalWrite (7, LOW);
delay (10000);
digitalWrite (7, HIGH);
delay (10000);
}

Fig.32 Pin Configuration of a 4 Channel Relay Module

Selection of an appropriate relay for a particular application requires evaluation of many


different factors:

 Number and type of contacts – normally open, normally closed, (double-throw)


 Contact sequence – "Make before Break" or "Break before Make". For example, the old style
telephone exchanges required Make-before-break so that the connection didn't get dropped
while dialing the number.
 Contact current rating – small relays switch a few amperes, large contactors are rated for up
to 3000 amperes, alternating or direct current
 Contact voltage rating – typical control relays rated 300 VAC or 600 VAC, automotive types
to 50 VDC, special high-voltage relays to about 15,000 V
 Operating lifetime, useful life - the number of times the relay can be expected to operate
reliably. There is both a mechanical life and a contact life. The contact life is affected by the
type of load switched. Breaking load current causes undesired arcing between the contacts,
eventually leading to contacts that weld shut or contacts that fail due erosion by the arc.
 Coil voltage – machine-tool relays usually 24 VDC, 120 or 250 VAC, relays for switchgear
may have 125 V or 250 VDC coils,
 Coil current - Minimum current required for reliable operation and minimum holding current,
as well as, effects of power dissipation on coil temperature, at various duty cycles.
"Sensitive" relays operate on a few milli amperes
 Package/enclosure – open, touch-safe, double-voltage for isolation between
circuits, explosion proof, outdoor, oil and splash resistant, washable for printed circuit board
assembly
 Operating environment - minimum and maximum operating temperature and other
environmental considerations such as effects of humidity and salt
 Assembly – Some relays feature a sticker that keeps the enclosure sealed to allow PCB post
soldering cleaning, which is removed once assembly is complete.
 Mounting – sockets, plug board, rail mount, panel mount, through-panel mount, enclosure for
mounting on walls or equipment
 Switching time – where high speed is required
 "Dry" contacts – when switching very low level signals, special contact materials may be
needed such as gold-plated contacts
 Contact protection – suppress arcing in very inductive circuits
 Coil protection – suppress the surge voltage produced when switching the coil current
 Isolation between coil contacts
 Aerospace or radiation-resistant testing, special quality assurance
 Expected mechanical loads due to acceleration – some relays used in aerospace applications
are designed to function in shock loads of 50 g or more
 Size - smaller relays often resist mechanical vibration and shock better than larger relays,
because of the lower inertia of the moving parts and the higher natural frequencies of smaller
parts. Larger relays often handle higher voltage and current than smaller relays.
 Accessories such as timers, auxiliary contacts, pilot lamps, and test buttons
 Regulatory approvals
 Stray magnetic linkage between coils of adjacent relays on a printed circuit board.

Relay Applications

 Relays are used to realize logic functions. They play a very important role in providing safety
critical logic.
 Relays are used to provide time delay functions. They are used to time the delay open and
delay close of contacts.
 Relays are used to control high voltage circuits with the help of low voltage signals. Similarly
they are used to control high current circuits with the help of low current signals.
 They are also used as protective relays. By this function all the faults during transmission and
reception can be detected and isolated.
3. CHAPTER

CIRCUIT OPERATION

3.1 Stages of Operation

The circuit design and implementation is discussed in detail in Chapter 2. In this chapter, the
entire process of operation is discussed starting from a person entering a room to the last
person leaving the room. The stages of operation are as follows-

 When a person enters the room the PIR sensor detects the motion of his entry at the entrance
of the room and sends a signal to the microcontroller Arduino UNO which in turn activates an
LED or a bulb indicating that someone is present in the room.
 The user becomes aware that there is a person in the room and using the Android App on the
Android device connected to the Bluetooth module, he or she can control the lights by using
the on or off button on the display of the app.
 When the user presses the ON or OFF button on the app then the microcontroller sends a
signal to the actuating Relay board which in turn switches the circuit from NO to NC thus
switching the lights connected to it in the ON position.
 The user can choose whichever lights he or she wants to switch ON or OFF.
 The incrementing value if the counter indicates that there are more people entering the room.
As the number of people in the room increases so do the display of the counter value on the
Android App.
 When someone uses the exit door to leave the room, then the PIR sensor connected at the
exit detects the motion and sends a signal to the microcontroller which in turn decreases the
value of the counter variable by one.
 As the people leaving the room increases so the number on the display of the Android app
decreases.
 When the last person leaves the room then the counter value changes from one to zero.
 As soon as the counter value changes to zero the lights connected to the relay board are
automatically switched off and there is no need for the user to switch it off manually.

3.2 ARDUINO Code

#include <SoftwareSerial.h>

int Control_RX = 6; // RX and TX pin for the SoftWareSerial library.

int Control_TX = 7;

int pir1 = 4;
int pir2 = 5;

int Relay1 = 10;

int Relay2 = 11;

int Relay3 = 12;

int Relay4 = 13;

int Counter1 = 0;

int Counter2 = -2;

// Set the default value of the counter as zero.

String Name = "Control"; // Name your module and set the password for it.

int Password = 1111;

String Uart = "9600, 0, 0";

SoftwareSerial Control (Control_RX, Control_TX); // Define the Rx and the Tx pins to


communicate with Bluetooth Module.

void setup() {

Serial.begin(9600);

Control. Begin(9600); // Begin HC-05 Bluetooth module to communicate.

pinMode(pir1,INPUT);

pinMode(pir2,INPUT);

pinMode(Relay1,OUTPUT);

pinMode(Relay2,OUTPUT);

pinMode(Relay3,OUTPUT);

pinMode(Relay4,OUTPUT);

void loop() {

if(digitalRead(pir1)==1)
{

Counter1++;

Counter2 = Counter1;

Control.print(Counter2);

delay(4000);

if(digitalRead(pir2)==1)

if(Counter1>=1)

Counter1--;

Counter2 = Counter1;

Control.print(Counter2);

delay(4000);

if(Counter2>= 1)

if(Control.available()){ // If HC-05 Bluetooth module is available, Commands() has


proceeded.

char c = Control.read();

Serial.println(c); // Control the characters that are set by the app using the terminal.

if(c=='2')

digitalWrite(Relay1,LOW);
}

if(c=='3')

digitalWrite(Relay1,HIGH);

if(c=='4')

digitalWrite(Relay2,LOW);

if(c=='5')

digitalWrite(Relay2,HIGH);

if(c=='6')

digitalWrite(Relay3,LOW);

if(c=='7')

digitalWrite(Relay3,HIGH);

if(c=='8')

digitalWrite(Relay4,LOW);

if(c=='9')

{
digitalWrite(Relay4,HIGH);

if(c=='r')

Counter2 = 0;

if(Counter2==0)

digitalWrite(Relay1,HIGH);

digitalWrite(Relay2,HIGH);

digitalWrite(Relay3,HIGH);

digitalWrite(Relay4,HIGH);

Actual Circuit Arrangement:

Fig.33 Actual Circuit Arrangement in bread board


4. CHAPTER
RESULTS AND DISCUSSION

After the entire project was carried out successfully, some of the noticeable observations that
came into view are the following:-
 Whenever a person enters the room, the IR sensor detects the motion or the movement
of the person at the entrance and it sends the signal to the microcontroller Arduino
UNO which in turn increments the value of the counter by one which is displayed on
the App.
 Now the user has the access to switch the circuit on or off using the on or off button
on the App. When the on button of a particular relay is pressed on the app then the
lights or fans connected to that particular relay gets switched on.
 As the number of persons entering the room increases so do the value of the counter
displayed on the app screen.
 Now when the persons leave the room then the IR sensor located at the exit of the
room senses the motion or the movement of the person. Thus it sends a signal to the
microcontroller Arduino UNO to decrease the value of the counter by one.
 When the last person of the room leaves the room, then the value of the counter
reaches zero. Then the microcontroller Arduino sends a signal to the relay module that
disconnects the supply from the lights and fans and every device connected to the
relay module gets switched off automatically.

These are the particular results that are obtained after running the circuit implemented in the
model. These results are absolute and the circuit works fine under all circumstances. This
chapter dealt with the results and discussion about the project and it shows that the app is
running successfully, the IR sensors are good and the Arduino is working fine to send and
control all signals sent according to the Arduino code and the Android app installed in the
user’s device. So thus we can move on to the next chapter of the conclusion thereby ending our
project report.
5. CHAPTER
CONCLUSION

By designing the Home Automation System in a modular manner, it was possible to create a
system that was complete with sensors, running program, and status monitor in an incremental
fashion. Building the system in this way made finding bugs early on an easy task to accomplish.
After completing a group project such as the HAS, it becomes apparent that a strong emphasis on
hierarchy and modularity early in the design process results in a clear specification. This
specification allows the implementers of the system to keep a clear idea of what tasks need to be
accomplished and never get confused by the complexity of the task at hand. If, while
constructing the system, any part failed to be realized, it was possible to work around the
problem and still manage to implement a system that was working towards the final goal. The
lesson learned is that more time spent designing results in less time wondering what went wrong
with the implementation.

The project leaves a very good opportunity to add and modify components in a variety of
fashion. The scope of improving the projects and adding substantial components without
changing any of the baser materials are incomprehensible. Some of the ways in which the project
can be modified without changing the actual code are:-

 The number of relays connected to the Arduino UNO board can be increased as per the
availability of the relay modules such as 8 channel and 16 channel relay modules.
 The number of rooms concerned with this particular project is one. The number of rooms
that can be controlled with the app and Arduino using the IR sensor modules can be
increased up till 4. For every room we can control a light and fan using the app and the
IR sensors can be placed at the entrance and exits of each room.
 Instead of using Bluetooth module (HC-05), the WI-FI module can also be used that can
provide a wider range of operation. However the cost of using Wi-Fi module is also
considerably greater than the cost of a Bluetooth module.
BIBLIOGRAPHY

The project has been successfully completed by using the help of the following books, websites
and journals:-

 Sensors and Transducers, Second Edition by D. Patranabis, PHI Learning Private


Limited.
 Home Automation System, Javier Castro and James Psota, 6.111: Introductory Digital
Systems Laboratory Final Project, Massachusetts Institute of Technology.
 Appinentor.mit.edu.in, an Android open-source web application provided by Google
and maintained by the Massachusetts Institute of technology for development of
Android Apps.
 Development of an Open-Source Cloud Connected Sensor monitoring Platform, Daniel
K. Fisher, Reginald S. Fletcher, Saseendran S. Anapalli, H. C. Pringle III,
10.4236/ait.2018.81001.
 Principles of Power Systems by V.K. Mehta and Rohit Mehta, S. Chand Publications.

Вам также может понравиться