development of a low cost home automation system …

54
DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM FOR SWITCHING ELECTRICAL DEVICES by Tanvir Ahmad Tarique POST GRADUATE DIPLOMA IN INFORMATION AND COMMUNICATION TECHNOLOGY (PG Dip. in ICT) Institute of Information and Communication Technology (IICT) BANGLADESH UNIVERSITY OF ENGINEERING AND TECHNOLOGY (BUET) 2014

Upload: others

Post on 14-Jan-2022

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

DEVELOPMENT OF A LOW COST HOME AUTOMATION

SYSTEM FOR SWITCHING ELECTRICAL DEVICES

by

Tanvir Ahmad Tarique

POST GRADUATE DIPLOMA IN INFORMATION AND COMMUNICATION

TECHNOLOGY (PG Dip. in ICT)

Institute of Information and Communication Technology (IICT) BANGLADESH UNIVERSITY OF ENGINEERING AND TECHNOLOGY (BUET)

2014

Page 2: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

i

The project report titled "Development of a Low Cost Home Automation System for switching Electrical Devices" submitted by Tanvir Ahmad Tarique, Student ID: 0412311014, Session: April-2012 has been accepted as satisfactory in partial fulfillment of the requirement for the degree of Post Graduate Diploma (ICT) held on 5th November 2014.

BOARD OF EXAMINERS

________________________________ 1. Prof. Dr. Md. Liakot Ali Chairman Professor & Director Institute of Information and Communication Technology BUET, Dhaka ̶ 1000. ________________________________ 2. Prof. Dr. Md. Saiful Islam Member Professor Institute of Information and Communication Technology BUET, Dhaka ̶ 1000. ________________________________ 3. Mohammad Imam Hasan Bin Asad Member Lecturer Institute of Information and Communication Technology BUET, Dhaka ̶ 1000.

Page 3: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

ii

CANDIDATE'S DECLARATION

It is hereby declared that this project report or any part of it has not been submitted elsewhere for the award of any degree or diploma. ___________________ Tanvir Ahmad Tarique

Page 4: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

iii

Dedicated to

My Parents

Page 5: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

iv

Table of Contents

Title Page No.

Board of Examiners i Candidate's Declaration ii Dedication iii Table of Contents iv List of Figures vi List of Abbreviations vi Acknowledgement vii Abstract viii

Chapter 1 Introduction 1

1.1 Introduction 2 1.2 Objective of the specific aims and possible outcome 3 1.3 Organization of the Project Report 4

Chapter 2 Automation System 5

2.1 Introduction 6 2.2 Automation System 6 2.2.1 Types of Automations 6 2.2.2 History of Automation 10 2.2.3 Advantages and Disadvantages 12 2.2.4 Limitations to Automation 13 2.2.5 Some of the Applications

14

2.3 Home Automation 14 2.3.1 Overview and Benefits 15 2.3.2 History of Home Automation 16 2.3.3 System Elements

17

2.4 Purpose of this Project 18 2.5 Microcontroller 18 2.6 Relay 19

Chapter 3 Methodology and Design of the Home Automation

System

20

3.1 Introduction 21 3.2 Methodology 21 3.3 Block Diagram of the Designed Project 21

Page 6: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

v

3.4 Description of the Components in the Block Diagram 22 3.4.1 Microcontroller 22 3.4.2 General Characteristics of ATMEGA328 23 3.4.2.1 Power Managed Modes 23 3.4.2.2 Peripheral Highlights 23 3.4.2.3 Features 25 3.4.2.4 Pin Description of ATMEGA328 26 3.4.2.5 Overview of ATMEGA328

27

3.4.3 The Arduino Board 29 3.4.4 Functional structure of ATMEGA328 30 3.4.5 PIR (Passive InfraRed) Sensor 31 3.4.5.1 Operation of PIR Sensor

31

3.4.6 Relay 32 3.4.6.1 Basic function of Relay 32 3.4.6.2 Relay Module

33

3.5 Flowchart of the Designed Project 34 3.6 Working Principle 34 3.7 Algorithm of the Designed Project 34 3.8 Pseudo-code of the Designed Project 35 3.9 Circuit Diagram of the Designed Project 35 3.10 Design Steps 36

Chapter 4 Results and Discussions

37

4.1 Introduction 38 4.2 Program Code 38 4.3 Pictorial View of the Designed Project 39 4.4 List of Components with Price 40 4.5 Results and Discussions 40 4.6 Advantages of the Designed Project 40 4.7 Disadvantages of the Designed Project 41 4.8 Applications 41

Chapter 5 Conclusion

42

5.1 Conclusion 43 5.2 Future Works

43

References 44

Page 7: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

vi

List of Figures

Figure No. Figure Caption Page No.

Fig. 3.1 Block diagram of the designed project 21 Fig. 3.2 Pin assignment of ATMEGA328 22 Fig. 3.3 ATMEGA328 Microcontroller 24 Fig. 3.4 The Arduino UNO Board 29 Fig. 3.5 ATMEGA328 functional Diagram 30 Fig. 3.6 The PIR Sensor 31 Fig. 3.7 Relay Module 33 Fig. 3.8 Flowchart of the designed project 34 Fig. 3.9 Circuit diagram of the designed project 35 Fig. 4.1 Pictorial view of the designed project (when there is no

human presence) 39

Fig. 4.2 Circuit Pictorial view of the designed project (when there is human presence)of the designed project

39

List of Abbreviations

Abbreviations Elaboration

HVAC Heating, Ventilation and Air Conditioning HAS Home Automation System RFID Radio Frequency Identification PCB Printed Circuit Board PIR Passive Infra-Red PLC Programmable Logic Controllers ATM Automated Teller Machine NC Numerical Control

CNC Computerized Numerical Control USB Universal Serial Bus

Page 8: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

vii

Acknowledgement

At first, I would like to thank and all praise to the Almighty Allah, the most merciful, the most gracious, the source of knowledge and wisdom endowed to mankind, who provided me with the power of mind, strength, patience and capability to carry me through the work and enable me to complete this project. I would like to thank my supervisor, Prof. Dr. Md. Liakot Ali, Director, Institute of Information and Communication Technology, Bangladesh University of Engineering and Technology, Dhaka, Bangladesh for his kind, constant, and inspiring guidance, close encouragement, advice, and valuable suggestions at all stages for preparing this dissertation. In completing this project, I have been fortunate to have help, support and encouragement from many people. I would like to acknowledge them for their cooperation. I would like to thank my family, specially my parents for their continuous support and inspiration throughout the whole period of this undertaking.

Page 9: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

viii

Abstract

Automation is a demand in this era of information and communication technology where a smart control system is used to reduce or replace human operators in the industry, offices or homes to produce some goods or services. Home automation system is the subset of automation system that allows us to control household appliances like light, door, fan, air-conditioner etc. in an intelligent way. It also includes those of domestic activities, such as home entertainment systems, houseplant and yard watering, pet feeding, and the use of domestic robots. Home automation system provides home security and emergency systems to be activated while necessary. It helps handicapped and old aged people which will enable them to control home appliances and alert them in critical situations. It not only refers to reduce human efforts but also energy efficiency and time saving. There are different types of home automation systems in the market. They are generally proprietary and closed, expensive and not very customizable by the end user. To overcome this limitation, there are scopes of research in this area. In this project work, a simple home automation device has been chosen to implement. It will sense the presence of human(s) by the motion sensor and according to its signal the electrical devices will be turned on/off. To do this, a simple PIR sensor has been used to detect the presence of humans. A program code was being downloaded into the microcontroller. When the PIR sensor gives an input signal to the microcontroller, the microcontroller then gives an output signal to the relay module which then turn on the light connected to it. If PIR sensor doesn’t give any output signal which will be feed to the input of the microcontroller, then the relay has been turned off and so the light connected to it. This is a very simple project work which is very cost-effective and can be used in so many places where automatic power consumption control is the main concern.

Page 10: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

1

Chapter 1

Introduction

Page 11: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

2

1.1 Introduction

