Home Automation System

Download as pdf or txt
Download as pdf or txt
You are on page 1of 50

Presidency University

Shanjedul Hassan

Page No: 2
ABSTRACT
The home automation is one of the most emerging trends in
modernization of home appliance control. Presently, conventional wall switches are
located in different parts of the house and one has to physically go near them and press
them to turn the loads on/off. It becomes very difficult for the elderly or physically
handicapped people to do so. This system is designed to provide control of home
appliances remote and via Bluetooth Android based Smart phone app. The proposed
system does not require a dedicated server PC with respect to similar systems and offers
a novel communication protocol to monitor and control the home environment with
more than just the these devices can be controlled through a web application or via
Bluetooth Android based Smart phone app. The proposed system does not require a
dedicated server PC with respect to similar systems and offers a novel communication
protocol to monitor and control the home environment with more than just the switching
functionality. To demonstrate the feasibility and effectiveness of this system, devices
such as light switches, temperature sensor, gas sensor and motion sensors have been
integrated with the proposed home control system. This paper presents a low cost and
flexible home control and environmental monitoring system.

Page No: 3
Chapter 1 : Introduction of Home Automation System
1.1 Introduction…………………………………………………………………………..6
1.2 About Project………………………………………………………………………....7

Chapter 2: Hardware Implementation of Home Automation System

2.1 Block Diagram of Digital Home Automation…………………………………………….8

Chapter 3: Component Description of Using Home Automation System

3.1 Resistors………………………………………………………………………………... 11

3.2 Capacitor ……………………………………………………………………………… 13

3.3 Power Supply………………………………………………………………………….. 16

3.4 Atmega 328P IC………………………………………………………………………. 18

3.5 MQ-07 Gas Sensor……………………………………………………………………… 21

3.6 Temperature and Humidity sensor Module………………………………………….. ..24

3.7 PIR Sensor…………………………………………………………………………… 26

3.8 LDR……………………………………………………………………………….…. 31

3.9 4 Relay Module ……………………………………………………………………… 35

3.10 Infrared Receiver( IR)……………………………………………………………….. 36

3.11 4x4 Matrix Keypad …………………………………………………. ………………. 38

Page No: 4
Chapter 4: Software Implementation and Testing
4.1 Main Program: a) Microcontroller-1…………………………………………………….39

b) Microcontroller-2…………………………………………………….43

Page No: 5
Chapter---1

1.1 Introduction

Home automation system focuses on controlling home


electronic devices whether you are inside or outside your home. home automation gives
an individual the ability to remotely or automatically control things around the home. A
home appliance is a device or instrument designed to perform a specific function,
specially an electrical device, such as a Fan, Light, Password Door, for household use.
The words appliance and devices are used interchangeably.

Automation is today‟s fact, where things are being controlled automatically, usually the
basic tasks of turning on/off certain devices and beyond, either remotely or in close
proximity. Automation lowers the human judgment to the lowest degree possible but
does not completely eliminate it. The concept of remote management of household
devices over the internet from anywhere, any time in the world today can be a reality.
Assume a system where from the office desk, the user could view the status of the
devices and decides to take control by air conditioner, and switches on or off some of the
lights. This user could walk back home and only finds a very comfortable, pleasant
home.

The recent developments in technology which permit the use of radio frequency
technology such as Bluetooth and android phone , have enabled different devices to have
capabilities of communicating with each other. Bluetooth is a new technology, which has
at its centre the goal of eliminating wired connections between computers. Instead of

Page No: 6
connecting with wires, every appliance has small transmitters/receivers. The radio
frequency used (2.4 GHz) is so high that the range of transmission will be small (about
30 feet). This is important because the range is so small, that it can be used in apartments
without much interference to your neighbors or from them. These are a few reasons that
make Bluetooth technology ideal for home automation. With this in mind, I propose to
design an internet based digital home automation system for remote control of home
appliances.

Many people are always on the move from place to place due to business demands.
Some people can spend a couple of days away from their home leaving all their
household appliances without any kind of monitoring and control.

1.2 About Project

A home Automation system focuses on controlling home


electronic devices whether you are inside or outside your home. Digital Home gives an
individual the ability to remotely or automatically control things around the home. A
Digital home is a device or instrument designed to perform a specific function,
especially an electrical device, such as a remotely window open for household use. The
task can be performed by on bases of sensor data. This will take itself decision and
action to perform.

The recent developments in technology which permit the use of radio frequency
technology such as Bluetooth have enabled different devices to have capabilities of
communicating with each other. Bluetooth is a new technology, which has at its center
the goal of eliminating wired connections between computers. Instead of connecting
with wires, every appliance has small transmitters/receivers. The radio frequency used
(2.4 GHz) is so high that the range of transmission will be small (about 30 feet). This is
important because the range is so small, that it can be used in apartments without much
interference to your neighbors or from them. These are a few reasons that make

Page No: 7
Bluetooth technology ideal for home automation. With this in mind, I propose to design
a digital home automation system for remote control of home appliances.

Chapter---2

2.1 Block Diagram of Home Automation System

Microcontroller- 1

Page No: 8
Microcontroller- 2

Block Diagram Description:

Temperature Sensor is connected to the Analog port of the microcontroller. The output
of the sensor is in is linear form the formula in the code converts the analog reading into
the degrees calices.

PIR sensor is Passive Infrared Sensor .it comes in a fully assembled package and Is
connect to the port pin of the microcontroller. It used for motion detection

Page No: 9
Light Sensor is made to work using a LDR. Whose output is given to the analog port.
The analog voltage is the process in the comptroller to determine the day light intensity.

GAS sensor can be place in kitchens or in workshops to detect the gas leakage. the
sensor is connected to the analog port .the detection of gas is determined by the set point
of the raw data according to the datasheet and the calibration done.

