Professional Documents
Culture Documents
AUTOMATION SYSTEM
BY
EEE/04/2995
SUBMITTED TO
ENGINEERING,
OCTOBER, 2009
CERTIFICATION
This is to certify that this project, the entire design and construction of the home automation
system was carried out and submitted as true work of OLAFUSI MICHAEL OLALEKAN of
Akure in partial fulfilment of the requirements for the award of Bachelor of Engineering in
_____________________ _____________________
______________________ ______________________
_______________________ _____________________
ii
DEDICATION
iii
ACKNOWLEDGEMENT
I cannot but acknowledge the unquantifiable help God gave me throughout this
project work, always showing up whenever I got to the end of my line and felt like changing
the project to a simpler one. Most remarkable was the breakthrough He gave me when I was
I am deeply indebted to my parents and siblings for their constant support especially
in circumstances where I find it hard to even convince myself that my request for help is fair
and reasonable. I am equally indebted my very understanding, fatherly and enviable project
I could not have been able to understand how to go about the vital aspect of the
project work if not for the supervisory assistance of my friend and colleague, Ayoade
Adewole (really, all aspect of my project work was vital). I must also acknowledge my
colleagues who over the four years we have been together, in ways they themselves do not
understand, have been the vital components of my educational and personal growth which
I greatly appreciate the tripartite support and nourishment I enjoyed from the entire
family of the Chapel of Faith, especially through Uncle Victor Omololu, Aunt Patience
Omololu and their ministry. I must also acknowledge the spiritual oversight of the two
chaplains whom I have been under throughout my five year undergraduate study, Rev
iv
ABSTRACT
This project involves the design and construction of an individual control home
household appliances and residential house features like doors, gate and even the windows.
This project is a demonstration of how to design and build a multi purpose remotely
controlled system that can switch OFF and ON any electrical household appliance (including
the security light), by dialling a phone already interfaced via RS232 to a microcontroller that
controls a relay for the automatic switching on and off of the appliance and the phone will
send a feedback short message service text indicating the new state of the appliance, whether
switched ON or OFF.
The results of this project show that a microcontroller is a very powerful device for
building smart electronic devices that can automatically control electrical appliances, with
v
TABLE OF CONTENTS
PROJECT REPORT....................................................................................................................i
CERTIFICATION......................................................................................................................ii
DEDICATION..........................................................................................................................iii
ACKNOWLEDGEMENT........................................................................................................iv
ABSTRACT...............................................................................................................................v
TABLE OF CONTENTS..........................................................................................................vi
TABLE OF FIGURES............................................................................................................viii
LIST OF TABLES....................................................................................................................ix
CHAPTER ONE........................................................................................................................1
INTRODUCTION......................................................................................................................1
1.1 AUTOMATION ..........................................................................................................2
1.1.1 Office automation...............................................................................................3
1.1.2 Building automation...........................................................................................3
1.1.3 Power automation...............................................................................................4
1.1.4 Home automation................................................................................................4
1.2 PROJECT AIM...........................................................................................................4
1.3 PROJECT OBJECTIVE.............................................................................................5
1.4 PROJECT SCOPE AND LIMITATION.....................................................................5
1.5 PROJECT JUSTIFICATION......................................................................................5
1.6 REPORT LAYOUT.....................................................................................................6
CHAPTER TWO.......................................................................................................................7
LITERATURE REVIEW...........................................................................................................7
2.1 HISTORY OF HOME AUTOMATION.....................................................................7
2.2 HOME AUTOMATION SYSTEMS..........................................................................7
2.3 HOME AUTOMATION STANDARDS....................................................................9
2.3.1 INSTEON standard...........................................................................................10
2.3.2 European Home Systems (EHS) protocol........................................................11
2.3.3 ZigBee standard................................................................................................12
2.3.4 KNX .................................................................................................................13
2.3.5 Z-Wave standard...............................................................................................15
2.3.6 X10 standard.....................................................................................................18
2.3.7 LonWorks .........................................................................................................20
2.3.8 ONE-NET standard...........................................................................................20
2.3.9 Universal Powerline Bus...................................................................................22
2.4 HOME AUTOMATION IMPLEMENTATION PLATFORMS.................................24
2.4.1 Powerline communication..................................................................................24
2.4.2 RS232.................................................................................................................25
2.4.3 Ethernet...............................................................................................................29
2.4.4 Bluetooth.............................................................................................................30
2.4.5 Infrared...............................................................................................................31
2.4.6 GSM....................................................................................................................31
2.4.7 Microcontroller...................................................................................................32
2.3.7.1 Von-Neumann architecture.........................................................................33
2.3.7.2 Harvard architecture...................................................................................33
vi
CHAPTER THREE..................................................................................................................35
METHODOLOGY ..................................................................................................................35
3.1 PRELIMINARY CONSIDERATIONS......................................................................35
3.1.1 Selection of implementation platform................................................................35
3.1.2 Selection of hardware components.....................................................................36
3.2 SYSTEM DESIGN......................................................................................................36
3.2.1 PIC18F4455.........................................................................................................37
3.2.1.1 Central Processing Unit (CPU)..................................................................38
3.2.1.2 Random Access Memory (RAM)..............................................................39
3.2.1.3 Read Only Memory (ROM).......................................................................39
3.2.1.4 Input and Output ports (I/O)......................................................................39
3.2.2 PIC18F4455 architecture...................................................................................40
3.2.3 PIC18F4455 programming................................................................................43
3.2.4 Nokia 6021.........................................................................................................44
3.2.5 HIN232..............................................................................................................45
3.2.6 Relay..................................................................................................................47
CHAPTER FOUR....................................................................................................................49
DESIGN AND IMPLEMENTATION......................................................................................49
4.1 BUILDING THE POWER SUPPLY AND INTERFACING THE RELAY.............50
4.2 SERIAL COMMUNICATION BETWEEN THE MICROCONTROLLER AND
NOKIA 6021............................................................................................................51
4.3 PROGRAMMING THE MICROCONTROLLER...................................................52
4.4 TESTING THE COMPLETE DESIGN AND CASING...........................................53
CHAPTER FIVE......................................................................................................................57
CONCLUSION AND RECOMMENDATION........................................................................57
5.1 CONCLUSION..........................................................................................................57
5.2 RECOMMENDATION..............................................................................................57
REFERENCES.........................................................................................................................59
APPENDIX I: Bill of components...........................................................................................61
APPENDIX II: The PIC C code for programming the PIC4455 in CCS C compiler..............62
vii
TABLE OF FIGURES
Figure 2.1: Straight cable connection between RS232 DB9 DTE and RS232 DB9 DCE.......26
Figure 2.2: Straight cable connection between RS232 DB25 DTE and RS232 DB25 DCE...26
Figure 2.3: Straight cable connection between RS232 DB9 DTE and RS232 DB25 DCE.....27
Figure 2.4: Crossover cable connection between DB9 DTE and DB9 DCE...........................27
Figure 2.5: Crossover cable connection between DB25 DCE and DB25 DCE.......................28
Figure 2.6: Crossover cable connection between DB9 DCE and DB9 DCE...........................28
Figure 4.4: The complete home automation system circuit (controlling lighting fixture).......55
viii
LIST OF TABLES
ix
CHAPTER ONE
INTRODUCTION
system ten minutes before you get home on a hot afternoon in January. How about
having a security system that will detect smoke, excessive electrical power usage,
burglar attempts and unauthorized movements in your house and alert you? This is
what home automation is about and there is no end to its application. In fact,
sophisticated home automation systems are now being developed that can maintain an
inventory of household items, record their usage through an RFID (Radio Frequency
'smart home', a home that can detect and identify you, automatically adjust the
lighting to your predefined taste, open doors automatically, play your favourite music,
water your flowers in the morning, switch on the security lights at night and switch
them off in the morning, heat water for bathe and tea, stream to you anywhere in the
world via the internet a live video of what is happening in and around your house. It
heating, and air conditioning into one centrally controlled system. This allows you to
Nowadays, you can hardly find a house without a home automation system
which can range from the remote for the television, burglar alarm and hi-tech security
predefined value.
1
1.1 AUTOMATION
control equipment, industrial machinery and processes, reducing the need for human
them with the physical requirements of work while automation greatly reduces the
need for human sensory and mental requirements as well (Wikipedia, 2009).
expanding range of applications and human activities. Many roles for humans in
pattern recognition, language recognition, and language production ability are well
beyond the capabilities of modern mechanical and computer systems. Tasks requiring
sounds, as well as high-level tasks such as strategic planning, currently require human
expertise.
and laboratory analysis of human genes, blood plasmas, cells, and tissues are carried
out at much greater speed and accuracy by automated systems. Automated teller
2
machines have reduced the need for bank visits to obtain cash and carry out
transactions. In general, automation has been responsible for the shift in the world
economy from agrarian to industrial in the 19th century and from industrial to services
used to digitally create, collect, store, manipulate, and relay office information needed
for accomplishing basic tasks and goals. Raw data storage, electronic transfer, and the
devices, designed to monitor and control the mechanical and lighting systems of a
The building automation system (BAS) core functionality keeps the building climate
monitors system performance and device failures and provides email and/or text
3
1.1.3 Power automation
plants, substations and transformers for effectiveness, efficiency and fault detection. It
has made it possible to have a reliable municipal or national electricity system, which
often comprises remote and hard-to-reach transformers and power sub-system units. It
makes it possible to monitor different power units, relay their status and health
information, and even carry out fault detection and correction without human
interference.
through electronic means that allow for things impracticable, overly expensive or
simply not possible in recent decades. Home automation includes all that a building
automation provides like climate controls, door and window controls, and in addition
control of multimedia home theatres, pet feeding, plant watering and so on. But there
4
system that will remotely switch on or off any household appliance connected to it,
using a microcontroller, voice dial on phone, and short message service for feedback.
scalable home automation system that can be used to remotely switch on or off any
short message service (SMS) for feedback and voice dial from any phone to toggle
switching on and off of any electrical appliance not limited to household appliances,
and sends a feedback message indicating the new present state of the appliance. It
available components like microcontroller, free voice dial service (popularly referred
5
1.6 REPORT LAYOUT
implemented.
• Chapter three highlights the project methodology, giving reasons for choice
coding and debugging. Special emphasis is also made on the flexibility and
enumerated.
6
CHAPTER TWO
LITERATURE REVIEW
Home automation has been around since the world war 1 (1914), in fact,
the television remote (a simple home automation system) was patented in 1893
(Wikipedia, 2009). Since then different home automation systems have evolved with a
sharp rise after the second World War. It's growth has been through various informal
research and designs by technology enthusiasts who want a better way of getting
things done at home without much effort on their part. The systems evolved from one
that can automatically do routine chores like switch on and off security lights, to more
sophisticated ones that can adjust lighting, put the television channel to favourite
residential buildings that make possible the automation of household appliances. The
new stream of home automation systems has developed into a vast one and the current
manufacturers.
The types of home automation systems based on their control systems are:
7
These types were the first to hit the market in the early years, here each
device like the heater or the air conditioner will have an independent control
dedicated to it.
this system you can preset or change the control parameters of several
similar devices, for example, the thermostat of several air conditioners and
windows, refrigerators and cooking systems, all at the same time regardless
of whether you are at home or away. You can connect to the control system
The types of home automation systems based on the carrier mode are:
The least expensive type of home automation system operates over the
home's existing wiring, or powerline carrier. These can range from X10-
a trained professional.
8
2. Wireless systems
Also available are wireless home automation systems that utilize radio-
3. Hardwired systems
Wired, or “hardwired” home control systems are the most reliable and
cable such as Category 5 or 5e, or their own proprietary “bus” cable. That is
why it is best to plan for them when a house is being constructed. Hardwired
systems can perform more tasks at a time and do them quickly and reliably,
making them ideal for larger homes. They can also integrate more systems
in the home, effectively tying together indoor and outdoor lighting, audio
and video equipment, security system, even the heating and cooling system
into one control package that will be easy and intuitive to operate.
Internet Protocol (IP) control automation system uses the internet, gives
each device under its control an Internet Protocol address, and creates a
local area network (LAN) in the home. Hence, the home can be interacted
with over the internet with possibility of live video streaming and real-time
control.
9
There are many established industry standards for home automation
systems and are implemented over the various carrier modes ranging from powerline
to wireless. The popular and major standards are INSTEON, European Home
Systems (EHS), ZigBee, KNX, Z-Wave, X10, LonWorks, ONE-NET and Univerasl
lines and a radio frequency (RF) protocol to communicate with and automate home
developed, based on the X10 model, for control and sensing applications in the home
(Wikipedia, 2009).
using the powerline and/or radio frequency (RF). All INSTEON devices are peers,
meaning each device can transmit, receive, and repeat any message of the INSTEON
INSTEON is not only an effective system for connecting lighting switches and loads
without extra wiring, but it also forms the basis for a more sophisticated home
automation network.
10
• Security alarm interfaces and sensors,
• Appliance management.
Developed by EHSA (European Home Systems Association) it was merged with two
other protocols to form the KNX protocol, which complies with CENELEC norm EN
50090 standard and had a chance to be a basis for the first open standard for home
• Appliance management.
11
2.3.3 ZigBee standard
using small, low-power digital radios based on the IEEE 802.15.4-2003 standard for
with cell phones via short-range radio. The technology defined by the ZigBee
specification is intended to be simpler and less expensive than other WPANs such as
Bluetooth. ZigBee is targeted at radio frequency (RF) applications that require a low
data rate, long battery life, and secure networking (Wikipedia, 2009).
low cost allows the technology to be widely deployed in wireless control and
monitoring applications, the low power-usage allows longer life with smaller
batteries, and the mesh networking provides high reliability and larger range.
bands; 868 MHz in Europe, 915 MHz in the USA and Australia, and 2.4 GHz in most
jurisdictions worldwide. ZigBee chip vendors typically sell integrated radios and
microcontrollers with between 60K and 128K flash memory, such as the Freescale
MC13213, the Ember EM250 and the Texas Instruments CC2430. Radios are also
the chip vendors also offer the ZigBee software stack, although independent ones are
also available. The ZigBee Alliance is a group of companies that maintain and publish
12
• Home Entertainment and Control — Smart lighting, advanced
control.
2.3.4 KNX
communications protocol for intelligent buildings. KNX is the successor to, and
convergence of, three previous standards: the European Home Systems Protocol
(EHS), BatiBUS, and the European Installation Bus (EIB). The KNX standard is
with the physical layers, configuration modes and application experience of BatiBUS
and EHS.
13
KNX defines several physical communication media:
• Powerline networking
• Radio
• Infrared
a PC, according to the needs of a particular implementation. The most common form
Miele & Cie KG, ON Semiconductor, Schneider Electric Industries S.A., Siemens,
themselves, and are intended to be sold to and installed by the end user.
14
2. E-mode or "Easy mode" devices require basic training to install. Their
designs' Zensys, uses a low power RF radio embedded or retrofitted into home
electronics devices and systems, such as lighting, home access control, entertainment
systems and household appliances. The technology has been standardized by the Z-
the network is capable of sending and receiving control commands through walls or
floors and around household obstacles or radio dead spots that might occur in the
home. Z-Wave devices can work singly or in groups, and can be programmed into
scenes or events that trigger multiple devices, either automatically or via remote
control.
15
remote control applications. Unlike Wi-Fi and other IEEE 802.11-based wireless
LAN systems that are designed primarily for high-bandwidth data flow, the Z-Wave
RF system operates in the sub Gigahertz frequency range and is optimized for low-
overhead commands such as on-off (as in a light switch or an appliance) and raise-
lower (as in a thermostat or volume control), with the ability to include device
metadata in the communications. Because Z-Wave operates apart from the 2.4 GHz
telephones and Bluetooth devices that work in the same frequency range. This
control medium that can be reliable alongside common wireless devices. On other
hand, 2.4 GHz frequency usage allows unlicensed devices usage in most countries;
this is convenient to customers and allows wider technology adoption and reduced
deployment costs. This could be not true for other frequencies and could easily turn
operated devices such as remote controls, smoke alarms and security sensors. Z-Wave
16
home electronics such as lighting, climate and security systems, it is
throughout the entire home. One of the benefits of Z-Wave over power
various all-off states for systems throughout the home, such as lighting,
door lock can de-activate a security system and turn on lights when
or cell phone via the Internet. Opening a Z-Wave enabled garage door can
17
trigger exterior and interior home lights, while a Z-Wave motion detector
can trigger an outdoor security light and a webcam, which would allow
devices as a unified event makes it well suited for home audio and video
control could turn on the needed components, set them to the correct
inputs and even lower motorized shades and dim the room lights. Z-
among electronic devices used for home automation. It primarily uses power line
wiring for signalling and control, where the signals involve brief radio frequency
and appliances. It was the first general purpose home automation network technology
and remains the most widely available. Although a number of higher bandwidth
alternatives exist including KNX, INSTEON, BACnet, and LonWorks, X10 remains
18
popular in the home environment with millions of units in use worldwide, and
Packets transmitted using X10 control protocol consist of a four bit house
code followed by one or more four bit unit code, finally followed by a four bit
command.
19
2.3.7 LonWorks
Corporation for networking devices over media such as twisted pair, power lines,
fibre optics, and radio frequency. It is used for the automation of various functions
within buildings such as lighting and HVAC (Heating, ventilating and air
conditioning).
This technology has its origins with chip designs, power line and twisted
twisted pair and power line carrier, are typically included in each of the standards
created around the LonWorks technology. The two-wire layer operates at 78 kbit/s
using differential manchester encoding, while the power line achieves either 5.4 or
tools. Most LonWorks-based control applications are being implemented with some
sort of IP integration, either at the user interface, application level or in the control
20
ONE-NET is an open-source standard for wireless network designed for
home automation, security and monitoring, device control, and sensor networks.
ONE-NET uses UHF ISM radio transceivers and currently operates in the
868 MHz and 915 MHz frequencies. The ONE-NET standard allows for
the 400 MHz and 2.4 GHz frequency ranges. It utilizes Wideband FSK (Frequency-
shift keying) to encode data for transmission and it features a dynamic data rate
protocol with a base data rate of 38.4 kbit/s. The specification allows per-node
Star network topology can be used for lower complexity and cost of peripherals, and
configures and authorizes peer-to-peer transactions. The wireless mesh network mode
allows for repeating to cover larger areas or route around dead areas. Outdoor peer-to-
peer range has been measured to over 500 m, indoor peer-to-peer range has been
demonstrated from 60 m to over 100 m, and mesh mode can extend operational range
Simple transactions typically use message types as defined by the ONE-NET protocol
to exchange sensor data such as temperature or energy consumption, and control data
21
such as on/off messages. Simple transactions use encryption techniques to avoid
blocks of data than simple messages. Block transactions consist of multiple packets
bytes per block. Streaming transactions are similar in format to block transactions but
window sensors, moisture detectors, etc. can achieve a three to five year battery life
with “AA” or "AAA" alkaline cells. Dynamic power adjustment allows signal
strength info to be used to scale back transmit power to conserve battery power. High
data rates and short packet sizes minimize transceiver on time. Further power
efficiency can be gained utilizing deterministic sleep periods for client devices.
communication among devices used for home automation. It uses powerline wiring
devices. While in the X10 protocol this digital data is encoded onto a 120 KHz carrier
which is transmitted as bursts during the relatively quiet zero crossings of the 50 or 60
Hz AC alternating current waveform, the UPB protocol works differently. The UPB
22
UPB Pulses) that are superimposed on top of the normal AC power waveform (sine
wave). Receiving UPB devices can easily detect and analyse these UPB Pulses and
pull out the encoded digital information from them. UPB Pulses are generated by
charging a capacitor to a high voltage and then discharging that capacitor’s voltage
into the powerline at a precise time. This quick discharging of the capacitor creates a
large “spike” (or pulse) on the powerline that is easily detectable by receiving UPB
sophisticated whole house home automation controllers. The simplest controllers are
plug-in controllers that are recommended for a moderate amount of switches and
sophisticated controllers can control more units and/or incorporate timers that
perform pre-programmed functions at specific times each day. Units are also available
that use passive infrared motion detectors or photocells to turn lights on and off based
on external conditions. Finally, whole house home automation controllers can be fully
programmed. These systems can execute many different timed events, respond to
external sensors, and execute, with the press of a single button, an entire scene,
and released in 1999. Based on the concept of the ubiquitous X10 standard, UPB has
an improved transmission rate and higher reliability. While X10 without specialised
23
2.4 HOME AUTOMATION IMPLEMENTATION PLATFORMS
GSM. Each platform having its own peculiarity and area of application.
also used for electrical power transmission. Though electrical power is transmitted
over high voltage transmission lines, distributed over medium voltage and used inside
carrier signal on the wiring system. Different types of powerline communications use
power wiring used. Since the power wiring system was originally intended for
transmission of alternating current (AC) power, in conventional use, the power wire
circuits have only a limited ability to carry higher frequencies. The propagation
problem is a limiting factor for each type of powerline communications. Data rates
200 Khz) carriers impressed on high-voltage transmission lines may carry one or two
analog voice circuits, or telemetry and control circuits with an equivalent data rate of
a few hundred bits per second; however, these circuits may be many miles long.
24
2.4.2 RS232
The RS232 stands for recommended standard number 232. The serial ports
on most computers use a subset of the RS232 standard. The full RS232 standard
specifies a 25-pin "D" connector of which 22 pins are used. Most of these pins are not
needed for normal PC communications, and indeed, most new PCs are equipped with
male D type connectors having only 9 pins, trading off compatibility with the standard
Equipment (DTE) and Data Communication Equipment (DCE). The DTE is an end
instrument that converts user information into signals or reconverts received signals
and uses the male connector. The DTE is the functional unit of a data station that
serves as a data source or a data sink and provides for the data communication control
communication link control device that provides the clock signal and uses the female
connector. The DTE ends the communication line, whereas the DCE provides a path
connection is used. However, to connect two DCEs or DTEs the transmit and receive
lines must be crossed. The DTE is usually a computer or a terminal device and the
Figures 2.1 – 2.3 shows the straight connections while figures 2.4 – 2.6
25
Figure 2.1 : Straight cable connection between RS232 DB9 DTE and RS232 DB9 DCE
Figure 2.2 : Straight cable connection between RS232 DB25 DTE and RS232 DB25 DCE
26
Figure 2.3 : Straight cable connection between RS232 DB9 DTE and RS232 DB25 DCE
Figure 2.4 : Crossover cable connection between DB9 DCE and DB9 DCE
27
Figure 2.5 : Crossover cable connection between DB25 DCE and DB25 DCE
Figure 2.6 : Crossover cable connection between DB9 DCE and DB9 DCE
28
2.4.3 Ethernet
physical connection of two or more devices together. Ethernet was originally based on
broadcast transmission medium. The methods used show some similarities to radio
systems, although there are fundamental differences, such as the fact that it is much
easier to detect collisions in a cable broadcast system than a radio broadcast. The
common cable providing the communication channel was likened to the ether and it
was from this reference that the name "Ethernet" was derived (Wikipedia, 2009).
From this early and comparatively simple concept, Ethernet evolved into the complex
networking technology that today underlies most local area networks. The coaxial
cable was replaced with point-to-point links connected by Ethernet hubs and/or
management and troubleshooting. StarLAN was the first step in the evolution of
Despite the significant changes in Ethernet from a thick coaxial cable bus
generations of Ethernet (excluding early experimental versions) share the same frame
formats (and hence the same interface for higher layers), and can be readily
29
interconnected. And due to the ubiquity of Ethernet, the ever-decreasing cost of the
hardware needed to support it, and the reduced panel space needed by twisted pair
Ethernet, most manufacturers now build the functionality of an Ethernet card directly
into computer and laptop motherboards, eliminating the need for installation of a
2.4.4 Bluetooth
distances from fixed and mobile devices, creating personal area networks (PANs). It
was originally conceived as a wireless alternative to RS232 data cables. It can connect
communications protocol primarily designed for low power consumption, with a short
communicate with each other when they are in range. Because the devices use a radio
other.
spectrum, which chops up the data being sent and transmits chunks of it on up to 79
(GFSK). It can achieve a gross data rate of 1 Mb/s. Bluetooth provides a way to
receivers, digital cameras, and video game consoles through a secure, globally
30
unlicensed Industrial, Scientific and Medical (ISM) 2.4 GHz short-range radio
frequency band. The Bluetooth specifications are developed and licensed by the
Bluetooth Special Interest Group (SIG). The Bluetooth SIG consists of companies in
(Wikipedia, 2009).
2.4.5 Infrared
longer than that of visible light (400 – 700 nm), but shorter than that of microwave
radiation . It's wavelength spans between 750nm and 100 µm and is employed in
(LEDs) to emit infrared radiation which is focused by a plastic lens into a narrow
beam. The beam is modulated, i.e. switched on and off, to encode the data. The
current. It responds only to the rapidly pulsing signal created by the transmitter, and
filters out slowly changing infrared radiation from ambient light. Infrared
communications are useful for indoor use in areas of high population density. IR does
not penetrate walls and so does not interfere with other devices in adjoining rooms.
Infrared is the most common way for remote controls to command appliances.
2.4.6 GSM
GSM which stands for Global System for Mobile Communication, is the
31
most popular standard for mobile phone communication in the world. It is used by
over three billion people across more than 212 countries and territories (Wikipedia,
2009).
GSM basically provides voice call and short message service (SMS). It
operates as a cellular network that mobile phones connect to by trying to search for
cells in their immediate vicinity. The modulation used in GSM is Gaussian minimum-
the signal to be modulated onto the carrier is first smoothed with a Gaussian low-pass
filter prior to being fed to a frequency modulator, which greatly reduces the
operate in the 900 MHz or 1800MHz frequency bands in most countries of the world
except in few countries like USA and Canada where 850 and 1900 MHz bands are
used as the 900 and 1800 MHz bands were already allocated. The GSM technology
uses a 200 Khz radio frequency channels that are time division multiplexed to enable
2.4.7 Microcontroller
computer means that the entire computer system lies within the confines of the
integrated circuit chip (Byte, 2002). The microcontroller on the encapsulated silver of
silicon has features similar to those of our standard personal computer. Its ability to
store and run unique programs makes it extremely versatile, and its ability to perform
maths and logic functions allows it to mimic sophisticated logic and electronic
32
such as automobile engine control systems, remote controls, office machines,
appliances, power tools and toys. Hence, microcontrollers due not function in
isolation, they accept input from one or more devices and provide output to other
devices within a given system. In fact, they are responsible for the intelligence in most
The microcontroller has two general architecture types that define its mode
This architecture has a single, common memory space where both program
instructions and data are stored. There is a single data bus which fetches both
instructions and data. And each time the CPU fetches a program instruction it may
have to perform one or more read/write operations to data memory space. It must wait
until these subsequent operations are complete before it can fetch and decode the next
program instruction. The advantage to this architecture lies in its simplicity and
economy. On some Von Neumann machines the program can read from and write to
CPU registers, including the program counter. This can be dangerous as you can point
the processor to memory blocks outside program memory space and careless
instructions and data. There are two or more internal data buses which allow
simultaneous access to both instructions and data. The CPU fetches instructions on
33
the program memory bus. If the fetched instruction requires an operation on data
memory, the CPU can fetch the next program instruction while it uses the data bus for
its data operation. This speeds up execution time at the cost of more hardware
34
CHAPTER THREE
METHODOLOGY
used in order to build a reliable and flexible system that can be easily operated and
adapted for a new household appliance. Therefore, for the purpose of this project
some specific deliberate choices were made on the type of platforms, hardware
Before the actual design of the project work, specific deliberate choices in
made. Priority was given to low cost availability, reliability, flexibility and simplicity
over which a home automation system can be implemented. Of the currently available
Microcontroller; RS232, GSM and Microcontroller were found most appropriate due
to their low cost availability, reliability and simplicity when used for an individual
control home automation system which my project work is on. Powerline and
Ethernet is too expensive and complex for this kind of home automation system,
35
3.1.2 Selection of hardware components
implemented. For RS232, there are DB-9 and DB-25 connection cables, but DB-9
cable was found most appropriate because it is cheaper, more readily available, less
bulky and just sufficient for the designed system when compared with DB-25. For
GSM, there are GSM modems and phone brands, but Nokia 6021 was chosen due to
its low cost availability, ability to understand AT commands and availability of its
RS232 DB-9 cable. Finally, for Microcontroller, the popular ones are those produced
manufactured PIC microcontroller was found most suitable due to its low cost
Nokia 6021 mobile phone, RS232 standard for communication between the
microcontroller and mobile phone, HIN232 for interfacing the microcontroller, a relay
As illustrated in the block diagram shown in figure 3.1, when the Nokia
6021 receives the required signal, it communicates via the RS232 and HIN232 to the
PIC18F4455, the PIC18F4455 controls the relay state via a driver and this in turn
36
RS232 HIN232
S ER IA L
PIC18F4455
D R IV ER
3.2.1 PIC18F4455
controller”. The PIC microcontroller contains a CPU (central processing unit), RAM
(random access memory), ROM (read-only memory), I/O (input/output) lines, serial
37
and parallel ports, timers and sometimes other built in peripherals such as A/D
Figure 3.2 shows the interactions (data flow) between the main
microcontroller parts.
The CPU is responsible for all the computing, it fetches, decodes and
executes program instructions and directs the flow of data to and from memory. It
performs the calculations required by program instructions and places the results of
these calculations, if required, into memory space. Most CPUs are synchronous,
meaning that they depend on the cycles of a processor clock, this clock generates a
million cycles/second.
38
3.2.1.2 Random Access Memory (RAM)
The RAM, random access memory, is used to write and read data values as
a program runs. RAM is volatile meaning that if the power supply to the
microcontroller is removed, its contents are lost. All variables used in a program are
allocated from the RAM. The time to retrieve information from RAM does not
depend upon the location of the information because RAM is not sequential, hence the
term random access. Most small PIC microcontrollers provide very little RAM which
forces you to write applications that use RAM wisely. Manipulating large data
structures and using pointers, re-entrant or recursive functions use large amounts of
The ROM, read only memory, is non-volatile memory used for program
information and permanent data. The microcontroller uses ROM memory space to store
program instructions it will execute when it is started or reset. Program instructions must be
saved in non-volatile memory so that they are not affected by loss of power, the
Without some means of getting information and signals in and out, the
microcontroller will have little or no use. Hence, the input and output ports are used to
pass data in and out of the microcontroller in a controlled manner, often according to
a standard protocol. The PIC microcontroller ports are of two types namely, serial and
parallel ports. They can operate in two main modes namely, synchronous and
39
asynchronous modes. The parallel I/O ports require a data line for each bit in a byte,
while the serial I/O uses a single data line for all the bits in the data stream by
transferring the bits in sequence. The synchronous mode involves synchronizing the
data transfer with a clock while the asynchronous mode does not. PIC
microcontrollers most often have parallel I/O capability built in and the serial I/O as a
peripheral feature.
nano watt technology microcontroller, was used in the actual design (Microchip,
2007).
40
• 24576 Bytes flash program memory,
• 18 interrupt sources,
41
Figure 3.4 : PIC18F4455 block diagram
42
3.2.3 PIC18F4455 programming
a complier and a programmer were used. There are many available compilers for
MPLAB, but CCS C (whose interface is shown in figure 3.5) was used. Also, there
through which programs written can be compiled into Hexadecimal codes. The IDE
43
Figure 3.6 : MikroElectronika programmer interface
Nokia 6021, shown in figure 3.7, is an EDGE (Enhanced Data Rates for
GSM Evolution) enabled mobile phone. It is built on the GSM technology standard
and has both Infrared and Bluetooth transceivers, these features make it suitable for
use in building an home automation system. It can serve as an extremely long range
remote (one that can be controlled from anywhere in the world) via a combination of
two or more of its Infrared or Bluetooth functionality, voice and data call capabilities,
44
short and multimedia message service (SMS/MMS) and wireless application protocol
(WAP). It also has an RS232 data cable called DKU-5 cable with which the phone can
In remote communication with the Nokia 6021, Hayes command set (also
consisting of series of short text strings which combine together to produce complete
commands for operations such as dialling, hanging up, sending/reading text messages,
3.2.5 HIN232
chip, used for making serial communication possible between a device that uses TTL
(transistor-transistor logic) signal levels and another device that uses RS232 signal
45
Figure 3.8 : HIN232 pinout
It requires a single +5V power supply and feature onboard charge pump
voltage converters which generate +10V and -10V supplies from the 5V supply. Its
drivers feature true TTL input compatibility, slew-rate limited output, and 300Ω
power-off source impedance. The receivers can handle up to +30V, and have a 3kΩ to
7kΩ input impedance, and they feature hysteresis to greatly improve noise rejection.
46
3.2.6 Relay
switch and a spring, that opens and closes under the control of another electrical
circuit. The spring holds the switch in one position, until a current is passed through
the coil, the coil generates a magnetic field which moves the switch. Because the relay
is able to control an output circuit of higher power than the input circuit, it is often
• Latching relay – This relay has two relaxed states (bistable) and it is
switched off, the relay remains in its last state. This is possible due to a
armature and contacts in position while the coil is relaxed. Hence, the first
pulse of current to the coil turns the relay on and the second pulse turns it
off.
• Reed relay – This relay has a set of contacts inside a vacuum or inert
current passes through a coil around the glass tube. Reed relays are capable
of faster switching speeds than most other relay types, but have a low
47
• Contactor relay – This is a very heavy-duty relay used for switching
electric motors and lighting loads. High current contacts are made with
Contactor relays are often used for motor starters and they generate a lot of
is just that it does not have any moving part which increases its long-term
reliability.
48
CHAPTER FOUR
Firstly, a flow chart as shown in figure 4.1 was developed for the design
Start
Send message
Send message
Phone rings
Yes
No Yes
Switch appliance Appliance already Switch appliance
on switched on off
49
4.1 BUILDING THE POWER SUPPLY AND INTERFACING THE RELAY
• 5V voltage regulator.
Voltage regulator
Bridge rectifier
Capacitor
Transformer
50
The primary side of the transformer was connected to a 220V AC mains
while the 9V secondary side was connected to the alternating voltage input pins of the
bridge rectifier. The DC output of the bridge rectifier was sent to the 5V voltage
regulator which supplies the constant 5V voltage supply needed by the PIC4455 and
HIN232.
microcontroller and the Nokia 6021 mobile phone, the voltage level signals from the
RS232 DB-9 data cable of the phone had to be converted to the corresponding
TTL/CMOS voltage level signals that the microcontroller understands. In doing this,
HIN232 which is an RS232 line driver/receiver was used to convert the RS232 signals
receive pin C7 were connected to the TTL/CMOS input and output pins 9 and 10, in
doing this connection it was necessary to connect the transmit pin (C6) of the
microcontroller to the input receive pin of the HIN232 and the receive pin (C7) of the
microcontroller to the output transmit pin of the HIN232. This ensured the cross
Communication Equipment) for both the microcontroller and the Nokia 6021 are
DCEs. For the DB-9 cable, the transmit pin 2 is connected to the RS232 output pin 7
Finally, the DTR (data terminal ready) pin 4 and RTS (request to send) pin
7 of the DB-9 cable were connected to the +5V terminal while the signal ground pin 5
51
was connected to the ground terminal. The complete connection is shown in figure
4.3.
HIN232
RS232 DB-9
connector
PIC4455
microcontroller
PIC C code that was built into an hexadecimal code to be programmed into the
PIC4455.
• Include the required header files which are 18f4455.h and string.h
header files.
52
• Set the communication parameters like the clock rate (20 MHz), the
baud rate (9600 bits/s), the transmit pin (PIN C6) and the receive pin
(PIN C7).
• Initialize the PIC4455 ports to be used. Pin C7 was set as an input pin
since it was the receive pin, the port D was initialized to low since D4
• Send the AT commands that will put the phone in text mode
printf(“at+cmgf=1;+cnmi=2,3,2,2,1\r”);
its receive pin, it will execute the main functional codes that will
if the phone is ringing and the course of action to take before going
if(kbhit())
{
...
}
53
After the completion of the hardware coupling, several tests were done on
1. The system would not work when the phone is connected after
powering it, even after a reset. This was due to the fact that the signals
sent at first by the system to the phone do not die of the line immediately
and affects subsequent signals sent even after connecting and resetting the
powering the system. Much concern was not given to this shortcoming
2. It was also observed that the system would not respond after about
four loop cycles (this corresponds to four concurrent switch toggle). This
process new data sent it by the phone after those cycles. The attempted
solution was to find a way of flushing the buffer after each cycle, but due
to little help found from books, internet and fellow PIC programmers, it's
Other than in the above stated situations, the system worked very well and
reliably.
In designing the case for the system, utmost concern was given to guarding
the system from physical strain and stress during carriage and project presentation. A
transparent plastic material was used for the casing as against glass material which
54
may easily break, a paper material which may give in to strain and stress, or even a
metallic material which will make the project work quite uneconomical, clumsy and
heavy. The casing was made in a manner that permits the whole circuit board to be
fixture, and the designed system are shown in figure 4.4 and 4.5.
55
Figure 4.5: The individual control home automation system
56
CHAPTER FIVE
5.1 CONCLUSION
automation system can be cheaply made from low-cost locally available components
and can be used to control multifarious home appliances ranging from the security
lamps, the television to the air conditioning system and even the entire house lighting
system. And better still, the components required are so small and few that they can
The designed home automation system was tested a number of times and
certified to control different home appliances used in the lighting system, air
conditioning system, heating system, home entertainment system and many more
(this is as long as the maximum power and current rating of the appliance does not
Bluetooth, Infrared and WAP connectivity without much change to the design and yet
still be able to control a variety of home appliances. Hence, this system is scalable
and flexible.
5.2 RECOMMENDATION
In consonance with the project work and in view of the researched methods
57
• The department should help the students in getting components that
the use of the conventional integrated circuits and logic gates makes the
one home appliance at once through the use of short message service texts
rather than voice dial though it will be more expensive and will require
system. Also, to cut the cost of mobile phone, the project may be
specialised functions like text messaging and/or phone calls. This GSM
modems often are cheaper and more reliable than GSM mobile phones.
58
REFERENCES
Byte Craft (2002). First Steps with Embedded Systems. Byte Craft Limited, Canada.
B & B Electronics (2003) RS-232 connections that work! DTE & DCE FAQ. From
http://www.bb-elec.com Retrieved on 29/03/2003
Collins, T. J. (2008). A project report on the design and construction of a low voltage
power line communication system. Project Report, FUTA Akure.
59
Wikipedia (2009). KNX (standard). From
http://en.wikipedia.org/wiki/KNX_(standard). Retrieved on 8/3/2009
60
APPENDIX I: Bill of components
61
APPENDIX II: The PIC C code for programming the PIC4455 in CCS C
compiler
#include <18f4455.h>
#use delay(clock=12000000)
#use rs232(baud=9600, xmit=PIN_C6,rcv=PIN_C7)
#fuses HS,NOWRT,NOWDT,NOPUT,NOPROTECT,NOBROWNOUT,NOLVP,NOCPD,NODEBUG
void main()
{
set_tris_c(128);
set_tris_b(0);
output_b(255);
set_tris_d(0);
output_d(0);
delay_ms(500);
printf("at+cmgf=1;+cnmi=2,3,2,2,1\r"); /* This puts the phone in text
mode and enables notification sending */
i=getch(); // \
u=getch(); // \
gets(data); // \
// |-Extract and silent the initial sent instruction
i=getch(); // /
u=getch(); // /
gets(data1);// /
back:
62
gets(data3);
b=0;
for(a=1;a<=6;a++)
{
req[b]=data3[a];
b++;
}
strncpy(mem,req,4);
strcpy(test,"RING"); /* The control string which the phone sends when
there is a phone call */
}
if(toggle==0)
{
output_low(PIN_D4); //set pin D4 to 0V
//delay_ms(5);
printf("at+cmgs=\"08064702218\"\r");
//delay_ms(50);
printf("appliance is switched off");
putc(26);
//delay_ms(10);
}
}
goto welcome;
}
goto back;
}
63