With advancement of technology things are becoming simpler and easier for us. Automation is the use of control systems and information technologies to reduce the need for human work in the production of goods and services. In the scope of industrialization, automation is a step beyond mechanization. Whereas mechanization provided human operators with machinery to assist them with the muscular requirements of work, automation greatly decreases the need for human sensory and mental requirements as well. Automation plays an increasingly important role in the world economy and in daily experience. Automatic systems are being preferred over manual system. Through this project we have tried to show automatic control of a house as a result of which power is saved to some extent. Home/office automation is the control of any or all electrical devices in our home or office, whether we are there or away. Home/office automation is one of the most exciting developments in technology for the home that has come along in decades. There are hundreds of products available today that allow us control over the devices automatically, either by remote control; or even by voice command. Home automation (also called domotics) is the residential extension of "building automation". It is automation of the home, housework or household activity. Home automation may include centralized control of lighting, HVAC (heating, ventilation and air conditioning), appliances, and other systems, to provide improved convenience, comfort, energy efficiency and security. Disabled can provide increased quality of life for persons who might otherwise require caregivers or institutional care. A home automation system integrates electrical devices in a house with each other. The techniques employed in home automation include those in building automation as well as the control of domestic activities, such as home entertainment systems, houseplant and yard watering, pet feeding, changing the ambiance "scenes" for different events (such as dinners or parties), and the use of domestic robots. Devices may be connected through a computer network to allow control by a personal computer, and may allow remote access from the internet. Typically, a new home is outfitted for home automation during construction, due to the accessibility of the walls, outlets, and storage rooms, and the ability to make design changes specifically to accommodate certain technologies. Wireless systems are commonly installed when outfitting a pre-existing house, as they reduce wiring changes. These communicate through the existing power wiring, radio, or infrared signals with a central controller. Network sockets may be installed in every room like AC power receptacles [1-2].

Page 12: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

3

Home automation is a very promising area. Its main benefits range from increased comfort and greater safety and security, to a more rational use of energy and other resources, allowing for significant savings. It also offers powerful means for helping and supporting the special needs of people with disabilities and, in particular, the elderly. This application domain is very important and will steadily increase in the future. [3] The concept of networking appliances and devices in the house. Home Automation Systems (HASs) represents a great research opportunity in creating new fields in engineering, architecture and computing (Huidobro and Millan, 2004). HASs becoming popular nowadays and enter quickly in this emerging market. However, end users, especially the disabled and elderly due to their complexity and cost, do not always accept these systems [4-5]. The reasons for implementing home automation are various, it can increase security of a house, provide energy savings, provide centralized device control, provide device control in the absence of the user, etc. Development of home automation was mainly initiated by the need for security, so various alarm systems were developed, which ensure house-supervision, and in case of any security risk, they activate the alarms, call telephone numbers, etc. For security purposes various other systems were developed, such as systems that simulate the presence of users. In such systems, in the user absence, the blinds are raised or lowered, and lights, audio and video equipment are turned on or off at specified time. Today, home automation includes various systems, such as control of lighting, air conditioning or blinds, security systems, control of audio or video devices, automated flower watering or pet feeding, etc. Also, various access control systems are included in home automation, such as automated control of a garage door or unlocking the entrance door automatically, e.g. with the use of RFID technology. All of these systems can be connected either by wires or wirelessly [6]. 1.2 Objective with specific aims and possible outcome

The aim of this project is to develop a low cost home automation system. The following objectives will be achieved:

(i) To design the circuit for the proposed system (ii) To design the firmware of the system (iii) To simulate the design (iv) To implement the system in the PCB (v) To test the functionality of the system in the laboratory

The outcome of this project is a prototype of a low cost home automation system.

Page 13: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

4

1.3 Organization of the Project Report

Chapter 1: Introduction: The project documentation starts with the introduction of the Home Automation System with a discussion on the existing systems available. It is followed by objectives and organization of the documentation. Chapter 2: Automation System: In this chapter, the detailed history or literature review about the automation and home automation system is described along with the purpose of this project work. Chapter 3: Methodology and Design of the Home Automation System: In this chapter, the detailed description of the components used is described along with the methodology of the project work and procedure of the design process is given including the block diagram, circuit diagram. Chapter 4: Results and Discussions: In this chapter, the detailed results and discussions of the project work is given along with the working principle, advantages, disadvantages and applications. Chapter 5: Conclusion: Finally conclusion on the project and recommendations for The future are made.

Page 14: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

5

Chapter 2

Automation System

Page 15: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

6

2.1 Introduction

This project is aimed at developing a low-cost home automation system device to control an electrical device to be turned on-off, as an example, in a room according to the presence of any human by using PIR (Passive Infra-Red) sensor. This requirement analysis and specification describes all the functional and non-functional requirements of the proposed system including both software and hardware parts. At first, this chapter starts with the previous and current situations of automation. 2.2 Automation System

Automation or automatic control is the use of various control systems for operating equipment such as machinery, processes in factories, boilers and heat treating ovens, switching in telephone networks, steering and stabilization of ships, aircraft and other applications with minimal or reduced human intervention. Some processes have been completely automated. The biggest benefit of automation is that it saves labor, however, it is also used to save energy and materials and to improve quality, accuracy and precision. The term automation, inspired by the earlier word automatic (coming from automaton), was not widely used before 1947, when General Motors established the automation department. It was during this time that industry was rapidly adopting feedback controllers, which were introduced in the 1930s. Automation has been achieved by various means including mechanical, hydraulic, pneumatic, electrical, and electronic and computers, usually in combination. Complicated systems, such as modern factories, airplanes and ships typically use all these combined techniques [13]. 2.2.1 Types of Automations

One of the simplest types of control is on-off control. An example is the thermostats used on household appliances. Although technically it is a form of automation, its capabilities are primitive. Old style HVAC systems used crude thermostats that were limited to on-off control, but some modern systems use more sophisticated sensors and digital controllers for variable speed fans or controlling other functions. Sequence control, in which a programmed sequence of discrete operations is performed, is often based on system logic that involves system states. An elevator control system is an example of sequence control. The advanced type of automation that revolutionized manufacturing, aircraft, communications and other industries, is feedback control, which is usually continuous

Page 16: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

7

and involves taking measurements using a sensor and making calculated adjustments to keep the measured variable within a set range [13]. (a) Open and Closed Loop

All the elements constituting the measurement and control of a single variable are called a control loop. Control that uses a measured signal, feeds the signal back and compares it to a set point, calculates and sends a return signal to make a correction, is called closed loop control. If the controller does not incorporate feedback to make a correction then it is open loop. An operator monitoring signals from various sensors and manually making corrections either physically, such as turning the handle on a valve, or remotely, such as using a dial on a control panel, is performing open loop control. Timers and sequence controllers using logic, such as those on an elevator, are also open loop [13]. (b) Feedback Control

Feedback control is accomplished with a controller. To function properly, a controller must provide correction in a manner that maintains stability. The theoretical basis of feedback control is control theory, which also covers servomechanisms, which are often part of an automated system. Maintaining stability is a principal objective of control theory. Stability means that the system should not oscillate excessively around the set point or get into a situation where it shuts down or runs away. As an example of feedback control, consider a steam coil air heater in which a temperature sensor measures the temperature of the heated air, which is the measured variable. This signal is constantly "fed back" to the controller, which compares it to the desired setting (set point). The controller calculates the difference (error), then calculates a correction and sends the correction signal to adjust the air pressure to a diaphragm that moves a positioner on the steam valve, opening or closing it by the calculated amount. The complexities of this are that the quantities involved are all of different physical types; the temperature sensor signal may be electrical or pressure from an enclosed fluid, the controller may employ pneumatic, hydraulic, mechanical or electronic techniques to sense the error and send a signal to adjust the air pressure that moves the valve. The first controllers used analog methods to perform their calculations. Analog methods were also used in solving differential equations of control theory. The electronic analog computer was developed to solve control type problems and

Page 17: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

8