Power supply section the 5v supply is given to the microcontroller circuit. And the 5v
supply is given to the relays.

The digital pin is connected to the LCD display the LCD is used to display the real time
data. of the sensors.

To control the relay operation and to monitor the status of the sensor the Bluetooth
module used and connected to the serial communication port of the microcontroller.

The android phone has a application to communicate with other Bluetooth device this
type of software have been used to control the operation and monitor.

Optional parts like dc/servo motors can be used to make some automated operation like
opening/closing the window, door, locking the door, valves of waters etc.

Page No: 10
Chapter---3

3.1 Resistors
Resistors are the most commonly used component in electronics and their purpose is to
create specified values of current and voltage in a circuit. A number of different
resistors are shown in the photos. (The resistors are on millimeter paper, with 1cm
spacing togive some idea of the dimensions). Photo 1.1a shows some low-power
resistors, while photo 1.1b shows some higher-power resistors. Resistors with power
dissipation below 5 watt (most commonly used types) are cylindrical in shape, with a
wire protruding from each end for connecting to a circuit (photo 1.1-a). Resistors with
power dissipation above 5 watt are shown below (photo 1.1-b).

Fig. 3.1 (b): High-power resistors and rheostats

Page No: 11
The symbol for a resistor is shown in the following diagram (upper: American symbol,
lower: European symbol.)

Fig. 3.1 (c): Resistor symbols

The unit for measuring resistance is the OHM. (the Greek letter Ω – called Omega).
Higher resistance values are represented by “k” (kilo-ohms) and M (meg ohms). For
example, 120 000 Ω is represented as 120k, while 1 200 000 Ω is represented as 1M2.
The dot is generally omitted as it can easily be lost in the printing process.In some circuit
diagrams, a value such as 8 or 120 represents a resistance in ohms. Another common
practice is to use the letter E for resistance in ohms. The letter R can also be used. For
example, 120E (120R) stands for 120 Ω, 1E2 stands for 1R2 etc.

3.2 Capacitor
The capacitor is a component which has the ability or “capacity” to store energy in the
form of an electrical charge producing a potential difference (Static Voltage) across its
plates, much like a small rechargeable battery.

There are many different kinds of capacitors available from very small capacitor beads
used in resonance circuits to large power factor correction capacitors, but they all do
the same thing, they store charge.

In its basic form, a capacitor consists of two or more parallel conductive (metal) plates
which are not connected or touching each other, but are electrically separated either by
air or by some form of a good insulating material such as waxed paper, mica, ceramic,
plastic or some form of a liquid gel as used in electrolytic capacitors. The insulating
layer between a capacitors plates is commonly called the Dielectric.

Page No: 12
Fig. 3.2 ( a ) : Some low-power Capacitor

Capacitance is the electrical property of a capacitor and is the measure of a capacitors


ability to store an electrical charge onto its two plates with the unit of capacitance being
the Farad (abbreviated to F) named after the British physicist Michael Faraday.

Fig. 3.2 ( b ) : Some low-power Capacitor Circuit

Capacitance is defined as being that a capacitor has the capacitance of One Farad when
a charge of One Coulomb is stored on the plates by a voltage of One volt. Capacitance,
C is always positive and has no negative units. However, the Farad is a very large unit
of measurement to use on its own so sub-multiples of the Farad are generally used such
as micro-farads, nano-farads and pico-farads, for example.

Page No: 13
Standard Units of Capacitance
-6
• Microfarad (μF) 1μF = 1/1,000,000 = 0.000001 = 10 F
• Nanofarad (nF) 1nF = 1/1,000,000,000 = 0.000000001 = 10-9 F
-12
• Picofarad (pF) 1pF = 1/1,000,000,000,000 = 0.000000000001 = 10 F
Then using the information above we can construct a simple table to help us convert
between pico-Farad (pF), to nano-Farad (nF), to micro-Farad (μF) and to Farads (F) as
shown.

How to calculate the capacitance for LM7805 Voltage regulator

Knowledge of Ripple factor is essential while designing the values of capacitors

It is given by
Y=1/(4√3fRC) (as the capacitor filter is used)
1. f= frequency of AC ( 50 Hz)
2. R=resistance calculated
R= V/Ic
V= secondary voltage of transformer
V=6√2=8. 4
R=8.45/500mA=16.9Ω standard 18Ω chosen
3. C= filtering capacitance
We have to determine this capacitance for filtering
Y=Vac-rms/Vdc
Vac-rms = Vr/2√3
Vdc= VMax-(Vr/2)
Vr=VMax-VMin
Vr = 5.2-4.8 =0. 4V
Vac-rms = .3464V
Vdc = 5V
Y=0 .06928

Hence the capacitor value is found out by substituting the ripple factor in Y=1/(4√3fRC)

Thus, C= 2314 µF and standard 2200µF is chosen

Datasheet of 7805 prescribes to use a 0.01μF capacitor at the output side to avoid
transient changes in the voltages due to changes in load and a 0.33μF at the input side of
regulator to avoid ripples if the filtering is far away from regulator.

Page No: 14
3.3 DC Power Supply

In most of our electronic products or projects we need a power supply for converting
mains AC voltage to a regulated DC voltage. For making a power supply designing of
each and every component is essential. Here I‟m going to discuss the designing of
regulated 12V Power Supply.

Firstly, make the bridge rectifier for 12 volt power supply and then connect a LM7807
voltage regulator IC in parallel with the output and you‟ll get the 7 volt output. As the
IC is connected in parallel with the 12V output, so the input to the IC is 12V (the
voltage regulator IC’s input should be more than 4 – 5 Volts than the output, like for
LM7812 the input is 18 V) .The following components are required-

1. Step Down Transformer – A single phase 230:18 V step down transformer is


