Microcontroller Based Home Automation System
Microcontroller Based Home Automation System
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
ELECTRICAL ENGINEERING
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.
_______________________ _______________________
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
3. CHAPTER………………………………………………………………………………………………………………………….40
CIRCUIT OPERATION……………………………………………………………………………………………………40
4. CHAPTER………………………………………………………………………………………………………………………….45
RESULTS AND DISCUSSION………………………………………………………………………………………….45
5. CHAPTER…………………………………………………………………………………………………………………………46
CONCLUSION………………………………………………………………………………………………………………46
BIBLIOGRAPHY………………………………………………………………………………………………………………………47
List of Figures
INTRODUCTION
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.
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.
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.
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
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.
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.
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.
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.
A typical system for detecting infrared radiation is given in the following block diagram:
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.
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.
NEP represents detection ability of a detector and is the amount of incident light equal to
intrinsic noise level of a detector.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
}
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.
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.
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.
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.
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.
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.
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.
Screen 1-
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
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.
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.
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.
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.
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.
Electromagnet
Movable Armature
Switch point contacts
Spring
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
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-
void loop ()
{
digitalWrite (7, LOW);
delay (10000);
digitalWrite (7, HIGH);
delay (10000);
}
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
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.
#include <SoftwareSerial.h>
int Control_TX = 7;
int pir1 = 4;
int pir2 = 5;
int Counter1 = 0;
String Name = "Control"; // Name your module and set the password for it.
void setup() {
Serial.begin(9600);
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)
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);
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:-