electronic analog controllers were also developed. Analog computers were displaced by digital computers when they became widely available. Common applications of feedback control are control of temperature, pressure, flow, and speed [13]. (c) Sequential Control and Logical Sequence or System State Control

Sequential control may be either to a fixed sequence or to a logical one that will perform different actions depending on various system states. An example of an adjustable but otherwise fixed sequence is a timer on a lawn sprinkler. States refer to the various conditions that can occur in a use or sequence scenario of the system. An example is an elevator, which uses logic based on the system state to perform certain actions in response to its state and operator input. For example, if the operator presses the floor n button, the system will respond depending on whether the elevator is stopped or moving, going up or down, or if the door is open or closed, and other conditions. An early development of sequential control was relay logic, by which electrical relays engage electrical contacts which either start or interrupt power to a device. Relays were first used in telegraph networks before being developed for controlling other devices, such as when starting and stopping industrial-sized electric motors or opening and closing solenoid valves. Using relays for control purposes allowed event-driven control, where actions could be triggered out of sequence, in response to external events. These were more flexible in their response than the rigid single-sequence cam timers. More complicated examples involved maintaining safe sequences for devices such as swing bridge controls, where a lock bolt needed to be disengaged before the bridge could be moved, and the lock bolt could not be released until the safety gates had already been closed. The total number of relays, cam timers and drum sequencers can number into the hundreds or even thousands in some factories. Early programming techniques and languages were needed to make such systems manageable, one of the first being ladder logic, where diagrams of the interconnected relays resembled the rungs of a ladder. Special computers called programmable logic controllers were later designed to replace these collections of hardware with a single, more easily re-programmed unit. In a typical hard wired motor start and stop circuit (called a control circuit) a motor is started by pushing a "Start" or "Run" button that activates a pair of electrical relays. The "lock-in" relay locks in contacts that keep the control circuit energized when the push button is released. The start button is a normally open contact and the stop button is normally closed contact. Another relay energizes a switch that powers the

Page 18: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

9

device that throws the motor starter switch (three sets of contacts for three phase industrial power) in the main power circuit. (Note: Large motors use high voltage and experience high in-rush current, making speed important in making and breaking contact. This can be dangerous for personnel and property with manual switches.) All contacts are held engaged by their respective electromagnets until a "stop" or "off" button is pressed, which de-energizes the lock in relay. See diagram: Motor Starters Hand-Off-Auto with Start-Stop. Commonly interlocks are added to a control circuit. Suppose that the motor in the example is powering machinery that has a critical need for lubrication. In this case an interlock could be added to insure that the oil pump is running before the motor starts. Timers, limit switches and electric eyes are other common elements in control circuits. Solenoid valves are widely used on compressed air or hydraulic fluid for powering actuators on mechanical components. While motors are used to supply continuous rotary motion, actuators are typically a better choice for intermittently creating a limited range of movement for a mechanical component, such as moving various mechanical arms, opening or closing valves, raising heavy press rolls, applying pressure to presses [13]. (d) Computer Control

Computers can perform both sequential control and feedback control, and typically a single computer will do both in an industrial application. Programmable logic controllers (PLCs) are a type of special purpose microprocessor that replaced many hardware components such as timers and drum sequencers used in relay logic type systems. General purpose process control computers have increasingly replaced stand-alone controllers, with a single computer able to perform the operations of hundreds of controllers. Process control computers can process data from a network of PLCs, instruments and controllers in order to implement typical (such as PID) control of many individual variables or in some cases, to implement complex control algorithms using multiple inputs and mathematical manipulations. They can also analyze data and create real time graphical displays for operators and run reports for operators, engineers and management. Control of an Automated Teller Machine (ATM) is an example of an interactive process in which a computer will perform a logic derived response to a user selection based on information retrieved from a networked database. The ATM process has a lot of similarities to other online transaction processes. The different logical responses are called scenarios. Such processes are typically designed with the aid of use cases and flowcharts, which guide the writing of the software code [13].

Page 19: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

10

2.2.2 History of Automation

The earliest feedback control mechanism was used to tent the sails of windmills. It was patented by Edmund Lee in 1745. The centrifugal governor, which dates to the last quarter of the 18th century, was used to adjust the gap between millstones. The centrifugal governor was also used in the automatic flour mill developed by Oliver Evans in 1785, making it the first completely automated industrial process. The governor was adopted by James Watt for use on a steam engine in 1788 after Watt’s partner Boulton saw one at a flour mill Boulton & Watt were building. The governor could not actually hold a set speed; the engine would assume a new constant speed in response to load changes. The governor was able to handle smaller variations such as those caused by fluctuating heat load to the boiler. Also, there was a tendency for oscillation whenever there was a speed change. As a consequence, engines equipped with this governor were not suitable for operations requiring constant speed, such as cotton spinning. Several improvements to the governor, plus improvements to valve cut-off timing on the steam engine, made the engine suitable for most industrial uses before the end of the 19th century. Advances in the steam engine stayed well ahead of science, both thermodynamics and control theory. The governor received relatively little scientific attention until James Clerk Maxwell published a paper that established the beginning of a theoretical basis for understanding control theory. Development of the electronic amplifier during the 1920s, which was important for long distance telephony, required a higher signal to noise ratio, which was solved by negative feedback noise cancellation. This and other telephony applications contributed to control theory. Military applications during the Second World War that contributed to and benefited from control theory were fire-control systems and aircraft controls. The word "automation" itself was coined in the 1940s by General Electric. The so-called classical theoretical treatment of control theory dates to the 1940s and 1950s. Relay logic was introduced with factory electrification, which underwent rapid adaption from 1900 through the 1920s. Central electric power stations were also undergoing rapid growth and operation of new high pressure boilers, steam turbines and electrical substations created a large demand for instruments and controls. Central control rooms became common in the 1920s, but as late as the early 1930s, most process control was on-off. Operators typically monitored charts drawn by recorders that plotted data from instruments. To make corrections, operators manually opened or closed valves or turned switches on or off. Control rooms also used color coded lights to send signals to workers in the plant to manually make certain changes.

Page 20: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

11

Controllers, which were able to make calculated changes in response to deviations from a set point rather than on-off control, began being introduced the 1930s. Controllers allowed manufacturing to continue showing productivity gains to offset the declining influence of factory electrification. In 1959 Texaco’s Port Arthur refinery became the first chemical plant to use digital control. Conversion of factories to digital control began to spread rapidly in the 1970s as the price of computer hardware fell [13]. Significant Applications of Automation System

The automatic telephone switchboard was introduced in 1892 along with dial telephones. By 1929, 31.9% of the Bell system was automatic. Automatic telephone switching originally used vacuum tube amplifiers and electro-mechanical switches, which consumed a large amount of electricity. Call volume eventually grew so fast that it was feared the telephone system would consume all electricity production, prompting Bell Labs to begin research on the transistor. The logic performed by telephone switching relays was the inspiration for the digital computer. The first commercially successful glass bottle blowing machine was an automatic model introduced in 1905. The machine, operated by a two man crew working 12 hour shifts, could produce 17,280 bottles in 24 hours, compared to 2,880 bottles made by a crew of six men and boys working in a shop for a day. The cost of making bottles by machine was 10 to 12 cents per gross compared to $1.80 per gross by the manual glassblowers and helpers. Sectional electric drives were developed using control theory. Sectional electric drives are used on different sections of a machine where a precise differential must be maintained between the sections. In steel rolling, the metal elongates as it passes through pairs of rollers, which must run at successively faster speeds. In paper making the paper sheet shrinks as it passes around steam heated drying arranged in groups, which must run at successively slower speeds. The first application of a sectional electric drive was on a paper machine in 1919. One of the most important developments in the steel industry during the 20th century was continuous wide strip rolling, developed by Armco in 1928. Before automation many chemicals were made in batches. In 1930, with the widespread use of instruments and the emerging use of controllers, the founder of Dow Chemical Co. was advocating continuous production. Self-acting machine tools that displaced hand dexterity so they could be operated by boys and unskilled laborers were developed by James Nasmyth in the 1840s. Machine

Page 21: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