required for 12v dc power supply. Likewise, to design a 5 V power supply you
may use the 230:10. There are three wire in the transformer and 18-0-18
(considering the 36 v) is written on it. So, you‟re needed to connect the
outermost wires of the transformer (which are of same colors).
2. Diode – Four Diodes are used in the circuit for rectification and a single diode is
used as freewheeling diode. All diodes are 1N4007.
3. Voltage Regulator IC– LM 7812 a voltage regulator IC is used in the 12V DC
Power supply.
4. Capacitances– capacitances are used for reducing ripples in DC power supply as
per specifications. A 1000 µF and a 10 µF capacitances. All these items are easily
available at electronics shop.

Circuit Diagram:

Page No: 15
Working Of Full Wave Bridge Rectifier:

When 230 V Ac mains is supplied to the transformer it steps down the voltage to 18 v.
18 v ac is supplied to the diodes of the bridge rectifier which converts the ac into dc for
both the cycles (for each cycle the two diodes conducts and voltage drops across the
diodes is 0.7*2=1.4 V). Through a filtering capacitor the supply goes to the positive pin
of LM7812 IC which regulate the voltage to 12V and the output of the IC is filtered by
the capacitor and the output is taken.

Final Step:

After you have all the above required items, plan the layout of the power supply and
carefully solder all the components. The resulting system will be a 12 volt power
supply with 700mA and check the output of the power supply with a multi meter.

Page No: 16
3.4 ATmega328P IC

The power pins are as follows:

• Vin : The input voltage to the Adriano board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via the
 power jack, access it through this pin.
• 5v: This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 12V), the USB
connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the

Page No: 17
5V or 3.3V pins bypasses the regulator, and can damage your board. We don't
advise it.
• 3v3 : A 3.3 volt supply generated by the on-board regulator. Maximum current
 draw is 50 mA.
 • GND : Ground pins.
• IOREF : This pin on the Adriano board provides the voltage reference with which
the microcontroller operates. A properly configured shield can read the IOREF pin
voltage and select the appropriate power source or enable voltage translators on
the outputs for working with the 5V or 3.3V.

Memory : The ATmega328 has 32 KB (with 0.5 KB used for the boot loader). It
also has 2 KB of SRAM and 1 KB of EEPROM (which can be read and written
with the EEPROM library).
Input and Output : Each of the 14 digital pins on the Uno can be used as an
input or output, using pinMode(), digitalWrite(), and digitalRead() functions. They
operate at 5 volts. Each pin can provide or receive a maximum of 40 mA and has
an internal pull-up resistor (disconnected by default) of 20-50 kOhms. In addition,
some pins have specialized functions:

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

TWI : A4 or SDA pin and A5 or SCL pin. Support TWI communication using the
Wire library.

 There are a couple of other pins on the board:




Page No: 18
AREF: Reference voltage for the analog inputs. Used with analog Reference().
• Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.

See also the mapping between Adriano pins and ATmega328P ports. The mapping
for the Atmega8, 168, and 328 is identical.

• Communication:

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

A Software Serial library allows for serial communication on any of the Uno's
digital pins.

The ATmega328P also supports I2C (TWI) and SPI communication. The Adriano
software includes a Wire library to simplify use of the I2C bus; see the
documentation for details. For SPI communication, use the SPI library.

Microcontroller ATmega328P IC
Operating Voltage 5V
Input Voltage 7-12V
(recommended)
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
boot loader
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)

Page No: 19
Clock Speed 16 MHz

3.5 MQ-07 Gas Sensor

Fig. 3.8 (a) : Gas sensor Module

Operating principle : MQ-7 gas sensor applies SnO2 which has a lower conductivity in
the clear air as a gas-sensing material. In an atmosphere where there may be carbon
monoxide in a certain density, the conductivity of the gas sensor raises along with the
concentration of carbon monoxide increases.

Combustible Gas Sensor – Analogy OutUsed in gas leakage detecting equipments for
detecting ofLPG, iso-butane, propane, LNG combustible gases. Thesensor does not get
trigger with the noise of alcohol,cooking fumes and cigarette smoke.

How to use:
❖We will
Pin No. Symbol Descriptions
illustrate
1 DOUT Digital output
the usage of
2 AOUT Analog output
the module
3 GND Power ground
with an example
4 VCC Positive power supply (2.5V-
of carbon
5.0V)
monoxide
detection by connecting a development board.
❖ Download the relative codes to the development board.
Page No: 20

Connect the development board to a PC via a serial wire and the module to the
development board. Then, power up the development board and start the serial
debugging software.

Here is the configuration of the connection between the module and the development
board

Port Arduino Pin


DOUT D2
AOUT A0
GND GND
VCC 5V

a. Warn-up the sensor for a minute.


b. The detected result can be checked by the LED indicator on the module. Put
the sensor into a container filled with carbon monoxide, you will find the indicator
turns on. While take the sensor out of the container, you can see the indicator turns
off.

OPERATION PRINCIPLE:
The surface resistance of the sensor Rs is obtained through effected
voltage signal output of theload resistance RL which series-wound. The relationship
between them is described:
Rs\RL = (Vc-VRL) / VRL

Page No: 21
Fig. 3.8 (b) : Gas sensor Output signal

Fig. shows alterable situation of RL signal output measured by using Fig. 3.8(b)
circuit output
signal when the sensor is shifted from clean air to carbon monoxide (CO) , output
signal measurement is made within one or two complete heating period (2.5 minute
from high voltage
to low voltage ).
Sensitive layer of MQ-7 gas sensitive components is made of SnO2 with stability, So,
it has
excellent long term stability. Its service life can reach 5 years under using condition.

Applications:
o Gas leak detection system o
Fire/Safety detection system o
Gas leak alarm / Gas detector

Features:
o Simple analog output
o High sensitivity to LPG, iso-butane, propane
o Small sensitivity to alcohol, smoke
o Fast response
o Wide detection range
o Stable performance and long life

Specification:
o Parameter Value Unit
o Target Gas iso-butane, Propane, LPG
o Detection Range 100 to 10000 PPM (part permillions)
o Output Voltage Range 0 to 5 VDC
o Working Voltage 5 VDC
o Current Consumption ≤180
mA o Warmup Time 10 Minutes
o Calibrated Gas 1000ppm iso-butane
o Response Time ≤10s Seconds
o Resume Time ≤30s Seconds

Page No: 22
o Standard Working Condition Temperature:-10 to 65 deg C.
Humidity: o ≤95%RH
o Storage Condition Temperature: -20-70 deg C Hum: ≤ 70%RH

SENSITVITY ADJUSTMENT :

o Resistance value of MQ-7 is difference to various kinds and various concentration


gases. So, When
o using this components, sensitivity adjustment is very necessary. we recommend
that you calibrate the
o detector for 200ppm CO in air and use value of Load resistance that( RL) about 10

o When accurately measuring, the proper alarm point for the gas detector should be
determined after
o considering the temperature and humidity influence. The sensitivity adjusting
program:
o a. Connect the sensor to the application circuit.
o b. Turn on the power, keep preheating through electricity over 48 hours.
o c. Adjust the load resistance RL until you get a signal value which is respond to
a certain
o carbon monoxide concentration at the end point of 90 seconds.
o d. Adjust the another load resistance RL until you get a signal value which
is respond to a CO
o concentration at the end point of 60 secon

3.6 Temperature and humidity module

Product Overview :

DHT11 digital temperature and humidity sensor is a composite Sensor


contains a calibrated digital signal output of the temperature and humidity. Application
of a dedicated digital modules collection technology and the temperature and humidity
sensing technology, to ensure that the product has high reliability and excellent long-
term stability. The sensor includes a resistive sense of wet components and NTC

Page No: 23
temperature measurement devices, and connected with a high-performance 8-bit
microcontroller.

Fig. 3.9 (a) : Temperature and humidity module

Applications :

HVAC, dehumidifier, testing and inspection equipment, consumer goods,


automotive, automatic control, data loggers, weather stations, home appliances, humidity
regulator, medical and other humidity

measurement and control.

Features :

Low cost, long-term stability, relative humidity and temperature


measurement, excellent quality, fast response, strong anti-interference ability, long
distance signal transmission, digital signal output, and precise calibration.

Product parameters :
Relative humidity
Resolution: 16Bi
Repeatability: ±1% RH
Accuracy: At 25. ±5% RH
Interchangeability: fully interchangeable
Response time: 1 / e (63%) of 25. 6s
1m / s air 6s
Hysteresis: <± 0.3% RH
Long-term stability: <± 0.5% RH / yr in
Temperature
Resolution: 16Bit
Repeatability: ±0.2.
Range: At 25. ±2.
Response time: 1 / e (63%) 10S

Page No: 24
Electrical Characteristics

Power supply: DC 3.5~5.5V


Supply Current: measurement 0.3mA standby 60µA
Sampling period: more than 2 seconds

Pin Description

1, the VDD power supply 3.5~5.5V DC


2, DATA serial data, a single bus
3, NC, empty pin
4, GND ground, the negative power

Typical circuit:

Page No: 25
Fig. 3.9 (b) : Temperature and humidity module Typical circuit

Microprocessor and DHT11 of connection typical application circuit as shown above,


DATA pull the microprocessor I / O ports are connected.

1. Typical application circuit recommended in the short cable length of 20 meters on the
5.1K pull-up resistor, the resistance of greater than 20 meters under the pull-up resistor
on the lower of the actual situation.

2. When using a 3.5V voltage supply cable length shall not be greater than 20cm.
Otherwise, the line voltage drop will cause the sensor power supply shortage, caused by
measurement error.

3. Each read out the temperature and humidity values are the results of the last
measurement For real-time data, sequential read twice, but is not recommended to
repeatedly read the sensors, each read sensor interval is greater than 5 seconds can be
obtained accurate data.

Problems you may encounter with multiple sensors:

If, when adding more sensors, you find that the temperature is inconsistent, this indicates
that the sensors are interfering with each other when switching the analog reading circuit
from one pin to the other.

3.7 PIR Sensor

Page No: 26
Some basic stats

These stats are for the PIR sensor in the Adafruit shop which is very much like the
Parallax one . Nearly all PIRs will have slightly different specifications, although they
all pretty much work the same. If there's a datasheet, you'll want to refer to it

• Size: Rectangular
Price:$10.00 at the Adafruit shop
• Output: Digital pulse high (3V) when triggered (motion detected) digital low
when idle (no motion detected). Pulse lengths are determined by resistors and
 capacitors on the PCB and differ from sensor to sensor.
 • Sensitivity range: up to 20 feet (6 meters) 110° x 70° detection range
• Power supply: 5V-9V input voltage,
BIS0001 Datasheet (the decoder chip used)
RE200B datasheet(most likely the PIR sensing element used)
NL11NH datasheet(equivalent lens used)
Parallax Datasheet on their version of the sensor

A great page on PIR sensors from GLOLAB \\


NYU sensor report

How does it work?

PIR sensors are more complicated than many of the other sensors explained in these
tutorials (like photocells, FSRs and tilt switches) because there are multiple variables
that affect the sensors input and output. To begin explaining how a basic sensor works,
we'll use this rather nice diagram.

The PIR sensor itself has two slots in it, each slot is made of a special material that is
sensitive to IR. The lens used here is not really doing much and so we see that the two
slots can 'see' out past some distance (basically the sensitivity of the sensor). When the
sensor
 is idle, both slots detect the same amount of IR, the ambient amount radiated from


 Page No: 27