12

tools were automated with Numerical control (NC) using punched paper tape in the 1950s. This soon evolved into computerized numerical control (CNC). Today extensive automation is practiced in practically every type of manufacturing and assembly process. Some of the larger processes include electrical power generation, oil refining, chemicals, steel mills, plastics, cement plants, fertilizer plants, pulp and paper mills, automobile and truck assembly, aircraft production, glass manufacturing, natural gas separation plants, food and beverage processing, canning and bottling and manufacture of various kinds of parts. Robots are especially useful in hazardous applications like automobile spray painting. Robots are also used to assemble electronic circuit boards. Automotive welding is done with robots and automatic welders are used in applications like pipelines [13]. 2.2.3 Advantages and Disadvantages

The main advantages of automation are:

i. Increased throughput or productivity. ii. Improved quality or increased predictability of quality.

iii. Improved robustness (consistency), of processes or product. iv. Increased consistency of output. v. Reduced direct human labor costs and expenses.

vi. The following methods are often employed to improve productivity, quality, or robustness.

vii. Install automation in operations to reduce cycle time. viii. Install automation where a high degree of accuracy is required.

ix. Replacing human operators in tasks that involve hard physical or monotonous work.

x. Replacing humans in tasks done in dangerous environments (i.e. fire, space, volcanoes, nuclear facilities, underwater, etc.)

xi. Performing tasks that are beyond human capabilities of size, weight, speed, endurance, etc.

xii. Economic improvement: Automation may improve in economy of enterprises, society or most of humanity. For example, when an enterprise invests in automation, technology recovers its investment; or when a state or country increases its income due to automation like Germany or Japan in the 20th Century.

xiii. Reduces operation time and work handling time significantly. xiv. Frees up workers to take on other roles. xv. Provides higher level jobs in the development, deployment, maintenance and

running of the automated processes [13].

Page 22: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

13

The main disadvantages of automation are:

i. Causing unemployment and poverty by replacing human labor. ii. Security Threats/Vulnerability: An automated system may have a limited level

of intelligence, and is therefore more susceptible to committing errors outside of its immediate scope of knowledge (e.g., it is typically unable to apply the rules of simple logic to general propositions).

iii. Unpredictable/excessive development costs: The research and development cost of automating a process may exceed the cost saved by the automation itself.

iv. High initial cost: The automation of a new product or plant typically requires a very large initial investment in comparison with the unit cost of the product, although the cost of automation may be spread among many products and over time.

v. In manufacturing, the purpose of automation has shifted to issues broader than productivity, cost, and time [13].

2.2.4 Limitations to Automation

i. Current technology is unable to automate all the desired tasks. ii. Many operations using automation have large amounts of invested capital and

produce high volumes of product, making malfunctions extremely costly and potentially hazardous. Therefore, some personnel are needed to insure that the entire system functions properly and that safety and product quality are maintained.

iii. As a process becomes increasingly automated, there is less and less labor to be saved or quality improvement to be gained. This is an example of both diminishing returns and the logistic function.

iv. As more and more processes become automated, there are fewer remaining non-automated processes. This is an example of exhaustion of opportunities. New technological paradigms may however set new limits that surpass the previous limits.

v. Many roles for humans in industrial processes presently lie beyond the scope of automation. Human-level pattern recognition, language comprehension, and language production ability are well beyond the capabilities of modern mechanical and computer systems. Tasks requiring subjective assessment or synthesis of complex sensory data, such as scents and sounds, as well as high-level tasks such as strategic planning, currently require human expertise. In many cases, the use of humans is more cost-effective than mechanical approaches even where automation of industrial tasks is possible. Overcoming these obstacles is a theorized path to post-scarcity economics [13].

Page 23: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

14

2.2.5 Some of the Applications

There are a huge list of applications of automation. Some of them are listed below [13]:

Automated retail Food and drink Automated restaurant Stores Automated mining Automated video surveillance Automated highway systems Automated waste management Home automation Industrial automation

This project deals with a simple home automation system. 2.3 Home Automation

Home automation (also called domotics) designates an emerging practice of increased automation of household appliances and features in residential dwellings, particularly through electronic means that allow for things impracticable, overly expensive or simply not possible in recent past decades. Home automation is the residential extension of building automation. It is automation of the home, housework or household activity. Home automation may include centralized control of lighting, HVAC (heating, ventilation and air conditioning), appliances, security locks of gates and doors and other systems, to provide improved convenience, comfort, energy efficiency and security. Home automation for the elderly and disabled can provide increased quality of life for persons who might otherwise require caregivers or institutional care. The popularity of home automation has been increasing greatly in recent years due to much higher affordability and simplicity through smartphone and tablet connectivity. The concept of the "Internet of Things" has tied in closely with the popularization of home automation. A home automation system integrates electrical devices in a house with each other. The techniques employed in home automation include those in building automation as well as the control of domestic activities, such as home entertainment systems, houseplant and yard watering, pet feeding, changing the ambiance "scenes" for different events (such as dinners or parties), and the use of domestic robots. Devices may be connected through a home network to allow control by a personal computer,

Page 24: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

15

and may allow remote access from the internet. Through the integration of information technologies with the home environment, systems and appliances are able to communicate in an integrated manner which results in convenience, energy efficiency, and safety benefits. Automated "homes of the future" have been staple exhibits for World's Fairs and popular backgrounds in science fiction. However, problems with complexity, competition between vendors, multiple incompatible standards, and the resulting expense have limited the penetration of home automation to homes of the wealthy, or ambitious hobbyists. Possibly the first "home computer" was an experimental home automation system in 1966 [14]. 2.3.1 Overview and Benefits of Home Automation System

Home automation refers to the use of computer and information technology to control home appliances and features (such as windows or lighting). Systems can range from simple remote control of lighting through to complex computer/micro-controller based networks with varying degrees of intelligence and automation. Home automation is adopted for reasons of ease, security and energy efficiency. In modern construction in industrialized nations, most homes have been wired for electrical power, telephones, TV outlets (cable or antenna), and a doorbell. Many household tasks were automated by the development of specialized automated appliances. For instance, automatic washing machines were developed to reduce the manual labor of cleaning clothes, and water heaters reduced the labor necessary for bathing. The use of gaseous or liquid fuels, and later the use of electricity enabled increased automation in heating, reducing the labor necessary to manually refuel heaters and stoves. Development of thermostats allowed more automated control of heating, and later cooling. As the number of controllable devices in the home rises, interconnection and communication becomes a useful and desirable feature. For example, a furnace can send an alert message when it needs cleaning, or a refrigerator when it needs service. If no one is supposed to be home and the alarm system is set, the home automation system could call the owner, or the neighbors, or an emergency number if an intruder is detected. In simple installations, automation may be as straightforward as turning on the lights when a person enters the room. In advanced installations, rooms can sense not only the presence of a person inside but know who that person is and perhaps set appropriate lighting, temperature, music levels or television channels, taking into account the day of the week, the time of day, and other factors.

Page 25: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

16

Other automated tasks may include reduced setting of the heating or air conditioning when the house is unoccupied, and restoring the normal setting when an occupant is about to return. More sophisticated systems can maintain an inventory of products, recording their usage through bar codes, or an RFID tag, and prepare a shopping list or even automatically order replacements. Home automation can also provide a remote interface to home appliances or the automation system itself, to provide control and monitoring on a smartphone or web browser. An example of remote monitoring in home automation could be triggered when a smoke detector detects a fire or smoke condition, causing all lights in the house to blink to alert any occupants of the house to the possible emergency. If the house is equipped with a home theater, a home automation system can shut down all audio and video components to avoid distractions, or make an audible announcement. The system could also call the home owner on their mobile phone to alert them, or call the fire department or alarm monitoring company [14]. 2.3.2 History of Home Automation