the room or walls or outdoors. When a warm body like a human or animal passes by, it
first intercepts one half of the PIR sensor, which causes a positive differential change
between the two halves. When the warm body leaves the sensing area, the reverse
happens, whereby the sensor generates a negative differential change. These change
pulses are what is detected.

Testing your PIR:

Once you have your PIR wired up its a good idea to do a simple test to verify that it
works the way you expect. This test is also good for range testing. Simply connect 3-4
alkaline batteries (make sure you have more than 3.5VDC out but less than 6V by
checking with your millimeter!) and connect ground to the - pin on your PIR. Powergoes
to the + pin. Then connect a basic red LED (red LEDs have lower forward voltages than
green or blue so they work better with only the 3.3v output) and a 220Ω resistor (any
value from 100Ω to 1.0KΩ will do fine) to the out pin as shown. Of course, the LED and
resistor can swap locations as long as the LED is oriented connection and connects
between out and ground.

Now when the PIR detects motion, the output pin will go "high" to 3.3V and light up the
LED!

Once you have the breadboard wired up, insert batteries and wait 30-60 seconds for the
PIR to 'stabilize'. During that time the LED may blink a little. Wait until the LED is off
and then move around in front of it, waving a hand, etc, to see the LED light up!

Page No: 28
Retriggering

Once you have the LED blinking, look on the back of the PIR sensor and make sure that
the jumper is placed in the L position as shown above.

Now set up the testing board again. You may notice that when connecting up the PIR
sensor as above, the LED does not stay on when moving in front of it but actually turns
on and off every second or so. That is called "non-retriggering".

Now change the jumper so that it is in the H position. If you set up the test, you will
notice that now the LED does stay on the entire time that something is moving. That is
called "retriggering"

Page No: 29
(The graphs above are from the BISS0001 datasheet, they kinda suck)

For most applications, "retriggering" (jumper in H position) mode is a little nicer. If you
need to connect the sensor to something edge-triggered, you'll want to set it to "non-
retriggering" (jumper in L position).

Changing pulse time and timeout length

There are two 'timeout‟s associated with the PIR sensor. One is the "Tx" timeout: how
long the LED is lit after it detects movement. The second is the "Ti" timeout which is
how long the LED is guaranteed to be off when there is no movement. These are not
easily changed but if you're handy with a soldering iron it is within reason.

First, lets take a look at the BISS datasheet again

Determining R10 and R9 isnt too tough. Unfortunately this PIR sensor is mislabeled (it
looks like they swapped R9 R17). You can trace the pins by looking at the BISS001

Page No: 30
datasheet and figuring out what pins they are - R10 connects to pin 3 and R9 connects to
pin 7. the capacitors are a little tougher to determine, but you can 'reverse engineer' them
from timing the sensor and solving.

3.8 LDR

Photocells are sensors that allow you to detect light. They are small, inexpensive, low-
power, easy to use and don't wear out. For that reason they often appear in toys, gadgets
and appliances. They are often referred to as CdS cells (they are made of Cadmium-
Sulfide), light-dependent resistors (LDR), and photo resistors.

Photocells are basically a resistor that changes its resistive value (in ohms Ω) depending
on how much light is shining onto the squiggly face. They are very low cost, easy to get
in many sizes and specifications, but are very inaccurate. Each photocell sensor will act a
little differently than the other, even if they are from the same batch. The variations can
be really large, 50% or higher! For this reason, they shouldn't be used to try to determine
precise light levels in lux or mill candela. Instead, you can expect to only be able to
determine basic light changes.

Page No: 31
For most light-sensitive applications like "is it light or dark out", "is there something in
front of the sensor (that would block light)", "is there something interrupting a laser
beam" (break-beam sensors), or "which of multiple sensors has the most light hitting it",
photocells can be a good choice!

Some Basic Stats


These stats are for the photocell in the Adafruit shop which is very much like the PDV-
P8001 . Nearly all photocells will have slightly different specifications, although they all
pretty much work the same. If there's a datasheet, you'll want to refer to it

• Size: Round, 5mm (0.2") diameter. (Other photocells can get up to 12mm/0.4"
 diameter!)
Price:$1.00 at the Ad fruit shop
 • Resistance range: 200KΩ (dark) to 10KΩ (10 lux brightness)
• Sensitivity range:CdS cells respond to light between 400nm (violet) and 600nm
 (orange) wavelengths, peaking at about 520nm (green).
• Power supply: pretty much anything up to 100V, uses less than 1mA of current on
 average (depends on power supply voltage)
Datasheet and another Datasheet
 • Two using andphotocells where nearly all of these graphs are taken from.








Page No: 32
Problems you may encounter with multiple sensors:
If, when adding more sensors, you find that the temperature is inconsistent, this indicates
that the sensors are interfering with each other when switching the analog reading circuit
from one pin to the other. You can fix this by doing two delayed readings and tossing
out the first one.

Measuring the sensor:

As we've said, a photocell's resistance changes as the face is exposed to more light.
When its dark, the sensor looks like an large resistor up to 10MΩ, as the light level
increases, the resistance goes down. This graph indicates approximately the resistance of
the sensor at different light levels. Remember each photocell will be a little different so
use this as a guide only!

Note that the graph is not linear, its a log-log graph!

Photocells, particularly the common CdS cells that you're likely to find, are not sensitive
to all light. In particular they tend to be sensitive to light between 700nm (red) and
500nm (green) light.

Page No: 33
Basically, blue light wont be nearly as effective at triggering the sensor as green/yellow
light!

What the Heck is Lux?


Most datasheets use lux to indicate the resistance at certain light levels. But what is lux ?
Its not a method we tend to use to describe brightness so its tough to gauge. Here is a
table adapted from a Wikipedia article on the topic!

Illuminance Example
0.002 lux Moonless clear night sky
0.2 lux Design minimum for emergency lighting (AS2293).
0.27 - 1 lux Full moon on a clear night
3.4 lux Dark limit of civil twilight under a clear sky
50 lux Family living room
80 lux Hallway/toilet
100 lux Very dark overcast day
300 - 500 lux Sunrise or sunset on a clear day. Well-lit office area.
1,000 lux Overcast day; typical TV studio lighting
10,000 - 25,000 lux Full daylight (not direct sun)
32,000 - 130,000 lux Direct sunlight

Page No: 34
3.9 4 Relay Module

This is a 5V 4-Channels Relay module, It can be controlled directly by a wide range of


microcontrollers such as Arduino, AVR, PIC, ARM and MSP430. 4 relays are included
in this module, with “NC” ports means “Normally connected to COM” and “NO” ports
means “Normally open to COM”. This module also equipped with 4 LEDS to show the
status of relays.

Features
 ❖ mechanical relays with status indicator LED
❖ 
Both “NC” and “NO” ports for each relay

Relay Working Principle:

When a coil of wire is wound on a non magnetic material such as plastic, paper etc. ,it is
called a air-core solenoid or simply a solenoid .if a soft iron core is inserted into the coil,
it becomes an electromagnet. this electromagnet is the basic component for relay and
many other electromechanical devices such as electric bell, circuit breaker etc,.

Relay Module Inputs

The module is supplied with power via the pin labeled VCC and ground via the
pin labeled GND.
The relays are energized with low inputs to the IN1, IN2, IN3 and IN4 inputs

Relay Module Outputs.

There are four relays that each provide dry contact outputs. That is to say that each relay
provides a common (COM) , normally open (NO) and a normally closed (NC) terminal.

Page No: 35
3.10 Infrared Receiver ( IR )

FEATURES

• Very low supply current

• Photo detector and preamplifier in one package

• Internal filter for PCM frequency

• Supply voltage: 2.5 V to 5.5 V

• Improved immunity against ambient light

• Insensitive to supply voltage ripple and noise

Page No: 36
DESCRIPTION
These products are miniaturized IR receiver modules forinfrared remote control systems.
A PIN diode and apreamplifier are assembled on a leadframe, the epoxypackage
contains an IR filter.The demodulated output signal can be directly connected toa
microprocessor for decoding.The TSOP384..series devices are optimized to
suppressalmost all spurious pulses from energy saving lamps likeCFLs. The AGC4 used
in the TSOP384..may suppresssome data signals. The TSOP382..series are
providedprimarily for compatibility with old AGC2 designs. Newdesigns should prefer
the TSOP384..series containing thenewer AGC4.These components have not.

3.11 4x4 Matrix Keypad

This 16-button keypad provides a useful human interface component for


microcontroller projects.Convenient adhesive backing provides a simple way to mount
the keypad in a variety of applications.

Features

Ultra-thin design
Adhesive backing
Excellent price/performance ratio
Easy interface to any microcontroller
Example programs provided for the BASICStamp 2 and Propeller
P8X32Amicrocontrollers

Key Specifications

Page No: 37
Maximum Rating: 24 VDC, 30 mA
Interface: 8-pin access to 4x4 matrix
Operating temperature: 32 to 122 °F(0 to 50°C)

Application Ideas

Security systems
Menu selection
Data entry for embedded systems

How it Works

Matrix keypads use a combination of four rows and four columns to provide button
states to the host
device, typically a microcontroller. Underneath each key is a pushbutton, with one end
connected to onerow, and the other end connected to one column. These connections are
shown in Figure 1.

Figure : 4x4Matrix Keypad Connections

Page No: 38
In order for the microcontroller to determine which button is pressed, it first needs to
pull each of thefour columns (pins 1-4) either low or high one at a time, and then poll the
states of the four rows(pins 5-8). Depending on the states of the columns, the
microcontroller can tell which button is pressed.For example, say your program pulls all
four columns low and then pulls the first row high. It then readsthe input states of each
column, and reads pin 1 high. This means that a contact has been madebetween column
4 and row 1, so button „A‟ has been pressed

Chapter---4

4.1 Main Program (Code)

Micro controller – 1
#include <IRLib.h>
#include <Servo.h>
int a=1;
int b=0;
int light = 4;
int fan = 5;
int ac = 6;
int mcb = 7;
int window_motor = 9;
IRrecv My_Receiver(A0);
IRdecode My_Decoder;
IRdecodeHash My_Hash_Decoder;
Servo My_Servo;

int ldrPin = A3; // select the input pin for the ldr light on off
unsigned int ldrValue = 0; // variable to store the value coming from the ldr
int LDR_LED=2;
int LASER_LDR_PIN = A4; // select the input pin for the ldr light on off
unsigned int laser_ldr_value = 0; // variable to store the value coming from the ldr
int LASER_LDR_LED=3;
int Gas_Fan = 13;
int Gas_Sensor = A2;
int Gas_Sensor_Value = 400;

void setup()
{
Serial.begin(9600);
My_Receiver.enableIRIn(); // Start the receiver
pos = 0;

Page No: 39
My_Servo.attach(window_motor);
My_Servo.write(pos);
delay(200);
while (!Serial); //delay for Leonardo
pinMode(light, OUTPUT);
pinMode(fan, OUTPUT);
pinMode(ac, OUTPUT);
pinMode(mcb, OUTPUT);

pinMode(LDR_LED, OUTPUT);
pinMode(LASER_LDR_LED, OUTPUT);
pinMode(Gas_Fan, OUTPUT);
pinMode(Gas_Sensor, INPUT);
}