Home automation has been a feature of science fiction writing for many years, but has only become practical since the early 20th Century following the widespread introduction of electricity into the home, and the rapid advancement of information technology. Early remote control devices began to emerge in the late 1800s. For example, Nikola Tesla patented an idea for the remote control of vessels and vehicles in 1898. The emergence of electrical home appliances began between 1915 and 1920; the decline in domestic servants meant that households needed cheap, mechanical replacements. Domestic electricity supply, however, was still in its infancy — meaning this luxury was afforded only the more affluent households. Ideas similar to modern home automation systems originated during the World's Fairs of the 1930s. Fairs in Chicago (1934), New York (1939) and (1964–65) depicted electrified and automated homes. In 1966 Jim Sutherland, an engineer working for Westinghouse Electric, developed a home automation system called "ECHO IV"; this was a private project and never commercialized. The first "wired homes" were built by American hobbyists during the 1960s, but were limited by the technology of the times. The term "smart house" was first coined by the American Association of House-builders in 1984. With the invention of the microcontroller, the cost of electronic control fell rapidly. Remote and intelligent control technologies were adopted by the building services industry and appliance manufacturers.

Page 26: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

17

By the end of the 1990s, "domotics" was commonly used to describe any system in which informatics and telematics were combined to support activities in the home. The phrase is a neologism formed from domus (Latin, meaning house) and informatics, and refers to the application of computer and robot technologies to domestic appliances. The concept "Domotique" was initially introduced in France in the 1980s and was during the 1990`s introduced in Spain and Italy as "Domótica", and refers to home automation. Despite interest in home automation, by the end of the 1990s there was not a widespread uptake, with such systems still considered the domain of hobbyists or the rich. The lack of a single, simplified, protocol and high cost of entry has put off consumers. While there is still much room for growth, according to ABI Research, 1.5 million home automation systems were installed in the US in 2012, and a sharp uptake could see shipments topping over 8 million in 2017 [14]. 2.3.3 System Elements

Elements of a home automation system include; sensors (such as temperature, daylight, or motion detection); controllers (such as a general-purpose personal computer or a dedicated automation controller); actuators, (such as motorized valves, light switches and motors); buses (wired or wireless); and interfaces (human-machine and / or machine-to-machine). One or more human-machine and/or machine-to-machine, interface devices are required, so that the residents of the home can interact with the system for monitoring and control; this may be a specialized terminal or, increasingly, may be an application running on a smart phone or tablet computer. Devices may communicate over dedicated wiring, or over a wired network, or wirelessly using one or more protocols. Building automation networks developed for institutional or commercial buildings may be adapted to control in individual residences. A centralized controller can be used, or multiple intelligent devices can be distributed around the home. There have been many attempts to standardize the forms of hardware, electronic and communication interfaces needed to construct a home automation system. Some standards use additional communication and control wiring, some embed signals in the existing power circuit of the house, some use radio frequency (RF) signals, some can be installed wirelessly and some use a combination of several methods. The Helix, by Resolution Products, is the first fully wireless system that can be installed anywhere in the home, and is sold by professional dealers. Control wiring is hardest to retrofit into an existing house. Some appliances include a USB port that is used for control and connection to a domotics network [14].

Page 27: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

18

2.4 Purpose of this Project

In this project, a very simple work has been chosen to accomplish. A device have to be prepared which will sense the presence of human beings by using the PIR sensor. If there is any human is present in a room in which the device is situated, then the device will turn on the light or energy bulb in that room. If there is no one in the room, then it will turn off the light automatically. To accomplish this, firstly the circuit was designed, i.e. hardware was designed using Proteus software. Then the program code was being formed using MPLab firstly and later with Arduino. Then it the hardware was implemented on the PCB and the code was downloaded into the microcontroller of the Arduino board. The detailed methodology is given the next chapter which includes the component description also. 2.5 Microcontroller

A microcontroller (sometimes abbreviated µC, uC or MCU) is a small computer on a single integrated circuit containing a processor core, memory, and programmable input/output peripherals. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for embedded applications, in contrast to the microprocessors used in personal computers or other general purpose applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, implantable medical devices, remote controls, office machines, appliances, power tools, toys and other embedded systems. By reducing the size and cost compared to a design that uses a separate microprocessor, memory, and input/output devices, microcontrollers make it economical to digitally control even more devices and processes. Mixed signal microcontrollers are common, integrating analog components needed to control non-digital electronic systems. Some microcontrollers may use four-bit words and operate at clock rate frequencies as low as 4 kHz, for low power consumption (single-digit milliwatts or microwatts). They will generally have the ability to retain functionality while waiting for an event such as a button press or other interrupt; power consumption while sleeping (CPU clock and most peripherals off) may be just nanowatts, making many of them well suited for long lasting battery applications. Other microcontrollers may serve performance-critical roles, where they may need to act more like a digital signal processor (DSP), with higher clock speeds and power consumption [16]. A microcontroller can be considered a self-contained system with a processor, memory and peripherals and can be used as an embedded system.[8] The majority of

Page 28: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

19

microcontrollers in use today are embedded in other machinery, such as automobiles, telephones, appliances, and peripherals for computer systems. While some embedded systems are very sophisticated, many have minimal requirements for memory and program length, with no operating system, and low software complexity. Typical input and output devices include switches, relays, solenoids, LEDs, small or custom LCD displays, radio frequency devices, and sensors for data such as temperature, humidity, light level etc. Embedded systems usually have no keyboard, screen, disks, printers, or other recognizable I/O devices of a personal computer, and may lack human interaction devices of any kind [16]. 2.6 Relay

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly control an electric motor or other loads is called a contactor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protective relays".

Page 29: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

20

Chapter 3

Methodology and Design of the Home

Automation System

Page 30: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

21

3.1 Introduction

In this project there are several components included as each of them have their specific function and task. These components are selected based on circuit reliability, function ability, and costs. At first the methodology is discussed. 3.2 Methodology

The Methodology consists of the following stages:

First the requirements of the project will be carefully analyzed to design the proposed home automation system. Based on it, the specifications of the necessary components of the hardware and software will be finalized.

Next the schematic diagram of the circuit will be designed. Proteus software will be used for this purpose. PIC microcontroller will be used for information processing

Then the firmware will be developed using MPLab software. Then the circuit will be simulated using Proteus software. Then the circuit will be implemented in the breadboard and tested in the

laboratory Then the Printed Circuit Board (PCB) will be designed for the circuit and the

proposed system will be implemented in the PCB. Then the designed system will be tested in the laboratory.

3.3 Block Diagram of the Designed Project

Fig. 3.1: Block diagram of the designed project

Page 31: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

22

3.4 Description of the Components in the Block Diagram

The main components are:

(i) ATMEGA328 Microcontroller (ii) PIR Sensor (iii) Arduino Uno Board (iv) Relay Module whose coils are driven by 5V DC (v) Adapter 5V (vi) Energy Bulb 10W

A short description of each of the components is discussed in this chapter.

3.4.1 Microcontroller

The selected microcontroller is the ATMEGA328 because of its ease of use, built-in timers, I2C communication, and RS232 port, built-in crystal and has many analog and digital inputs and outputs. To avoid extra costs, this model is most basic that meets all of the design criteria. It is also a fairly new model so it should be available for years to come. So the ATMEGA328 was the best choice available. The microcontroller is used to control the whole operation of the system.

Fig. 3.2: Pin assignment of ATMEGA328

Page 32: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

23

3.4.2 General Characteristics of ATMEGA328

3.4.2.1 Power Managed Modes:

• Run: CPU on, peripherals on, Idle: CPU off, peripherals on, Sleep: CPU off, peripherals off • Idle mode currents down to 5.8 µA typical, Sleep mode current down to 0.1 µA typical • Timer1 Oscillator: 1.8 µA, 32 kHz, 2V, Watchdog Timer: 2.1 µA, Two-Speed Oscillator Start-up 3.4.2.2 Peripheral Highlights:

• High-current sink/source 25 mA/25 mA, Three programmable external interrupts, Four input change interrupts, Up to 2 Capture/Compare/PWM (CCP) modules, one with Auto-Shutdown (28-pin devices), Enhanced Capture/Compare/PWM (ECCP), two PWM outputs, Selectable polarity, Programmable dead time, Auto-Shutdown and Auto-Restart, Master Synchronous Serial Port (MSSP) module supporting 3-wire SPI™ (all 4 modes) and I2C™ Master and Slave Modes: • Enhanced Addressable USART module: - Supports RS-485, RS-232 and LIN 1.2 - RS-232 operation using internal oscillator block (no external crystal required) - Auto-Wake-up on Start bit - Auto-Baud Detect • 10-bit, up to 13-channel Analog-to-Digital Converter module (A/D): - Auto-acquisition capability - Conversion available during Sleep • Dual analog comparators with input multiplexing) Flexible Oscillator Structure: • Four Crystal modes, up to 40 MHz • 4X Phase Lock Loop (available for crystal and internal oscillators) • Two External RC modes, up to 4 MHz • Two External Clock modes, up to 40 MHz • Internal oscillator block: - 8 user selectable frequencies, from 31 kHz to 8 MHz - Provides a complete range of clock speeds from 31 kHz to 32 MHz when used with PLL - User tunable to compensate for frequency drift • Secondary oscillator using Timer1 @ 32 kHz

Page 33: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

24

• Fail-Safe Clock Monitor: - Allows for safe shutdown if peripheral clock stops Special Microcontroller Features: • C compiler optimized architecture: - Optional extended instruction set designed to optimize re-entrant code • 100,000 erase/write cycle Enhanced Flash program memory typical • 1,000,000 erase/write cycle Data EEPROM memory typical • Flash/Data EEPROM Retention: 100 years typical • Self-programmable under software control • Priority levels for interrupts • 8 x 8 Single-Cycle Hardware Multiplier • Extended Watchdog Timer (WDT): - Programmable period from 4 ms to 131s • Single-supply 5V In-Circuit Serial Programming™ (ICSP™) via two pins • In-Circuit Debug (ICD) via two pins • Wide operating voltage range: 2.0V to 5.5V • Programmable 16-level High/Low-Voltage Detection (HLVD) module: - Supports interrupt on High/Low-Voltage Detection • Programmable Brown-out Reset (BOR - With software enable option)

Fig. 3.3: ATMEGA328 Microcontroller

Page 34: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

25

3.4.2.3 Features

High-performance, Low-power AVR® 8-bit Microcontroller

Advanced RISC Architecture – 130 Powerful Instructions – Most Single-clock Cycle Execution – 32 x 8 General Purpose Working Registers – Fully Static Operation – Up to 16 MIPS Throughput at 16 MHz – On-chip 2-cycle Multiplier

High Endurance Non-volatile Memory segments – 8K Bytes of In-System Self-programmable Flash program memory – 512 Bytes EEPROM – 1K Byte Internal SRAM – Write/Erase Cycles: 10,000 Flash/100,000 EEPROM – Data retention: 20 years at 85°C/100 years at 25°C – Optional Boot Code Section with Independent Lock Bits

In-System Programming by On-chip Boot Program

True Read-While-Write Operation – Programming Lock for Software Security

Peripheral Features – Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode – One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and

Capture Mode

– Real Time Counter with Separate Oscillator – Three PWM Channels – 8-channel ADC in TQFP and QFN/MLF package

Eight Channels 10-bit Accuracy – 6-channel ADC in PDIP package

Six Channels 10-bit Accuracy – Byte-oriented Two-wire Serial Interface – Programmable Serial USART – Master/Slave SPI Serial Interface – Programmable Watchdog Timer with Separate On-chip Oscillator – On-chip Analog Comparator

Page 35: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

26

Special Microcontroller Features – Power-on Reset and Programmable Brown-out Detection – Internal Calibrated RC Oscillator – External and Internal Interrupt Sources – Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and

Standby

I/O and Packages – 23 Programmable I/O Lines – 28-lead PDIP, 32-lead TQFP, and 32-pad QFN/MLF

Operating Voltages – 2.7 - 5.5V (ATmega8L) – 4.5 - 5.5V (ATmega8)

Speed Grades – 0 - 8 MHz (ATmega8L) – 0 - 16 MHz (ATmega8)

Power Consumption at 4 Mhz, 3V, 25°C – Active: 3.6 mA – Idle Mode: 1.0 mA

Power-down Mode: 0.5 μA

3.4.2.4 Pin Description of ATMEGA328

Port B (PB7.PB0) XTAL1/XTAL2/TOSC1/TOSC2: Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, Even if the clock is not running. Depending on the clock selection fuse settings, PB6 can be used as input to the inverting Oscillator amplifier and input to the internal clock operating circuit. Depending on the clock selection fuse settings, PB7 can be used as output from the inverting Oscillator amplifier If the Internal Calibrated RC Oscillator is used as chip clock source, PB7..6 is used as TOSC2..1input for the Asynchronous Timer/Counter2 if the AS2 bit in ASSR is set. The various special features of Port B are elaborated in

Page 36: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

27

Port C (PC5.PC0): Port C is a 7-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is, XC not running

PC6/RESET: If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C.If the RSTDISBL Fuse is un programmed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running. The minimum pulse length is given in Shorter pulses are not guaranteed to generate a Reset. Port D (PD7.PD0): Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. The Port D pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port D also serves the functions of various special features of the ATmega8. RESET: Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. The minimum pulse length is given i Shorter pulses are not guaranteed to generate a reset. AVCC: AVCC is the supply voltage pin for the A/D Converter, Port C (3.0), and ADC (7.6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port C (5.4) use digital supply voltage, VCC. AREF: AREF is the analog reference pin for the A/D Converter.

ADC7.6 (TQFP and QFN/MLF Package Only): In the TQFP and QFN/MLF package, ADC7..6 serve as analog inputs to the A/D converter. These pins are powered from the analog supply and serve as 10-bit ADC channels.

3.4.2.5 Overview of ATMEGA328

The ATMEGA328 is a low-power CMOS 8-bit microcontroller based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8 achieves throughputs approaching 1 MIPS per MHz, allowing the system designed to optimize power consumption versus processing speed.

Page 37: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

28

The AVR core combines a rich instruction set with 32 general purpose working registers. All the 32 registers are directly connected to the Arithmetic Logic Unit (ALU), allowing two independent registers to be accessed in one single instruction executed in one clock cycle. The resulting architecture is more code efficient while achieving throughputs up to ten times faster than conventional CISC microcontrollers. The ATMEGA328 provides the following features: 8K bytes of In-System Programmable Flash with Read-While-Write capabilities, 512 bytes of EEPROM, 1K byte of SRAM, 23 general purpose I/O lines, 32 general purpose working registers, three flexible Timer/Counters with compare modes, internal and external interrupts, a serial programmable USART, a byte oriented Two wire Serial Interface, a 6-channel ADC (eight channels in TQFP and QFN/MLF packages). 10-bit accuracy, a programmable Watchdog Timer with Internal Oscillator, an SPI serial port, and five software selectable power saving modes. The Idle mode stops the CPU while allowing the SRAM, Timer/Counters, SPI port, and interrupt system to continue functioning. The Power down mode saves the register contents but freezes the Oscillator, disabling all other chip functions until the next Interrupt or Hardware Reset. In Power-save mode, the asynchronous timer continues to run, allowing the user to maintain a timer base while the rest of the device is sleeping. The ADC Noise Reduction mode stops the CPU and all I/O modules except asynchronous timer and ADC, to minimize switching noise during ADC conversions. In Standby mode, the crystal/resonator Oscillator is running while the rest of the device is sleeping. This allows very fast start-up combined with low-power consumption. The device is manufactured using Atmel’s high density non-volatile memory technology. The Flash Program memory can be reprogrammed In-System through an SPI serial interface, by a conventional non-volatile memory programmer, or by an On-chip boot program running on the AVR core. The boot program can use any interface to download the application program. Application Flash memory. Software in the Boot Flash Section will continue to run while the Application Flash Section is updated, providing true Read-While-Write operation. By combining an 8-bit RISC CPU with In-System Self-Programmable Flash on a monolithic chip, the ATmega8 is a powerful microcontroller that provides a highly-flexible and cost-effective solution to many embedded control applications. The ATMEGA328 is supported with a full suite of program and system development tools, including C compilers, macro assemblers, program debugger/simulators, In-Circuit Emulators, and evaluation kits. Reliability Qualification results show that the projected data retention failure rate is much less than 1 PPM over 20 years at 85°C or 100 years at 25°C.

Page 38: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

29

3.4.3 The Arduino Board

Arduino board is chosen for this project work as it gives so many facilities. Such as— 1. It is a complete board with PCB and gives very accurate result. 2. It is very easy to implement any project. 3. It is very cost effective with compared to the ordered-given and prepared

PCB, so on.

The Arduino UNO board used in this project is given below:

Fig 3.4: The Arduino UNO Board

Page 39: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

30

3.4.4 Functional structure of ATMEGA328

The functional structure of ATMEGA328P is shown below:

Fig. 3.5: ATMEGA328 functional Diagram

Page 40: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

31

3.4.5 PIR (Passive InfraRed) Sensor

The PIR Sensor used in this project is given below:

Fig 3.6: The PIR Sensor

A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from objects in its field of view. They are most often used in PIR-based motion detectors. All objects with a temperature above absolute zero emit heat energy in the form of radiation. Usually this radiation is invisible to the human eye because it radiates at infrared wavelengths, but it can be detected by electronic devices designed for such a purpose. The term passive in this instance refers to the fact that PIR devices do not generate or radiate any energy for detection purposes. They work entirely by detecting the energy given off by other objects. It is important to note that PIR sensors don't detect or measure "heat" per se; instead they detect the Infrared radiation emitted from an object which is different from but often associated/correlated with the object's temperature (e.g., a detector of X-rays or gamma rays would not be considered a heat detector, though high temperatures may cause the emission of X or gamma radiation).

A PIR-based motion detector is used to sense movement of people, animals, or other objects. They are commonly used in burglar alarms and automatically-activated lighting systems. They are commonly called simply "PIR" or sometimes "PID", for "passive infrared detector". [15] 3.4.5.1 Operation of PIR Sensor

An individual PIR sensor detects changes in the amount of infrared radiation impinging upon it, which varies depending on the temperature and surface characteristics of the objects in front of the sensor. When an object, such as a human, passes in front of the background, such as a wall, the temperature at that point in the sensor's field of view will rise from room temperature to body temperature, and then

Page 41: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

32

back again. The sensor converts the resulting change in the incoming infrared radiation into a change in the output voltage, and this triggers the detection. Moving objects of similar temperature to the background but different surface characteristics may also have a different infrared emission pattern, and thus sometimes trigger the detector. PIRs come in many configurations for a wide variety of applications. The most common models have numerous Fresnel lenses or mirror segments, an effective range of about ten meters (thirty feet), and a field of view less than 180 degrees. Models with wider fields of view, including 360 degrees, are available — typically designed to mount on a ceiling. Some larger PIRs are made with single segment mirrors and can sense changes in infrared energy over one hundred feet away from the PIR. There are also PIRs designed with reversible orientation mirrors which allow either broad coverage (110° wide) or very narrow "curtain" coverage, or with individually selectable segments to "shape" the coverage. [15] 3.4.6 Relay

A relay is an electrically operated switch. Many relays use an electromagnet to mechanically operate a switch, but other operating principles are also used, such as solid-state relays. Relays are used where it is necessary to control a circuit by a low-power signal (with complete electrical isolation between control and controlled circuits), or where several circuits must be controlled by one signal. The first relays were used in long distance telegraph circuits as amplifiers: they repeated the signal coming in from one circuit and re-transmitted it on another circuit. Relays were used extensively in telephone exchanges and early computers to perform logical operations. A type of relay that can handle the high power required to directly control an electric motor or other loads is called a contactor. Solid-state relays control power circuits with no moving parts, instead using a semiconductor device to perform switching. Relays with calibrated operating characteristics and sometimes multiple operating coils are used to protect electrical circuits from overload or faults; in modern electric power systems these functions are performed by digital instruments still called "protective relays". 3.4.6.1 Basic function of Relay

A simple electromagnetic relay consists of a coil of wire wrapped around a soft iron core, an iron yoke which provides a low reluctance path for magnetic flux, a movable iron armature, and one or more sets of contacts (there are two in the relay pictured). The armature is hinged to the yoke and mechanically linked to one or more sets of moving contacts. It is held in place by a spring so that when the relay is de-energized there is an air gap in the magnetic circuit. In this condition, one of the two sets of contacts in the relay pictured is closed, and the other set is open. Other relays may

Page 42: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

33

have more or fewer sets of contacts depending on their function. The relay in the picture also has a wire connecting the armature to the yoke. This ensures continuity of the circuit between the moving contacts on the armature, and the circuit track on the printed circuit board (PCB) via the yoke, which is soldered to the PCB. When an electric current is passed through the coil it generates a magnetic field that activates the armature and the consequent movement of the movable contact either makes or breaks (depending upon construction) a connection with a fixed contact. If the set of contacts was closed when the relay was de-energized, then the movement opens the contacts and breaks the connection, and vice versa if the contacts were open. When the current to the coil is switched off, the armature is returned by a force, approximately half as strong as the magnetic force, to its relaxed position. Usually this force is provided by a spring, but gravity is also used commonly in industrial motor starters. Most relays are manufactured to operate quickly. In a low-voltage application this reduces noise; in a high voltage or current application it reduces arcing. When the coil is energized with direct current, a diode is often placed across the coil to dissipate the energy from the collapsing magnetic field at deactivation, which would otherwise generate a voltage spike dangerous to semiconductor circuit components. If the coil is designed to be energized with alternating current (AC), a small copper "shading ring" can be crimped to the end of the solenoid, creating a small out-of-phase current which increases the minimum pull on the armature during the AC cycle. 3.4.6.2 Relay Module

The relay module used in this project is given below:

Fig 3.7: Relay Module

Page 43: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

34

3.5 Flowchart of the Designed Project

The flowchart of the designed home automation system is given below:

Fig 3.8: Flowchart of the designed project 3.6 Working Principle

This device's working principle is very simple. After turning on the device, there is a calibration time of 30 seconds is given for the sensor to be ready. Then PIR sensor is ready to sense the presence of human beings. If there is any human present or any kind of motions in a room in which the device is situated, then it gives a signal to the microcontroller and according to that signal, microcontroller will give an output signal to the relay module. This relay module then switches the light or energy bulb to be turned on in that room. If there is no one in the room, then it will turn off the light automatically. There is a 3 seconds on-time delay given in the code so that if there is any motion then the light will lit for 3 seconds. This time can be changed according to the need. 3.7 Algorithm of the Designed Project

The algorithm of the designed home automation system is given below: 1. Turn on the device 2. Set Calibration time = 30 sec

Page 44: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

35

3. Sense the presence of human motion using PIR sensor 4. If there is any motion then switch on the Relay for 3 sec and go back to Step 3 5. If there is no motion then switch off the Relay and go back to Step 3 6. Continue this work till there is power available.

3.8 Pseudo-code of the Designed Project

The pseudo-code of the designed home automation system is given below: Calibration time = 30 sec Loop: Input PIR If PIR = 1 Display Humans there Relay = 1 (Relay is ON) Light = 1 (Light is ON) Delay = 3 sec GOTO Loop If PIR = 0 Display No Humans Relay = 0 (Relay is OFF) Light = 0 (Light is OFF) GOTO Loop Goto Loop 3.9 Circuit Diagram of the Designed Project

Fig. 3.9: Circuit diagram of the designed project

Page 45: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

36

3.10 Design Steps

In this paragraph, how this project was designed is mentioned in the steps:

1. At first, the circuit was chosen by finding it from the internet from many sources.

2. Then it was implemented in the Proteus software to check the simulation process.

3. Then the firmware was written. 4. When it was okay in the simulation step, the list of components are being

prepared. 5. Then those were brought from the local market. 6. After that the program code was downloaded in the microcontroller. 7. Then circuit connection was given and checked thoroughly. 8. When it works properly, the whole circuit was implemented on a sheet-like

board. These are the few steps for the design of this project.

Page 46: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

37

Chapter 4

Results and Discussions

Page 47: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

38

4.1 Introduction

In this chapter, the detail of the results found of this project has been described including the discussions, working principle, advantages, disadvantages, and applications. 4.2 Program Code

int ledPin = 4; // choose the pin for the LED int inputPin = 2; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); } void loop() { val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON delay(150); } else { digitalWrite(ledPin, LOW); // turn LED OFF delay(1000); } } // the whole program is not mentioned here for clarity

Page 48: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

39

4.3 Pictorial View of the Designed Project

The following picture shows the different parts of the designed project in the pictorial view format.

Fig. 4.1: Pictorial view of the designed project (when there is no human presence) The Fig. 4.1 shows that the circuit board is connected with power supply and it is working or on. It shows that there is no motion has been detected thus the light is being turned off. But when there is a human motion is detected as in the Fig. 4.2, the light is being turned on automatically. And when again there is no human motion, the light will be turned off as like the Fig. 4.1.

Fig. 4.2: Pictorial view of the designed project (when there is human presence)

Page 49: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

40

4.4 List of Components with Price

Sl.

No. Name of the Component Quantity

Unit

Price

Price

(BDT)

1 Power Supply (5 V DC Adapter) 1 150 150 2 Arduino Board 1 900 900 3 PIR Sensor 1 300 300 4 Relay Module 1 450 450 5 Connecting Wires and others ̶ 100 100

Total = One thousand nine hundred taka only 1,900/= 4.5 Results and Discussions

This device works very efficiently. It gives very quick response. In this section, how this device is designed and what difficulties were being faced will be discussed. As described in 3.11 section in which the design steps are given, the circuit was designed using Proteus software. The firmware was written with the Arduino’s IDE. Then after that the firmware was downloaded in the microcontroller of Arduino board and then the circuit connection was done. Then the circuit was being checked in various areas such as in the bedroom, office room etc. and it gives very high efficiency. Though at first the circuit didn’t work as it is desired due to some faulty components and wrong connections, but finally it works. And after that it was placed on a hard-board so that it can be portable. This circuit was designed using Arduino board with ATMEGA328 microcontroller, PIR Sensor and relay module. All of these are very cost effective and gives very good response. Also it is very easy to implement the whole device in a portable format. 4.6 Advantages of the Designed Project

The advantages are mentioned below:

High efficiency Cost effective Small in size thus portable Low power consumption Reliable High sensitivity or quick responsiveness Very easy to implement

Page 50: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

41

4.7 Disadvantages of the Designed Project

The disadvantages are mentioned below:

It takes 30 seconds to be ready. The motions have to be continuously in order to keep turning on the lights or

electrical devices. 4.8 Applications

This device can be used in the following places after changing the code (if required) –

Lifts Gates Offices Home Secured places to observe motion Industries

And in many more places.

Page 51: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

42

Chapter 5

Conclusion

Page 52: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

43

5.1 Conclusion

At first, the device was designed with PIC microcontroller and opto-coupler. The firmware was written in MPLab and the simulation was done with Proteus. Though the simulation of the circuit was perfectly fine, the implemented one could not deliver such good performance. So the design of the circuit and also different modules of the design were changed to improve the performance. But still the performance could not be improved. Sometimes it gave correct response while sometimes it did not. Hence, the response was not stable. Afterwards to solve the problem a different approach was taken. The circuit was redesigned with an Arduino board with Atmel microprocessor, a relay instead of opto-coupler and new PIR sensor. The performance of the new setup increased drastically. As Arduino is an open-source platform, the implementation is easy and cheap and related help is available in the internet (http://arduino.cc/). After some further analysis of previous failure it revealed that it was due to faulty components such as PIR sensor and opto-coupler. Finally, it can be concluded that this device is very low cost compared to the devices available in the market. It has been designed very carefully and after observing its working procedure, it can said that it is very efficient and reliable device. It gives very high sensitivity by which the light is turned on immediately. It can be used in many places such as lifts in the buildings to save the power. That means whenever anyone enters the lift, the light and fan installed in the lift will be turned on automatically. And when he leaves the lift, light and fan will be turned off. 5.2 Future Works

1. To implement this device in the lifts of ECE building of BUET so as to save the power after changing the program code.

2. To implement it in the places where security is concerned using the alarm devices.

3. To implement it using mobile app to control the device wirelessly.

Page 53: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

44

References

[1] Kaur, I., ‘Microcontroller Based Home Automation System With Security’, International Journal of Advanced Computer Science and Applications (IJACSA), Vol. 1, no. 6, pp. 60-65, December 2010. [2] Javale, D., Mohsin, M., Nandanwar, S, Shingate, M., ‘Home Automation and Security System Using Android ADK’, International Journal of Electronics Communication and Computer Technology (IJECCT), Vol. 3, Issue 2, pp. 382-385, March 2013. [3] Kamarudin, M. R., Aiman, M. F, Yusof, M., ‘Low Cost Smart Home Automation via Microsoft Speech Recognition’, International Journal of Engineering & Computer Science (IJECS-IJENS), Vol. 13, No 03, pp. 6-11, June 2013. [4] Panth, S, Jivani, M., ‘Home Automation System (HAS) using Android Mobile Phone’, International Journal of Electronics and Computer Science Engineering (IJECSE), Vol. 3, No. 1, pp. 1-10, June 2013. [5] Ramlee, R. A., Leong, M. H., Singh, R. S. S., Ismail, M. M., Othman, M. A., Sulaiman, H., A., Misran, M. H., Said, M. A. M., ‘Bluetooth Remote Home Automation System Using Android Application’, The International Journal of Engineering And Science (IJES), Vol. 2, Issue 01, Pages 149-153, 2013. [6] Šenk, I., Tarjan, L., Ostojić, G., Stankovski, S., ‘Infrared Transceiver for Home Automation’, Electronics, Faculty of Electrical Engineering, University of Banja Luka, Bosnia and Herzegovina, Vol. 14, no. 02, Pages 82-85, December 2010. [7] Sriskanthan, N, Karand, T., “Bluetooth Based Home Automation System”. Journal of Microprocessors and Microsystems, Vol. 26, pp.281-289, 2002. [8] Ramli, M. I., Wahab, M. H. A., Nabihah, A., “TOWARDS SMART HOME: CONTROL ELECTRICAL DEVICES ONLINE”, Nornabihah Ahmad International Conference on Science and Technology: Application in Industry and Education (2006). [9] Ali, A., Rousan, M. A., “Java-Based Home Automation System R.” IEEE Transactions on Consumer Electronics, Vol. 50, No. 2, MAY 2004. [10] Pradeep, G, Chandra, B. S., Venkateswarao, M., “Ad-Hoc Low Powered 802.15.1 Protocol Based Automation System for Residence using Mobile Devices”, Dept. of ECE, K L University, Vijayawada, Andhra Pradesh, India IJCST, Vo l. 2, SP 1, December 2011.

Page 54: DEVELOPMENT OF A LOW COST HOME AUTOMATION SYSTEM …

45

[11] Yavuz, E., Hasan, B., Serkan, I, Duygu, K., “Safe and Secure PIC Based Remote Control Application for Intelligent Home”. International Journal of Computer Science and Network Security, Vol. 7, No. 5, May 2007. [12] Jadhav, A., Anand, S., Dhangare, N., Wagh, K. S., “Universal Mobile Application Development (UMAD) On Home Automation” Marathwada Mitra Mandal’s Institute of Technology, University of Pune, India Network and Complex Systems ISSN 2224-610X (Paper) ISSN 2225-0603 (Online) Vol 2, No.2, 2012. [13] http://en.wikipedia.org/wiki/Automation [14] http://en.wikipedia.org/wiki/Home_automation [15] http://en.wikipedia.org/wiki/Passive_infrared_sensor [16] https://en.wikipedia.org/wiki/Microcontroller