void loop() {

if (My_Receiver.GetResults(&My_Decoder)) {//Puts results in My_Decoder


My_Hash_Decoder.copyBuf(&My_Decoder);//copy the results to the hash decoder
My_Decoder.decode();
My_Hash_Decoder.decode();

My_Receiver.resume();
if (My_Decoder.value == 0xCD0) {
My_Servo.write(180, 30, true);
}
if (My_Decoder.value == 0xA70) {
My_Servo.write(90, 30, true);
}
if (My_Decoder.value == 0x2D0) {
My_Servo.write(0, 30, true);
}
if (My_Decoder.value == 0x10) {
digitalWrite(light, HIGH);
}
if (My_Decoder.value == 0x58EE) {

digitalWrite(light, LOW);
}
if (My_Decoder.value == 0x810) {
digitalWrite(fan, HIGH);
}
if (My_Decoder.value == 0xE90) {

digitalWrite(fan, LOW);
}

Page No: 40
if (My_Decoder.value == 0x410) {
digitalWrite(ac, HIGH);
}
if (My_Decoder.value == 0x59EE) {

digitalWrite(ac, LOW);
}
if (My_Decoder.value == 0xC10) {
digitalWrite(mcb, HIGH);
}
if (My_Decoder.value == 0x5E25) {

digitalWrite(mcb, LOW);
}
}
if(Serial.available())
{//if there is data being recieved
blueToothVal=Serial.read(); //read it
}

if (blueToothVal=='a')
{//if value from bluetooth serial is n
digitalWrite(light,HIGH); //switch on light
if (lastValue!='a')
Serial.println(F("light is on")); //print light is on
lastValue=blueToothVal;
}
else if (blueToothVal=='b')
{//if value from bluetooth serial is n
digitalWrite(light,LOW); //turn off light
if (lastValue!='b')
Serial.println(F("light is off")); //print light is on
lastValue=blueToothVal;
}

if (blueToothVal=='c')
{//if value from bluetooth serial is n
digitalWrite(fan,HIGH); //switch on fan
if (lastValue!='c')
Serial.println(F("fan is on")); //print fan is on
lastValue=blueToothVal;
}
else if (blueToothVal=='d')
{//if value from bluetooth serial is n
digitalWrite(fan,LOW); //turn off fan
if (lastValue!='d')
Serial.println(F("fan is off")); //print fan is on

Page No: 41
lastValue=blueToothVal;
}
if (blueToothVal=='e')
{//if value from bluetooth serial is n
digitalWrite(ac,HIGH); //switch on ac
if (lastValue!='e')
Serial.println(F("ac is on")); //print ac is on
lastValue=blueToothVal;
}
else if (blueToothVal=='f')
{//if value from bluetooth serial is n
digitalWrite(ac,LOW); //turn off ac
if (lastValue!='f')
Serial.println(F("ac is off")); //print ac is on
lastValue=blueToothVal;
}
if (blueToothVal=='g')
{//if value from bluetooth serial is n
digitalWrite(mcb,HIGH); //switch on mcb
if (lastValue!='g')
Serial.println(F("mcb is on")); //print mcb is on
lastValue=blueToothVal;
}
else if (blueToothVal=='h')
{//if value from bluetooth serial is n
digitalWrite(mcb,LOW); //turn off mcb
if (lastValue!='h')
Serial.println(F("mcb is off")); //print mcb is on
lastValue=blueToothVal;
}

//***************LDR LIGHT On off Program Start******************************//


{
ldrValue = analogRead(ldrPin);
if(ldrValue<100) digitalWrite(LDR_LED, HIGH); // set the LDR_LED on
else digitalWrite(LDR_LED, LOW); // set the LDR_LED off }

//***************LDR LIGHT On off Program Stop******************************//


//***************LASER LDR LIGHT On off Program Start***********************//

{
laser_ldr_value = analogRead(LASER_LDR_PIN);
if(laser_ldr_value<400) digitalWrite(LASER_LDR_LED, HIGH); // set the LASER_LDR_LED on
else digitalWrite(LASER_LDR_LED, LOW); // set the LASER_LDR_LED off }

//***************LASER LDR LIGHT On off Program Stop***********************//

Page No: 42
{
int analogSensor = analogRead(Gas_Sensor);
if (analogSensor > Gas_Sensor_Value)
{
digitalWrite(Gas_Fan, HIGH);
}
else
{
digitalWrite(Gas_Fan, LOW);
}
}

} // End the program

Micro controller -2

#include<LiquidCrystal.h>
#include <Servo.h>
#include <EEPROM.h>
#include <DHT.h>
#include <Wire.h>
dht sensor;
Servo ser;
LiquidCrystal lcd(13,12,11,10,9,8);
int row[]={3,2,A5,A4}; // Defining row pins of keypad connected to Arduino pins int
col[]={A3,A2,A1,A0}; //Defining column pins of keypad connected to Arduino
int col_scan; // Variable to identify a key press
char temp_press; // Variable to hold value of key press
char check[6],pass[6]; // See About the Program

int i,j,lcd_count,count=1,key_id=0,flag,entry=0; // See About the Program

int Temp= 6;
int led= 7;
int buzzer = 4;
int doormotor =5;
int bajaw = 10;
char ja[6];
int ant=6;

void setup()
{
Serial.begin(9600);
ser.attach(doormotor);
ser.write(0);

Page No: 43
pinMode(buzzer, OUTPUT);
lcd.begin(20,4);
pinMode(led, OUTPUT);

for(i=0;i<=3;i++)
{
pinMode(row[i],OUTPUT);
pinMode(col[i],INPUT);
digitalWrite(col[i],HIGH);
}
lcd.clear();
lcd.setCursor(3,0);
lcd.print("WELCOME TO OUR");
lcd.setCursor(0,1);
lcd.print("DIGITAL ROOM SYSTEM");
lcd.setCursor(0,2);
lcd.print("PRESIDENCYUNIVERSITY");

delay(5000);
lcd.clear();

if(EEPROM.read(3) == NULL){
lcd.print("SET 5 Digit PASS");
} else {
lcd.print("Set Password...");
}
}

void loop()
{
delay(100); //wait a sec (recommended for DHT11)
sensor.read11(Temp);

lcd.setCursor(0,2);
lcd.print("Humidity : ");
lcd.print(sensor.humidity);

lcd.setCursor(0,3);
lcd.print("Temperature: ");
lcd.print(sensor.temperature);

if(EEPROM.read(1) == NULL || ant == 0){


while(entry<2) // Password Setting Loop begins
{
SetPassword();

Page No: 44
}
// Password Setting Loop Ends
}
key_id=0;
keyscan(); // Scan for a Key Press
/* Actions on Key Press begins */
if(key_id==1) // Condition to Check Key is Pressed
{
ja[count] = temp_press;
check[count]=temp_press;
count++;
Serial.print(EEPROM.read(i));
Serial.println();
/* Condition to Unlock Begins*/

if(temp_press=='#')
{
checkPassword();
if(flag==0)
{
delay(100);
digitalWrite(led, HIGH);
digitalWrite(buzzer, LOW);
ser.write(180);
delay(3000);
digitalWrite(led, LOW);
digitalWrite(buzzer, LOW);
ser.write(90);
}
else
{
bajaw++;
digitalWrite(buzzer, HIGH);
delay(2000);
if(bajaw < 3){
digitalWrite(buzzer, LOW);
}
digitalWrite(led, HIGH);
ser.write(90);
}
count=1; // Resetting the counter variable
}
/* Condition to Unlock Ends*/
/* Condition to Change Password Begins */
else if(temp_press=='D')
{

Page No: 45
digitalWrite(buzzer, LOW);
ser.write(180);
delay(5000);
ser.write(90);
}
else if(temp_press=='C')
{
checkPassword();
if(flag==0)
{
lcd.setCursor(0,0);
lcd.print("Enter new Password");
key_id=0;
entry=0;
ant = 0;
}else{
ser.write(90);
bajaw=bajaw+1;
digitalWrite(buzzer, HIGH);
delay(3000);
if(bajaw < 3){
digitalWrite(buzzer, LOW);
}
}
count=1; // Resetting the counter variable
}
/* Condition to Change Password Ends */
/* Condition to LOCK Begins*/
else if(temp_press=='B')
{
lcd.clear();
lcd.setCursor(4,1);
lcd.print("Door Locked");
digitalWrite(led, HIGH);
delay (4000);
digitalWrite(led, LOW);
lcd.clear();
lcd.setCursor(4,0);
lcd.print("Door Locked");
ser.write(90);
count=1; // Resetting the counter variable
}
/* Condition to LOCK Ends*/
}

/* Actions on Key Press Ends*/


}

Page No: 46
/* Main Program Ends */

void SetPassword() // Subroutine to SET User Defined Password


{
keyscan();
if(key_id==1)
{
if(temp_press=='A'||temp_press=='C'||temp_press=='B') // Condition to Check for an
Invalid Keypress
{

digitalWrite(buzzer, HIGH);
delay(500);
digitalWrite(buzzer, LOW);
entry=0;
}
else
{
pass[entry]=temp_press;
int entryy = entry + 1;

EEPROM.write(entry, temp_press);
}
}
key_id=0;
if(entry==5)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Password set & locked");
digitalWrite(led, HIGH);
ser.write(90);
delay(2000);
digitalWrite(led, LOW);

lcd.clear();
lcd.setCursor(4,0);
lcd.print("Door Locked");
}
} // Subroutine to SET Password ENDS

char keyscan()// Subroutine to Scan Keypad for a Keypress


{
for(i=0; i<=3; i++)
{

Page No: 47
digitalWrite(row[0],HIGH);
digitalWrite(row[1],HIGH);
digitalWrite(row[2],HIGH);
digitalWrite(row[3],HIGH);
digitalWrite(row[i],LOW);
for(j=0; j<=3; j++)
{
col_scan=digitalRead(col[j]);
if(col_scan==LOW)
{
key_id=1;
entry++;
temp_press=keypress(i,j);
lcd.setCursor(lcd_count++,1);
lcd.print(temp_press);
if(temp_press=='A'||temp_press=='C'||temp_press=='B')
{
lcd_count=0;
lcd.clear();
}
delay(300);
break;
}}
}}// Subroutine to Scan Keypress Ends

char keypress(int i, int j) // Subroutine to Identify the value of Key pressed


{
if(i==0&&j==0)
{
return('1');
}
if(i==0&&j==1)
{
return('2');
}
if(i==0&&j==2)
{
return('3');
}
if(i==0&&j==3)
{
return('A');
}
if(i==1&&j==0)
{
return('4');
}

Page No: 48
if(i==1&&j==1)
{
return('5');
}
if(i==1&&j==2)
{
return('6');
}
if(i==1&&j==3)
{
return('B');
}
if(i==2&&j==0)
{
return('7');
}
if(i==2&&j==1)
{
return('8');
}
if(i==2&&j==2)
{
return('9');
}
if(i==2&&j==3)
{
return('C');
}
if(i==3&&j==0)
{
return('*');
}
if(i==3&&j==1)
{
return('0');
}
if(i==3&&j==2) {
return('#'); }
if(i==3&&j==3) {
return('D'); }
} // Subroutine to identify Keypress Ends

void checkPassword() // Subroutine to Check User Input Data with SET Password
{
flag=0;
for(i=1;i<=5&&flag==0;i++) {
Serial.print(EEPROM.read(i), DEC);

Page No: 49
Serial.println();
if(check[i]==pass[i] || ja[i]==EEPROM.read(i)) {
flag=0; }
else {flag=1; }
}
} // Subroutine to check password ends

Page No: 50

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy