message based home automation & security system

109
MESSAGE BASED HOME AUTOMATION AND SECURITY SYSTEM By Hassan Mahmood Polash S.M. Istiaque Sekander Md. Jahid Hassan Srijohn Kumar Roy Department of Electrical & Electronics Engineering 12

Upload: jhp360

Post on 29-Sep-2015

16 views

Category:

Documents


3 download

DESCRIPTION

final year project report

TRANSCRIPT

MESSAGE BASED HOME AUTOMATION AND SECURITY SYSTEMBy

Hassan Mahmood Polash

S.M. Istiaque Sekander

Md. Jahid Hassan

Srijohn Kumar Roy

Department of Electrical & Electronics Engineering

UNIVERSITY OF INFORMATION TECHNOLOGY & SCIENCES

MESSAGE BASED HOME AUTOMATION AND SECURITY SYSTEM

This Project report is submitted to the Department of Electrical and Electronic Engineering, University of Information Technology and Sciences (UITS), in partial fulfillment of the requirement for the degree of Bachelor of Science in Electrical and Electronic Engineering (EEE). A PROJECT REPORT

SUBMITTED BYHassan Mahmood Polash

S.M. Istiaque Sekander

ID: 09530173

ID: 09530176

Md. Jahid Hassan

Srijohn Kumar Roy

ID: 09530177

ID: 10330305

SUPERVISED BY

DEEPAK KUMAR CHOWDHURY

ASSISTANT PROFESSOR

Department of EEE, UITS

Department of Electrical & Electronics Engineering

UNIVERSITY OF INFORMATION TECHNOLOGY & SCIENCESMESSAGE BASE HOME AUTOMATION AND SECURITY SYSTEM

A Project Report Submitted

By

Hassan Mahmood Polash

S.M. Istiaque Sekander

Md. Jahid HassanSrijohn Kumar Roy

For the partial fulfillment of degree of

B.Sc in Electrical and Electronics Engineering

Examination held in December , 2014.

Approved By____________________________Deepak Kumar ChowdhurySupervisor,

Assistant Professor, Depart of EEE________________________

External/Second Examiner

ACKNOWLEDGEMENT

At first we are grateful to the almighty God owner of the supreme power and universe for giving us the energy and ability to complete our Project work successfully. For this project, we would like to express cordial and endless gratitude from the string of our heart to our project supervisor Deepak Kumar Chowdhury, Assistant Professor, Department of Electrical & Electronic Engineering, University of Information Technology & Sciences (UITS) whose important, brave and aspiratory directions, suggestions, cooperation and cordial behavior makes us possible to finish our Project work fruitfully. Without his guidance it was almost impossible to carry out with the project work. He had been very helpful and ever affectionate to endure this mistakes we had committed in the project and always encouraged us by correcting our wrong proceedings. We would also like to express our gratefulness to all the teachers of the EEE department for helping us several times. We would like to give special thanks to our friends and finally we want to express our deep gratitude to our beloved parents who are the source of inspiration and happiness in our everyday life.Finally, we would like to thank our respective families for their constant encouragement and support. Authors

Hassan Mahmood Polash

S.M. Istiaque SekanderMd. Jahid HassanSrijohn Kumar RoyCHAPTER 1INTRODUCTION

1.1INTRODUCTION

Home Automation & Security System is the residential extension of building automation. Home automation system 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. [1] A home automation system may include simple automated door opener to complete automation of home appliances. Usual home automation feature may include ambient light intensity control, temperature and humidity monitor and control system etc. Home automation helps people to get things done conveniently. For example, it helps to turn on the microwave oven from the office laptop, remotely start vacuuming, etc. Home automation system can be extended to home security monitoring system. A home security system may include intruder alarm system to CCTV monitoring facilities. The basic aim of Home automation is to control or monitor signals from different appliances.Home automation is a growing trend. Automation systems can control important systems like lighting and temperature controls as well as entertainment systems and even curtains. Though costly, control systems can ease the lifestyle of a homeowner greatly. Depending upon which sort of control system is purchased, the ease of the customers life can be exponentially increased. Especially with central control systems, users can change the temperature and lighting in their house with a flick of the finger. No longer is it necessary to worry about leaving the heat running or burning out light bulbs that were mistakenly left on.

In this thesis we have presented simplicity in design, a standard compatible platform of home automation & security system. Our designed system includes a GSM modem and a microcontroller based monitoring and control device that allows monitoring from any distance, over GSM network using short message service (SMS). Multiple sensors feed surrounding environment information to the microcontroller like temperature and humidity and also monitors gas leakage or smoke and human presence. And microcontroller sends that information via SMS to a cell phone number by using a GSM modem. Our designed system constantly monitors the temperature and humidity and display on a LCD. If the temperature reaches 50C the microcontroller turns off the main power supply of the house. We have selected 50C, because it is very unusual temperature for human comfort and household temperature considering our geographical position. Hence this lead to one assessment that some, flammable object is on fire in smaller magnitude or some electrical home appliance is about to catch fire. Since most of the modern electrical home appliance generates temperature between 20C to 35C.1.2BACKGROUND

Home automation is adopted for reasons of ease, security and energy efficiency. In modern construction in 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 energy necessary for bathing. If no one is supposed to be home and the alarm system is set, the Home Automation & Security System could call the owner, or the neighbors, or an emergency number if an intruder is detected. [1]In simple installations, automation may be as straightforward as turning on/off 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. 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. The system could also call the home owner on their mobile phone to alert them, or call the fire department or alarm monitoring company.1.3IMPORTANCE OF THE WORK

Home automation systems that are available in market are very expensive. Moreover it also includes high monthly service charge and installation cost. Also this system requires internet connection to operate; hence the user also has to bear internet subscription fees.

As the demand of home automation system increases, so is the complexity of construction and maintenance cost. Our goal for this project to develop a home automation system that is not only simple in construction and low on maintenance cost, but also a standard compatible platform of home automation & security system. To do so, we have used four sensors (temperature sensor, humidity sensor, gas detector and PIR motion sensor) and interfaced with a microcontroller. We have tried to provide access to the user, that information about the sensors instantly from a LCD display as well as through SMS.

1.4OBJECTIVE

Our objective is to construct a cost effective home automation system.

Also to make a system which is easy to operate and low on maintenance cost.

And to make a safety monitoring system that provides security against fire damage and intruder.

And to develop an automation system that can control main power supply of a house.

1.5APPLICATION

There is several application of our project:

This project includes interfacing of temperature and humidity sensors. This concept can be used for manufacturing and processing industries.

It is also represent the use of several security features such as motion sensing ability which can be used for monitoring house, office, restricted area etc. for human trespassing.

It also includes a gas leakage detector which can be used in deep sea drilling rig, oil tanker ships for hazardous gas leakage and combustion gas detection.

This project features usage of GSM modem and SMS; this can be extended over GSM data service, like GPRS, EDGE, 3G internet for monitor and control wide range of modern home appliance over any distance and even lower cost.

1.6BLOCK DIAGRAM:

1.7METHODOLOGY

The purpose of the project is to develop an automation system based on PIC Microcontroller and GSM modem. The sensors are connected to microcontroller. Microcontroller converts the analog input into digital signal and analyzes, then takes actions to accordance. Our projects systematic flow chart and explanation of work are given below:

1.7.1EXTENSIVE LITERATURE REVIEW

In recent years there has been an exponential growth and advancement in computing technology. There has also been use of these technologies even among non-technical users as they are no longer limited to personal computers that occupy fixed desk space. Instead there has been an increasing trend towards global computing that integrates seamlessly into peripheral environment to assist ones day to day life.

Several standards have been proposed each day promising to solve standards issue. Home automation is not different. At very basic level home automation is introduced as early as 19th century with the introduction of water supply and energy distribution system. Science then several solutions was proposed by the industry and academia; but the progress has been relatively slow. Few system aims to solve issues such as ease of access and scalability, such as Microchips X-10. In early 2000s, there has been several academic research were published regarding home automation, such as in University of Utah, Utah, USA Kevin Brown, Don DeLaMare and Brian Faires proposed an land phone based home automation and security system, where a door, window, motion sensors are integrated to a MC9S12C32 microcontroller (which serve as a slave microcontroller to collect and analyze data from sensors) and a thermostat control unit and a land phone is integrated to another MC9S12C32 microcontroller (which serve as a master microcontroller to control and dial a fixed number if required). A MC9S12C32 is a powerful 16-bit microcontroller by Freescale Semiconductor Inc. It has 32KB of program memory and 4KB RAM with 52 general purpose I/O pin, with a 16-channel ADC module. In the project by Kevin Brown, Don DeLaMare and Brian Faires, they used two MC9S12C32 microcontroller, one as master and another as slave, connected to each other over I2C (inter-integrated circuit) communication protocol. The slave microcontroller is integrated with three sensors (door, window and motion) to monitor the internal situation of a house. If any of this sensor triggers then the slave microcontroller sends a signal to the master microcontroller. The master microcontroller is integrated with a keypad and a land phone. If any of the sensor were triggered then the microcontroller wait for 10 seconds for an authorized password entry from the keypad; otherwise it dials 911(emergency number in USA) to call the police.

Our system includes one 8-bit PIC16F877A microcontroller by Microchip Inc. It has 8KB program memory and 368 bytes RAM with 33 general purposes I/O pin. Since land phone are rarely used in modern days hence we replaced land phone with cell phone. Integrating a cell phone to a microcontroller is a complex process and requires an auxiliary circuit, so instead of a cell phone we used a GSM module, which is special type circuit that mimics a cell phone. It can be directly integrated to a microcontroller without the help of an auxiliary circuit. But our systems microcontroller has a limitation of low data bus (8-bit only), program memory and RAM. Hence we had to develop a program that is low on line count compare to Kevin Brown, Don DeLaMare and Brian Faires project. We also have to remove the keypad feature for this reason. Our system incorporates four sensors (i.e. temperature, humidity, and motion and gas sensor). Our systems microcontroller gathers information from the sensors and analyzes them if any one of them is triggered over an alarming level, and then a SMS is send to a predefined cell phone number. And if certain parameter is crossed over danger level then supply from the mains is cut off.Another research was published by Sunny Peter Gomasa under Massey University, Albany, New Zealand, proposing a web service based home automation, where light, smoke and motion sensor are integrated to a single board computer ALIX 3D2 and the computer is connected to a ADSL modem. It also developed a website for the control and monitoring purpose using PHP web development language. An ALIX 3D2 is single board computer by PC Engines Ltd. A single board computer has distinctive advantage over microcontroller. Single board computer usually includes a powerful microprocessor which performance is measured in several hundred MHz; whereas the performance of a microcontroller processor is measured in MIPS (million instructions per second). An ALIX 3D2 single board computer includes AMD Geode LX800 CPU with 500 MHz clock speed and 256 MB RAM. It also includes a LAN port and two USB port. The LAN port can be used with ADSL modem for internet connection. The main purpose of an ALIX 3D2 single board computer is to allow control different load via internet. The load might be connected to one or more microcontroller powered control board. The drawback of ALIX 3D2 is, beside need of internet it also require a dedicated small computer server and its own custom website.

To avoid the complexity of using single board computer we developed our own microcontroller powered controller board. And instead of internet, we have used SMS of monitoring. But since our microcontroller is very low on ability compare to a single board computer, our system operation is only limited to notification of certain parameter via SMS and termination of mains power supply when needed. We also had to remove end-user control feature.

1.6.2 MODEL CONCEPT

During the system design, ease of construction, ease of use and cost effectiveness is given top priority. We intend to develop a home automation and security system that is low on cost for construction as well as minimum operating cost as possible. Our intention is to develop a system that is user friendly and requires no user manual to operate. Thus our system is based on SMS. Because SMS is the most versatile and easy communication method in mobile communication, requires basic handsets that are able to send and receive SMS; and almost anybody can grasp the concept of SMS. To develop a home automation and security system, the system requires auxiliary sensing equipment. So we considered the most common concern of a home owner. According to our findings a home owner mostly concerned about respectively, intruder or trespasser, fire, temperature and humidity of the house. Hence we choose four sensors that are related to these factors and they are PIR based motion sensor, gas detector, temperature and humidity sensor.1.7.3SELECTION PROCESS

At the beginning of the selection process, access to system status via SMS and internet are both thoroughly revised and SMS is selected for the ease of construction and use. At the second phase of the selection process, selection of microcontroller is considered. There are three ranges of microcontroller are available and they are, Base Line, Mid-Range and High-End microcontroller. In our project we needed ADC module (analog-to-digital converter), UART module and general input-output option. But in a Base Line controller all these module are not available. Although High-End controller provides this features but the devices are expensive. On the other hand Mid-Range controller provides all of these modules in reasonable cost. Hence we selected Mid-Range controller (PIC16F877A).In third phase of our selection process, we needed to select those sensors which parameters are used in our daily life. Hence we select four types of sensors and they are: Temperature, Humidity, Gas and Motion sensor. In the final phase of selection of hardware, we had to decide which type of sensor is to be used. There are two types of sensor, analog and digital. Digital sensor provides low percentage of error, but they are expensive and cannot be easily found. Analog sensors require a time consuming calibration and they are error prone. But they are low on cost. Hence we selected analog type sensors for our project.

1.7.4MODEL DEVELOPMENT

After selecting appropriate hardware for the project, we developed a virtual system using Proteus 8.1 EDA (Electronic Design Automation). A Computer-aided design or CAD software helps to remove any type design error before actual hardware are assembled. It also helps a designer to keep track of how much a system draws power. After testing the virtual system we used EAGLE (Easily Applicable Graphical Layout Editor) CAD to design the custom PCB for the project.

1.7.5TESTING

This project is implemented with all the sensors along with LCD display, connected to the microcontroller individually for testing and calibration on a BREADBOARD. The microcontroller is then interfaced with a GSM modem and tested for sending SMS on the same BREADBOARD. Whenever a sensor status was updated, the microcontroller updated the status on the LCD display and if needed sends a status SMS to a predefined number successfully.

1.7.6VARIFICATION

At first we connected all the devices. When power was supplied, a Beep sound from the buzzer ensures that the system is on. We are able to observe the system status on a LCD display where temperature, relative humidity, gas and motion sensor status are shown. We change the temperature and humidity by heating up the sensor and change of status was displayed on the LCD. Again we triggered both smoke and motion sensor separately and a SMS was sent for each sensors status, in a cell phone in our hand.1.7.7IMPLMENTATION

After several testing and verification, the components are soldered on a custom etched PCB. GSM modem is connected with project circuit board with jumper wires.

1.8OUTLINE OF THE THESISThis thesis is organized in such a way that it can be effectively helpful for any other to work with any Message based home automation system. Towards this goal the project has divided in several sections- In Chapter One, we have described the aspect of the project in practical life. Also we tried to describe a short idea about what we are trying to implement.

In Chapter Two, we have described the importance of microcontroller, its architecture, and peripherals.

In Chapter Three, we have described about sensors, working principle of sensors, its types and construction.

In Chapter Four, we have described about the basic network structure of GSM network and SMS.

In Chapter Five, we have described about the AT command, for interfacing a GSM module with microcontroller.

In Chapter Six, we tried to make an overall familiarization of all the hardware and software to incorporate to implement these projects.

In Chapter Seven, we have described the algorithm, designing procedure and implementation of the project.

In Chapter Eight, we have described the future aspect of the project, its application and overall conclusion.

In Appendix A, we provided the source code of the project.

CHAPTER 2

INTRODUCTION TO MICROCONTROLLER2.1INTRODUCTION

The term microcomputer is used to describe a system that includes at minimum a microprocessor, program memory, data memory, and an input-output (I/O) device. Some microcomputer systems include additional components such as timers, counters, and analog-to-digital converters. Thus, a microcomputer system can be anything from a large computer having hard disks, floppy disks, and printers to a single-chip embedded controller.

Here we are going to consider only the type of microcomputers that consist of a single silicon chip. Such microcomputer systems are also called microcontrollers, and they are used in many household goods such as microwave ovens, TV remote control units, cookers, hi-fi equipment, CD players, personal computers, and refrigerators. Many different microcontrollers are available on the market. Here we shall be looking at programming and system design for the PIC (programmable interface controller) series of microcontrollers manufactured by Microchip Technology Inc. [4]2.2MICROCONTROLLER SYSTEMS

A microcontroller is a single-chip computer. Micro suggests that the device is small, and controller suggests that it is used in control applications. Another term for microcontroller is embedded controller, since most of the microcontrollers are built into (or embedded in) the devices they control. A microprocessor differs from a microcontroller in a number of ways. The main distinction is that a microprocessor requires several other components for its operation, such as program memory and data memory, input-output devices, and an external clock circuit. A microcontroller, on the other hand, has all the support chips incorporated inside its single chip. All microcontrollers operate on a set of instructions (or the user program) stored in their memory. A microcontroller fetches the instructions from its program memory one by one, decodes these instructions, and then carries out the required operations.

Microcontrollers have traditionally been programmed using the assembly language of the target device. Although the assembly language is fast, it has several disadvantages. An assembly program consists of mnemonics, which makes learning and maintaining a program written using the assembly language difficult. Also, microcontrollers manufactured by different firms have different assembly languages, so the user must learn a new language with every new microcontroller he or she uses.

Microcontrollers can also be programmed using a high-level language, such as mikroC by MikroElektronika Inc., CCS C by Custom Computer Services, Inc., Keil Compiler by Keil Elektronik etc. High-level languages are much easier to learn than assembly languages. They also facilitate the development of large and complex programs.

In theory, a single chip is sufficient to have a running microcontroller system. In practical applications, however, additional components may be required so the microcomputer can interface with its environment. With the advent of the PIC family of microcontrollers the development time of an electronic project has been reduced to several hours.

Basically, a microcomputer executes a user program which is loaded in its program memory. Under the control of this program, data is received from external devices (inputs), manipulated, and then sent to external devices (outputs). For example, in a microcontroller-based oven temperature control system the microcomputer reads the temperature using a temperature sensor and then operates a heater or a fan to keep the temperature at the required value.

A microcontroller is a very powerful tool that allows a designer to create sophisticated input-output data manipulation under program control. Microcontrollers are classified by the number of bits they process. Microcontrollers with 8 bits are the most popular and are used in most microcontroller-based applications. Microcontrollers with 16 and 32 bits are much more powerful, but are usually more expensive and not required in most small or medium-size general purpose applications that call for microcontrollers.

The simplest microcontroller architecture consists of a microprocessor, memory, and input-output. The microprocessor consists of a central processing unit (CPU) and a control unit (CU). The CPU is the brain of the microcontroller; this is where all the arithmetic and logic operations are performed. The CU controls the internal operations of the microprocessor and sends signals to other parts of the microcontroller to carry out the required instructions.

Memory, an important part of a microcontroller system, can be classified into two types: program memory and data memory. Program memory stores the program written by the programmer and is usually nonvolatile (i.e., data is not lost after the power is turned off). Data memory stores the temporary data used in a program and is usually volatile (i.e., data is lost after the power is turned off). [4]There are basically six types of memories, summarized as follows:

2.2.1RAMRAM, random access memory, is a general purpose memory that usually stores the user data in a program. RAM memory is volatile in the sense that it cannot retain data in the absence of power (i.e., data is lost after the power is turned off). Most microcontrollers have some amount of internal RAM, 256 bytes being a common amount, although some microcontrollers have more, some less. The PIC18F452 microcontroller, for example, has 1536 bytes of RAM. Memory can usually be extended by adding external memory chips. [4]2.2.2ROMROM, read only memory, usually holds program or fixed user data. ROM is nonvolatile. If power is removed from ROM and then reapplied, the original data will still be there. ROM memory is programmed during the manufacturing process, and the user cannot change its contents. ROM memory is only useful if we have developed a program and wish to create several thousand copies of it. [4]2.2.3PROMPROM, programmable read only memory, is a type of ROM that can be programmed in the field, often by the end user, using a device called a PROM programmer. Once a PROM has been programmed, its contents cannot be changed. PROMs are usually used in low production applications where only a few such memories are required. [4]2.2.4EPROMEPROM, erasable programmable read only memory, is similar to ROM, but EPROM can be programmed using a suitable programming device. An EPROM memory has a small clear-glass window on top of the chip where the data can be erased under strong ultraviolet light. Once the memory is programmed, the window can be covered with dark tape to prevent accidental erasure of the data. An EPROM memory must be erased before it can be reprogrammed. Many developmental versions of microcontrollers are manufactured with EPROM memories where the user program can be stored. These memories are erased and reprogrammed until the user is satisfied with the program. Some versions of EPROMs, known as OTP (one time programmable), can be programmed using a suitable programmer device but cannot be erased. OTP memories cost much less than EPROMs. OTP is useful after a project has been developed completely and many copies of the program memory must be made. [4] 2.2.5EEPROMEEPROM, electrically erasable programmable read only memory, is a nonvolatile memory that can be erased and reprogrammed using a suitable programming device. EEPROMs are used to save configuration information, maximum and minimum values, identification data, etc. Some microcontrollers have built-in EEPROM memories. For instance, the PIC18F452 contains a 256-byte EEPROM memory where each byte can be programmed and erased directly by applications software. EEPROM memories are usually very slow. An EEPROM chip is much costlier than an EPROM chip. [4]2.2.6FLASH EEPROMFlash EEPROM, a version of EEPROM memory, has become popular in microcontroller applications and is used to store the user program. Flash EEPROM is nonvolatile and usually very fast. The data can be erased and then reprogrammed using a suitable programming device. Some microcontrollers have only 1K flash EEPROM while others have 32K or more. The PIC18F452 microcontroller has 32K bytes of flash memory. [4]2. 3MICROCONTROLLER ARCHITECHTURETwo types of architectures are conventional in microcontrollers. Von Neumann architecture, used by a large percentage of microcontrollers, places all memory space on the same bus; instruction and data also use the same bus.

In Harvard architecture (used by PIC microcontrollers), code and data are on separate buses, which allows them to be fetched simultaneously, resulting in an improved performance. [4]2.3.1 RISC and CISC

RISC (reduced instruction set computer) and CISC (complex instruction computer) refer to the instruction set of a microcontroller. In an 8-bit RISC microcontroller, data is 8 bits wide but the instruction words are more than 8 bits wide (usually 12, 14, or 16 bits) and the instructions occupy one word in the program memory. Thus the instructions are fetched and executed in one cycle, which improves performance.

In a CISC microcontroller, both data and instructions are 8 bits wide. CISC microcontrollers usually have over two hundred instructions. Data and code are on the same bus and cannot be fetched simultaneously. [4]2.4MICROCONTROLLER FEATURES

Microcontrollers from different manufacturers have different architectures and different capabilities. Some may suit a particular application while others may be totally unsuitable for the same application. The hardware features common to most microcontrollers are described in this section.2.4.1SUPPLY VOLTAGE

Most microcontrollers operate with the standard logic voltage of 5V. Some microcontrollers can operate at as low as 2.7V, and some will tolerate 6V without any problem. The manufacturers data sheet will have information about the allowed limits of the power supply voltage. PIC18F452 microcontrollers can operate with a power supply of 2V to 6.5V. Usually, a voltage regulator circuit is used to obtain the required power supply voltage when the device is operated from a mains adapter or batteries. For example, a 5V regulator is required if the microcontroller is operated from a 5V supply using a 9V battery. [4]2.4.2THE CLOCK

All microcontrollers require a clock (or an oscillator) to operate, usually provided by external timing devices connected to the microcontroller. In most cases, these external timing devices are a crystal plus two small capacitors. In some cases they are resonators or an external resistor-capacitor pair. Some microcontrollers have built-in timing circuits and do not require external timing components. If an application is not time- sensitive, external or internal (if available) resistor-capacitor timing components are the best option for their simplicity and low cost. An instruction is executed by fetching it from the memory and then decoding it. This usually takes several clock cycles and is known as the instruction cycle. In PIC microcontrollers, an instruction cycle takes four clock periods. Thus the microcontroller operates at a clock rate that is one-quarter of the actual oscillator frequency. [4]The performance of a CPU in a microcontroller is normally determined by the frequency of an oscillator crystal. Typically a crystal oscillator produces a fixed sine wavethe frequency reference signal. Electronic circuitry translates that into a square wave at the same frequency for digital electronics applications. The clock distribution network inside the CPU carries that clock signal to all the components that need it. With each clock pulse, the CPU executes one instruction set. The higher the clock pulse the higher the execution rate. For example if we use a CPU with a 20 MHz clock frequency, then it will execute an instruction in 0.05 microseconds (since, hence or 0.05s). But if the same CPU is given an 8 MHz clock frequency, then it will execute the same instruction in 12.5 microseconds ( or 12.5s). Usually most CPU in microcontrollers complete one instruction with each clock pulse, but some device requires up to 4 clock pulses to complete one instruction set, such as PIC microcontroller we used in our project requires 4 clock pulses to complete one instruction set.

But increased clock frequency will increase heat produce by the CPU in microcontroller, which in turns increases the body temperature of the microcontroller, leading to failure of the device. According to manufacturer datasheet increase of 1MHz clock frequency will increase 5C operating body temperature of the microcontroller per hour. Maximum operating temperature of a PIC16F877A is 125C. [10] Using the following equation a safe operating temperature for the microcontroller can be derived.

TB= TA+FOSC5C2C

Here, TB = total body temperature of the microcontroller

TA = ambient/room temperature FOSC = oscillating frequency

Example: if the room temperature is 30C and 20MHz clock frequency, then according to stated equation the body temperature of the microcontroller will be,

TB= 30+205C2C

Or, TB= 30+1002C

Or, TB= 1302C

This exceeds the maximum operating temperature of the microcontroller. Again if the room temperature is 30C and 8MHz clock frequency, then according to stated equation the body temperature of the microcontroller will be,

TB= 30+85C2C

Or, TB= 30+402C

Or, TB= 702C

And this is within the maximum operating range of the microcontroller. Hence, we used an 8MHz clock frequency, instead of 20MHz clock frequency.2.4.3TIMERS

Timers are important parts of any microcontroller. A timer is basically a counter which is driven from either an external clock pulse or the microcontrollers internal oscillator. A timer can be 8 bits or 16 bits wide. Data can be loaded into a timer under program control, and the timer can be stopped or started by program control. Most timers can be configured to generate an interrupt when they reach a certain count (usually when they overflow). The user program can use an interrupt to carry out accurate timing-related operations inside the microcontroller. Microcontrollers in the PIC16F series have at least two timers. For example, the PIC16F877A microcontroller has two built-in timers. Some microcontrollers offer capture and compare facilities, where a timer value can be read when an external event occurs, or the timer value can be compared to a preset value, and an interrupt is generated when this value is reached. Most PIC16F microcontrollers have at least two capture and compare modules. [4]2.4.4WATCHDOG

Most microcontrollers have at least one watchdog facility. The watchdog is basically a timer that is refreshed by the user program. Whenever the program fails to refresh the watchdog, a reset occurs. The watchdog timer is used to detect a system problem, such as the program being in an endless loop. This safety feature prevents runaway software and stops the microcontroller from executing meaningless and unwanted code. Watchdog facilities are commonly used in real-time systems where the successful termination of one or more activities must be checked regularly. [4]2.4.5RESET INPUT

A reset input is used to reset a microcontroller externally. Resetting puts the microcontroller into a known state such that the program execution starts from address0 of the program memory. An external reset action is usually achieved by connecting a push-button switch to the reset input. When the switch is pressed, the microcontroller is reset. [4]2.4.6INTERRUPTS

Interrupts are an important concept in microcontrollers. An interrupt causes the microcontroller to respond to external and internal (e.g., a timer) events very quickly. When an interrupt occurs, the microcontroller leaves its normal flow of program execution and jumps to a special part of the program known as the interrupt service routine (ISR). The program code inside the ISR is executed, and upon return from the ISR the program resumes its normal flow of execution. The ISR starts from a fixed address of the program memory sometimes known as the interrupt vector address. Some microcontrollers with multi-interrupt features have just one interrupt vector address, while others have unique interrupt vector addresses, one for each interrupt source. Interrupts can be nested such that a new interrupt can suspend the execution of another interrupt. Another important feature of multi-interrupt capability is that different interrupt sources can be assigned different levels of priority. For example, the PIC18F series of microcontrollers has both low-priority and high- priority interrupts levels. [4]2.4.7BROWN-OUT DETECTOR

Brown-out detectors, which are common in many microcontrollers, reset the microcontroller if the supply voltage falls below a nominal value. These safety features can be employed to prevent unpredictable operation at low voltages, especially to protect the contents of EEPROM-type memories. [4]2.4.8ANALOG-TO-DIGITAL CONVERTER

An analog-to-digital converter (A/D) is used to convert an analog signal, such as voltage, to digital form so a microcontroller can read and process it. Some microcontrollers have built-in A/D converters. External A/D converter can also be connected to any type of microcontroller. A/D converters are usually 8 to 10 bits, having 256 to 1024 quantization levels. Most PIC microcontrollers with A/D features have multiplexed A/D converters which provide more than one analog input channel. For example, the PIC18F452 microcontroller has 10-bit 8-channel A/D converters. The A/D conversion process must be started by the user program and may take several hundred microseconds to complete. A/D converters usually generate interrupts when a conversion is complete so the user program can read the converted data quickly. A/D converters are especially useful in control and monitoring applications, since most sensors (e.g., temperature sensors, pressure sensors, force sensors, etc.) produce analog output voltages. [4]2.4.9SERIAL INPUT-OUTPUT

Serial communication (also called RS232 communication) enables a microcontroller to be connected to another microcontroller or to a PC using a serial cable. Some microcontrollers have built-in hardware called USART (universal synchronous- asynchronous receiver-transmitter) to implement a serial communication interface. The user program can usually select the baud rate and data format. If no serial input-output hardware is provided, it is easy to develop software to implement serial data communication using any I/O pin of a microcontroller. The PIC18F series of microcontrollers has built-in USART modules. Some microcontrollers (e.g., the PIC18F series) incorporate SPI (serial peripheral interface) or I2C (integrated interconnect) hardware bus interfaces. These enable a microcontroller to interface with other compatible devices easily. [4]2.4.10EEPROM DATA MEMORY

EEPROM-type data memory is also very common in many microcontrollers. The advantage of an EEPROM memory is that the programmer can store nonvolatile data there and change this data whenever required. For example, in a temperature monitoring application, the maximum and minimum temperature readings can be stored in an EEPROM memory. If the power supply is removed for any reason, the values of the latest readings are available in the EEPROM memory. The PIC18F452 microcontroller has 256 bytes of EEPROM memory. Other members of the PIC18F family have more EEPROM memory (e.g., the PIC18F6680 has 1024 bytes). The mikroC language provides special instructions for reading and writing to the EEPROM memory of a PIC microcontroller. [4]2.4.11 LCD DRIVERS

LCD drivers enable a microcontroller to be connected to an external LCD display directly. These drivers are not common since most of the functions they provide can be implemented in software. For example, the PIC18F6490 microcontroller has a built-in LCD driver module. [4]2.4.12 ANALOG COMPARATOR

Analog comparators are used where two analog voltages need to be compared. Although these circuits are implemented in most high-end PIC microcontrollers, they are not common in other microcontrollers. The PIC18F series of microcontrollers has built-in analog comparator modules. [4]2.4.13 REAL-TIME CLOCK

A real-time clock enables a microcontroller to receive absolute date and time information continuously. Built-in real-time clocks are not common in most microcontrollers, since the same function can easily be implemented by either a dedicated real-time clock chip or a program written for this purpose. [4]2.4.14 SLEEP MODESome microcontrollers (e.g., PICs) offer built-in sleep modes, where executing this instruction stops the internal oscillator and reduces power consumption to an extremely low level. The sleep modes main purpose is to conserve battery power when the microcontroller is not doing anything useful. The microcontroller is usually woken up from sleep mode by an external reset or a watchdog time-out. [4]2.4.15 POWER-ON RESET

Some microcontrollers (e.g., PICs) have built-in power-on reset circuits which keep the microcontroller in the reset state until all the internal circuitry has been initialized. This feature is very useful, as it starts the microcontroller from a known state on power-up. An external reset can also be provided, where the microcontroller is reset when an external button is pressed. [4]2.5PIC16F877A MICROCONTROLLER OVERVIEWHigh-Performance RISC CPU:

Only 35 single-word instructions to learn

All single-cycle instructions except for program branches, which are two-cycle

Operating speed: DC 20 MHz clock input

DC 200 ns instruction cycle

Up to 8K x 14 words of Flash Program Memory, Up to 368 x 8 bytes of Data Memory (RAM),Up to 256 x 8 bytes of EEPROM Data Memory

Pin out compatible to other 28-pin or 40/44-pinPIC16CXXX and PIC16FXXX microcontrollers

Peripheral Features:

Timer0: 8-bit timer/counter with 8-bit prescaler Timer1: 16-bit timer/counter with prescaler, can be incremented during Sleep via external crystal/clock

Timer2: 8-bit timer/counter with 8-bit period register, prescaler and postscaler Two Capture, Compare, PWM modules

Capture is 16-bit, max. resolution is 12.5 ns Compare is 16-bit, max. resolution is 200 ns

PWM max. resolution is 10-bit Synchronous Serial Port (SSP) with SPI (Master mode) and I2C (Master/Slave)

Universal Synchronous Asynchronous Receiver Transmitter (USART/SCI) with 9-bit address detection

Parallel Slave Port (PSP) 8 bits wide with external RD, WR and CS controls (40/44-pin only)

Brown-out detection circuitry for Brown-out Reset (BOR)

10-bit, up to 8-channel Analog-to-Digital

Converter (A/D)

DeviceProgram MemoryData SRAM (Bytes)EEPROM (Bytes)I/O10-bitA/D (ch)CCP (PWM)MSSPUSARTTimers8/16-bitComparators

Bytes# Single WordInstructionsSPIMasterI2C

PIC16F877A14.3K81923682563382YesYesYes2/12

2.6WHY SELECT PIC16F877A?PIC16F877A has a operating range at DC 20MHz clock frequency. It has 386 bytes RAM and vast 8192 single word instruction or 14.3Kbytes program memory. It also provides an ADC and USART module. It also provides CCP, SPI, I2C Comparator and Timers module.

To implement our design we needed an ADC module to read sensors analog data and analyze. To send SMS using a GSM Modem, we need an UART module to communicate with module. Thats why we selected PIC16F877A microcontroller.

2.7USED PIN IN OUR PROJECT PIN01 it is Master Reset pin, it also used for power on reset feature where microcontroller program cycle is reset and start from the beginning.

PIN 02 0 5 are part of the ADC module of the microcontroller, can be used as both analog and digital input, and digital output.

PIN 13 14 used for receiving an external clock frequency using a crystal oscillator.

PIN 11 32 used for power supply to microcontroller, usually +5v.

PIN 12 31 used for grounding end to complete the circuit.

PIN 25 is connected to UART module of microcontroller, performs the transition of data.

PIN 26 is connected to UART module of microcontroller, performs the receiving of data.

CHAPTER 3

SENSOR3.1 INTRODUCTION

A sensor is a device that measures a physical quantity and converts it into a signal which can be read by an observer or by an (today mostly electronic) instrument. A sensor is a device, which responds to an input quantity by generating a functionally related output usually in the form of an electrical or optical signal. A sensor's sensitivity indicates how much the sensor's output changes when the measured quantity changes.

A good sensor obeys the following rules:

Is sensitive to the measured property only

Is insensitive to any other property likely to be encountered in its application

Does not influence the measured property

Ideal sensors are designed to be linear or linear to some simple mathematical function of the measurement, typically logarithmic. The output of such a sensor is an analog signal and linearly proportional to the value or simple function of the measured property. The sensitivity is then defined as the ratio between output signal and measured property. [1]3.2 TEMPERATURE SENSORA temperature is a numerical measure of hot and cold. Its measurement is by detection of heat radiation, particle velocity, kinetic energy, or most commonly, by the bulk behavior of a thermometric material. It may be calibrated in any of various temperature scales, Celsius, Fahrenheit, Kelvin, etc. [3]

3.2.1TEMPERATURE AND ITS MEASUREMENT

Simply speaking, temperature is the degree of hotness of the body which is a measure of the heat content in the body. The problem to quantify the heat content of the body on a scale did not arise until the invention of the Steam Engine. The curiosity of scientists to understand the behavior of water at different levels of heat contents gave rise to a formal and better laid out study. One of the first references for temperature dates back to 1760, when Joseph Black declared that applying the same heat to different materials resulted in different temperatures. Years of rigorous scientific study led to many theories ranging from the simple Caloric concept, which treated heat as a material substance which is exchanged among materials, to Carnots description of heat as a form of energy (which laid the foundation of the first law of thermodynamics). However, none of them satisfactorily explained the concept of temperature. It was Maxwells theory which offered good reasoning into it. He defined temperature of a body as is its thermal property which provides information about the energy content of the system. It is the measure of the average kinetic energy (energy by virtue of motion) of the molecules of the substance and signifies a heat potential due to which heat flows from higher temperature to lower temperature.

The word temperature itself is said to be derived of the Latin word tempera meaning moderate or soften. Moving along Maxwells line of thought, the velocity of molecules should be the basis of selecting the value of temperature, with absolute heatlessness being a state where the molecules are totally static. But, this measurement is not possible practically, and hence, other manifestations of the effect of heat are utilized to measure temperature, for example, the geometric expansion of materials. [3]3.2.2TYPES OF TEMPERATURE SENSORSTemperature can be classified into following classes:The classes of temperature sensors based on their mechanical property:

Contact Temperature Sensing: The sensor is brought into physical contact with the object to be monitored. This method can be used with solids, liquids and gases. The sensors used for measurement can vary from capillary bulb thermometers and bi-metal sensors to sensors that use varying voltage signals or resistance values. [3]

Expansion Thermometers: These sensors use Bi-metallic strips which have different expansion rates at a particular temperature. Thus, this difference of expansion can be translated into temperature change using a mechanical pointer. Though not very accurate, these devices offer the advantage of being portable. Low cost applications like time compensators in mechanical clocks, thermostats where a higher temperature may open the contact as in heating control or may close it like in refrigerators make use of bimetallic strips to open and close mechanical switches which in turn control electrical switches like circuit breakers. [3]

Filled System Thermometers: These devices are filled with some substitute which expands or contracts due to temperature change. They may be filled with mercury. However, as it is considered to be an environmental hazard, organic liquid types may be used instead. These do not require any electric power to operate and are stable even after repeated use. However, they do not provide any kind of reading storage solution and also cannot make point measurements. These find use in medical industry to measure body temperatures. [3]The classes of temperature sensors based on their electrical property:

Voltage signal based sensors: Thermocouples are the main sensors of this category. The underlying principle is the Seebeck effect. When two different metals or alloys are placed together so as to form two junctions, a voltage is induced across the junctions when there is a difference of temperatures between the junctions. These sensors are capable of detecting very high temperatures (as high as 1700o), have a very simplistic design which makes them quite robust to shock and vibration and can have almost immediate response to temperature changes. They however provide localized temperature readings and need a cold junction compensation to maintain the temperature gradient. Also, they are highly non-linear devices when compared to other sensors and require extremely good algorithms on the part of the conditioning electronics and processors to compensate for the non-linearity. Thermocouples find application in extremely high temperature sensing applications, chemical reaction monitoring, metal cutting, gas chromatography, sensing temperatures inside internal combustion engines etc. owing to their wide temperature range and ruggedness; however, if high accuracy and linearity are desired, other temperature sensors must be used. Simple implementation ideas can be like the one in the following: [3]

Resistance value based sensors: The resistance of metals and semiconductors offered to the flow of current through them changes with temperature. This change can be monitored and mapped to various temperature values on a scale. Further, on increasing the temperature, the value of resistance may increase or decrease. Substances with a positive temperature coefficient like most metals undergo a positive change of resistance with increasing temperature, while resistance of most semiconductors decreases with increasing temperature owing to their negative temperature coefficients. Based on the temperature coefficients, the Resistance Temperature Detectors (RTD) can be further divided into two types: [3]Resistance Wire: Mainly built with materials with positive resistance coefficient materials like platinum, RTDs are resistive elements which exhibit predictable change in resistance with temperature. The change of Resistance with temperature is given by the relation:

Here, Rt and Ro are the resistance of the material at temperatures t and to C; andis the Average temperature Coefficient. These devices may be in the forms of Thin Film Resistors or Wire-wounded Resistors. They offer a very wide linear range of temperature measurement (-200 to 650oC) and are very stable with minimal drift even with repeated operation year after year. The signal output is quite large as compared to thermocouples, and can use ordinary copper wires for extension. Also, these can be spread over a large area. Such sensors may be mounted on one arm of a balanced Wheatstone bridge circuit as shown in the figure below and the entire circuit be used to calculate and also control actuators for maintenance of temperature using feedback. They provide the desired linear range of operation where thermocouples fall short. RTDs find use in applications like cold junction compensation, calibration purposes, in a wheat stone bridge circuit and process control. The linearity simplifies the implementation of signal conditioning circuitry and makes RTDs suitable for high precision applications. RTDs measure absolute temperature in contrast with the thermocouples, and hence, might not be suitable for maintaining uniform temperature throughout the surface like the thermocouples are used. [3]

Thermistor: Semiconductors offer a variety of phenomenon and form the very basis of electronics. Both Positive (PTC) and Negative Temperature Coefficient (NTC) semiconductors are present and sensors based on them are differentiated as cold-wire PTC-Thermistor and hot-wire NTC-Thermistor. For PTC-Thermistor, Ferro electricity is the predominant phenomenon causing the positive coefficient in a short range of temperature. The short temperature range of operation for these materials makes them suitable for use as temperature limiting switches. They have been used successfully in CRT monitors as timers in degaussing coils. They can be used as replacements for fuses in the form of current limiting devices. If the current increases, more heat is generated which heats up the Thermistor. This increases the resistance which reduces the current and voltage available to the device thus protecting it from increased currents. For NTC-Thermistor, the relation between resistance and temperature is negative and exponential which is very repeatable. In the range of use, this exponential curve can be seen as a fairly linear plot and can even provide more sensitivity than RTDs which makes them more attractive in terms of accuracy in measurements.

Owing to their low costs, they find ample use in automotive and consumer products industries like coolant and oil temperature monitors, incubator temperature maintenance, low temperature thermometers, modern digital thermostats, battery pack temperature monitors etc. A more recent application where NTC Thermistor have been used is 3D printing, where Thermistor are used to maintain a constant temperature at the hot end of 3D printers for the proper melting of plastic filaments. [3]Integrated Silicon Temperature Sensors: Besides all these classifications, integrated circuits have been designed to provide ease of use while measuring temperatures in the desired scale. For example, the LM35 IC from Texas Instruments is a precision temperature sensor IC that offers reading directly on the Celsius scale and LM34 is another one offering readings on the Fahrenheit scale. These ICs provide Voltage readings which are directly proportional to a certain multiplier of temperature and hence can be directly read off a multimeter, or fed directly into an ADC for further processing. They provide easy integration and interfacing with other elements of the circuit. Many semiconductor companies like Analog Devices, Microchip, Smartek, ZMD and ST Microelectronics are into temperature sensors design and even provide signal processing circuitry and digital I/O interfaces for microcontrollers. These temperature sensors find widespread use in consumer products like personal computers, office electronics equipment, cellular phones, HVACs and battery management solutions.

Apart from these major principles of temperature measurement, other methods have also been developed. Some of them are, oscillating quartz temperature sensors, thermal noise thermometers, fiber optic thermometers and temperature measurement systems. [3]

3.2.3SELECTION CRITERIA OF TEMPERATURE SENSORS

None of the temperature sensing devices are versatile enough to be used everywhere. If the thermocouples are known for their wide temperature range of operation, RTDs are unrivalled in the linearity range and Thermistor is very accurate while the silicon sensors are easy to integrate in circuits. The use of a particular temperature sensor in some applications is governed by a number of parameters, the most important being temperature itself. The temperature range for the application, the rate at which the temperature may change, etc. help decide the type of design. For example, for sensors with high operating temperatures, special connection leads would be needed, while for sensors which have to deal with temperature shocks, wire-wound type of construction is preferred.

The stability and accuracy of the sensor at the prescribed operating conditions is another major factor to weigh while choosing design. Sensitivity of the device to measure small changes and how prone it is to self heating, determines the reliability of the device and its performance. The response time of the sensor is often governed by the size of the sensor. For example, the small dimensions of a film type resistor based sensor result in minimal associated heat capacity and hence, short response times (0.1 s in water and 3 to 6s in air). In the same application area, wire type resistor would respond in 0.2 to 0.5s in water and 4 to 25s in air. To aid you in choosing the right temperature sensor for your application, a comparison table of the 4 popular sensors is drawn below for easy reference:

Table 1 Comparison among Different Types of Temperature Sensor

TypeThermocoupleRTDThermistorIntegrated Silicon

Temperature Range-270 - 1800C-250 - 900C-100 - 450C-55 - 150C

Accuracy0.5C0.01C0.1C1C

Linearity (Minimum order of polynomial, lesser the better)4th order polynomial2nd order polynomial3rd order polynomialLinearization not required. Within 1C

Sensitivity? 10V/C0.00385?/?/C (Pt)Several?/?/C-2mV/C

RuggednessLarger the gauge of wire, more is the ruggednessQuite susceptible to breakage due to vibrationHermetic Thermistor housed in glass, not affected by shock or vibrationAs rugged as an IC in plastic package like a DIP.

Responsiveness (test conditions)Tres) will return from modem. Then simply type was message and at the end enters a "Ctrl-Z" character (ASCII 26). Was message will be send with OK confirmation.8) AT+IPR Baud Rate

In Wavecom the default baud rate is 152000bps, whereas in Telit it is 9600bps. Not all microcontrollers support that much speed. So before use any module read datasheet carefully. To check were module's baud rate write:

AT+IPR?To set were preferable baud rate, write:

AT+IPR = 9600But if we now restart were module, the default baud rate it had earlier, will set again. So if we want to change were module's baud rate permanently, after change the baud rate, we have to save it in the module. The AT command for it is:AT&WThis command save all the configuration it has, at the time of this code executed.

(Note: At the end of all AT command we should send Carriage Return (CR) and some module also need Line Feed (LF) character with CR.)

That is the end of AT commands explanation. [5]5.3AT COMMANDS ARE USED IN OUR PROJECT

1) AT

According to syntax rule 1 every AT command should begin with AT including the double quotes. The AT command is used for testing the GSM modem weather it is working or not. This command is also used for the calling attention of the modem before every other command.

2) AT+CMGF=1

AT+CMGF=1 command is used for configuring the modem into text SMS mode.

3) AT+CMGS=AT+CMGS= command is used to set the destination number for the SMS. CHAPTER 6HARADWARE & SOFTWARE DESCRIPTION6.1HARDWARE REQUIREMENT

PIC Microcontroller 16F877A,

Temperature Sensor HSM-20G,

Humidity Sensor HSM-20G,

Gas Detector MQ9,

PIR Motion Detector Module,

SIMCOM 900 GSM Module,

LCD Display,

Crystal oscillator,

Piezo Buzzer,

Relay.

6.2DESCRIPTION of HARDWARE

6.2.1PIC MICROCONTROLLER (PIC16F877A)Microcontroller is the most important instrument for this project. Multiple sensors are used in this project, hence reading their analog data and convert them into digital data to analyze requires a powerful microcontroller. The microcontroller also sends that information via SMS in real time and display on a LCD.

6.2.2SIM900 GSM MODULE

GSM/GPRS moduleis used to establish communication between a computer and aGSM-GPRS system.Global System for Mobile communication (GSM)is an architecture used for mobile communication in most of the countries.Global Packet Radio Service (GPRS)is an extension of GSM that enables higher data transmission rate.GSM/GPRS module consists of a GSM/GPRS modem assembled together with power supply circuit and communication interfaces(like RS-232, USB, etc) for computer. GSM/GPRS MODEM is a class of wireless MODEM devices that are designed for communication of a computer with the GSM and GPRS network. It requires a SIM (Subscriber Identity Module)card just like mobile phones to activate communication with the network. Also they haveIMEI(International Mobile Equipment Identity) number similar to mobile phones for their identification. A GSM/GPRS MODEM can perform the following operations:1.Receive, send or delete SMS messages in a SIM.

2.Read, add, search phonebook entries of the SIM.

3.Make, Receive, or reject a voice call.

The MODEM needsAT commands, for interacting with processor or controller, which are communicated through serial communication. These commands are sent by the controller/processor. The MODEM sends back a result after it receives a command. Different AT commands supported by the MODEM can be sent by the processor/controller/computer to interact with theGSM and GPRS cellular network.6.2.3HSM 20G TEMPERATURE & HUMIDITY SENSOR

The module of HSM-20G is a combination of both temperature and humidity sensor. This module implements resistive (Thermistor NTC type) temperature sensing principle and capacitive humidity sensing principle.

6.2.4MQ 9 GAS DETECTOR

MQ 9 is a semiconductor type gas detector. This model is particularly sensitive to methane (CH4), LPG (liquidize pressurized gas) and Carbon Monoxide (CO). Its sensing element is made of Al2O3 ceramic tube and SnO2 wire.

6.2.5PIR MOTION SENSING MODULEIt is a pyroelectric sensor module which developed for human body detection. An integrated PIR sensor combined with a Fresnel lens which is mounted on a compact PCB, and limited components to form the module. Delay time, Lux is adjustable. Customization is accepted.6.2.6LCD DISPLAYThe LCD display used in this project is an alphanumeric 162 display. It contains total of 16 pins, 8 data pins, 1registor select pin, 1 read-write pin, 1 enable signal pin, 1display brightness control pin, 2 power supply pin, 2 backlight pin.

6.2.7PIEZO BUZZER

Piezo buzzer is an electronic device commonly used to produce sound. Light weight, simple construction and low price make it usable in various applications like car/truck reversing indicator, computers, call bells etc.6.2.8CRYSTAL OSCILLATOR

A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time, to provide a stable clock signal for digital integrated circuits; in this provides it provides an 8MHz clock frequency for microcontroller.

6.2.9RELAY

A relay is an electrically operated switch the employs electromagnet to mechanically operate a switch. Here a relay is to mains supply as protective measurement of the load and the entire circuit.6.3SOFTWARE REQUIRMENT

Proteus 8.1,

mikroC,

PicKit 2.

6.3.1PROTEUS 8.1 Proteus 8.1 is software for microprocessor based embedded system design and simulation, schematic capture and PCB layout design. It is developed by Labcenter Electronics Ltd. England.

6.3.2MikroC PRO for PIC

MikroC PRO for PIC is the most popular C compiler for PIC microcontroller. It is high level programming language. It provides a vast built in library function for electronic hobbyist and professional embedded system developer. It is developed by Mikroelektronika under third party license from Microchip Technologies.

6.3.3PicKit 2 PicKit2 is programmer (firmware burner) software for PIC microcontroller.CHAPTER 7

CIRCUIT DIAGRAM & ALGORITHM

7.1CIRCUIT DIAGRAM

7.2ALGORITHM

PART 01: FOR SENSORS

Step 01: Start

Step 02: Declare Variables; Preprocessor and User Function (if any).

Step 03: Create an array with appropriate label for sending SMS. Step 04: Start main function.

Step 05: Set PORTA all PIN as Input,

PORTC PIN 2 as Output to Buzzer,

PORTD PIN 3 as Output to Relay.Step 06: SetPORTC PIN 2 as Output 0 or 0V for Buzzer,

PORTD PIN 3 as Output 1 or 5V for Relay.

Step 07: Initiate LCD display.

Step 08: Initiate UART peripheral.

Step 09: Initiate ADC peripheral.

Step 10: DO FOREVER.

Step 11: Get analog readings from Analog Input Channel 2 twenty times, then acquire an average

value and place it in a variable (suppose a).

Step 12: Convert that value into a voltage output using following equation

and store it in another variable (suppose x)Step 13: Apply the value of x into the following equation to get humidity value. Store it in

SMS array and another variable (suppose Humidity). Step 14: Get value derive in Step 13 and convert it into ASCII character to display on the LCD.

Step 15: Repeat Step 11 to Step 12 for Analog Input Channel 3.

Step 16: Repeat Step 13 for the following equation for the value derived at Step 15.

Step 17: Repeat Step 14 for Step 16.

Step 18: Get analog readings from Analog Input Channel 1.

Step 19: Check if Channel 1 reading is > 800 , set flag bit = 1.

check again if flag bit == 1,

start buzzer, send SMS YES,

display YES

else

stop buzzer,

display NO.Step 20: Repeat Step18 for Analog Input Channel 0.

Step 21: Repeat Step19 for Channel 0 reading is > 512.Step 22: Check if

Step 16 reading is > 50 and Step 19 flag bit == 1

Invert Step 06 output.

Send SMS

Step 23: Stop

PART 02: FOR SENDING SMS (GSM COMMAND)

Step 01: Start

Step 02: Prepare GSM modem by writing AT command to UART module.

Step 03: Send Carriage Return as end of command.

Step 04: Set SMS Text mode by writing AT+CMGF = 1 to UART module.

Step 05: Repeat Step 02.Step 06: To set destination number write AT+CMGS = to UART module.

Step 07: Repeat Step 02.Step 08: Write the destination number between to UART module.

Step 09: Repeat Step 02.

Step 10: Send Line Feed command.

Step 11: IF send SMS invoked THEN

write message to UART module

write Ctrl+Z to UART module as end of message indication.

Repeat Step 02 and Step 09.

Step 12: Stop.

7.3FLOW CHART

7.3.1DESCRIPTION

At first we turn on the supply for the system. Upon power supply to the system, a buzzer sound indicates that the system is on. When the power supply is on, the microcontroller initiates its internal ADC, UART module. Microcontroller uses the UART module to communicate with GSM modem. After initialization of ADC module, microcontroller starts reading the sensor value. The sensors are connected to the ADC module in the following manner respectively, RA0 pin is connected to PIR motion sensor, RA1 pin is connected to gas detector, RA2 pin is connected to temperature sensor and RA3 pin is connected to humidity sensor. If the readings from RA0 pin exceeds 512, which indicates motion and human presence; then the microcontroller turns on the buzzer and sends a SMS using GSM modem. At the same time if the readings from RA1 pin exceeds 800, which indicates existence of gas or smoke particle; then the microcontroller turns off the relay which controls the main power supply of the house and sends a SMS using GSM modem. In the mean time the microcontroller checks for changes of value from RA2 pin. If so, then the microcontroller calculates the value and checks if that the value is 50C or not. If the value is 50C, then the microcontroller turns off the relay and sends a SMS using GSM modem and also shows the temperature on LCD. Again at the same time microcontroller check for changes of value from RA3 pin. If the value changes, then microcontroller calculate the value and show the result on a LCD.

Here 512 and 800 is ADC value. It is unit less. These values can be calculated by following method;

ADC voltage resolution, Q = Here, reference voltage is 5V. Since PIC16F877A has a 10-bit A/D converter, hence

Here, 2.5V is input voltage from PIR sensor and 0.004887V is minimum ADC resolution voltage.

Here, 3.9 V is input voltage from PIR sensor and 0.004887V is minimum ADC resolution voltage.

CHAPTER 8

CONCLUSION & FUTURE DEVELOPMENT

8.1CONCLUSION Message Based Home Automation and Security System has a strong appeal because it provides a flexible monitoring service over any distance.

In this project, a microcontroller is interfaced with a GSM modem and four sensors (temperature, humidity, gas & motion). Temperature and Humidity sensor constantly feed information about the ambient, to the microcontroller. Then microcontroller convert those analog data into digital data with the help of built in ADC module and process them and show on a LCD display. If a certain level of temperature (50oC) is crossed, microcontroller turns of the entire system. Also sends a message to a predefined cell phone number.

A gas and a PIR motion sensor is also interfaced with the same microcontroller and constantly monitor. If any of them is triggered it sends an immediate warning message to a predefine phone number.

The resulting system operates in real time. And can be easily modified to get any desired result to related feature. The system operation is cost effective.

8.2DRAWBACKSEven though the system operates in a cost effective manner, its construction is much complex and time consuming. Since 4 individual sensors were used, it demands individual testing of each sensor before the whole system is assembled together. Besides that, each sensors needs to be interfaced with microcontroller separately to operate in real time, so they do not interfere each others operation.

Another drawback of this project that we encountered is shortage of RAM in the microcontroller. The program we developed for this system uses almost all the RAM available in the microcontroller; which creates a problem of hang of the system. So we had to reprogram several times to make available space in the RAM to operate smoothly.

A complex algorithm also required to develop a program that allows the microcontroller to use the GSM network to send SMS to owner.

8.3FUTURE DEVELOPMENT This system incorporate a gas detector which can be used in garments industry for early warning of combustible gas which might lead to fire; since these factories are built in congested space.

This system can be implemented to monitor temperature, humidity and hazardous gas deposition in oil and gas mining fields.

Law enforcement agencies can use this concept for monitoring burglar warning.

Fire service and civil defense can use this concept receive fire warning.

This system can be expanded to home automation system.

Appendix A

SOURCE CODE

/*****************************************************************************

* Program for "Home Automation System"

* MCU: PIC16F877A;

*

X-Tal: 8MHz (Ex.)

*****************************************************************************/

// LCD module connections

sbit LCD_RS at RB2_bit;

sbit LCD_EN at RB3_bit;

sbit LCD_D4 at RB4_bit;

sbit LCD_D5 at RB5_bit;

sbit LCD_D6 at RB6_bit;

sbit LCD_D7 at RB7_bit;

sbit LCD_RS_Direction at TRISB2_bit;

sbit LCD_EN_Direction at TRISB3_bit;

sbit LCD_D4_Direction at TRISB4_bit;

sbit LCD_D5_Direction at TRISB5_bit;

sbit LCD_D6_Direction at TRISB6_bit;

sbit LCD_D7_Direction at TRISB7_bit;

// End LCD module connections

unsigned int Humidity = 0;

unsigned int Temperature = 0;

short smoke = 0;

short human = 0;

short system = 0;

short stt1,stt2,stt3;

short sms_musk1;

long adc_rd = 0;

long Cnt_human = 0;

long cnt_sms=0;

char uart_rd;

#define Buzzer RC2_bit

#define Relay RD3_bit

#define ON 1

#define OFF 0

void Get_Humidity(void);

void Get_Temperature(void);

void Get_PIR_Sensor(void);

void Get_Gas_Sensor(void);

void System_Control(void);

void Send_Presense(void);

void SMS_Int(void);

void UART_Write_CText(const char *cptr)

{

char chr;

for ( ; chr = *cptr ; ++cptr ) UART1_Write(chr);

}

char SMS[] = "Human: . Smoke: . Temp: C. Hum: %";

void main()

{

TRISA = 0xFF;//all input

ADCON1 = 0x00;//all analog

TRISC2_bit = 0; // Set as output

TRISD3_bit = 0; //Set as output

Relay = OFF;

Buzzer = ON;

// LCD Initialization...

Lcd_Init();

Lcd_Cmd(_LCD_CLEAR); //clear LCD

Lcd_Cmd(_LCD_CURSOR_OFF); //Cusros Off

Lcd_Out(1,4,"SMART HOME ");

Lcd_Out(2,4,"AUTOMATION ");

Delay_ms(500);

Lcd_Cmd(_LCD_CLEAR);

Buzzer = OFF;

UART1_Init(9600);

Delay_ms(100);

while(1)

{

Get_Humidity(void);

Get_Temperature(void);

Get_Gas_Sensor(void);

Get_PIR_Sensor(void);

//main system control...

System_Control(void);

cnt_sms++;

if(cnt_sms>5000)

{

cnt_sms = 0;

SMS_Int(void);

UART1_Write_Text(SMS);

UART1_Write((char)26);//send Control + Z

UART1_Write((char)13);

UART1_Write((char)10);

}

}//while...(1)

}//void main

/*****************************************************************************

********************** Get_Humidity ***********************************

*****************************************************************************/

void Get_Humidity(void)

{

char hum[] = "RH: %";

int ii;

float voltage = 00.00;

ADCON0 = 0b00010001;// Select Channel 2

adc_rd = 0; //Clear Previous Data

for(ii=0;ii512)

{

human = 1;

Lcd_Out(2,13,"YES");

if(stt1 && human)//generate single pulse

{

Buzzer = ON;

SMS_Int(void);

UART_Write_CText("Human Found");

UART1_Write((char)26);//send Control + Z

UART1_Write((char)13);

UART1_Write((char)10);

Delay_ms(100);

Buzzer = OFF;

stt1 = 0;

}

SMS[6] = 'Y';

SMS[7] = 'E';

SMS[8] = 'S';

}

else

{

human = 0;

Lcd_Out(2,13,"No ");

stt1 = 1;

SMS[6] = 'N';

SMS[7] = 'O';

SMS[8] = ' ';

}

// after movement hysteresis...

if(human == 1)

{

system = 1;

Cnt_human = 0;

}

else

{

if(Cnt_human=49)

{

system = 0;

break;

}

}

}

/*****************************************************************************

********************** Get_PIR_Sensor ********************************

*****************************************************************************/

void System_Control(void)

{

if(system)

{

if(Temperature60 || smoke==1)

{

Buzzer = ~Buzzer;

Delay_ms(500);

}

}

}

else

{

Relay = OFF;

}

if(Temperature>60 || smoke==1)

{

Buzzer = ~Buzzer;

Delay_ms(500);

SMS_Int(void);

UART_Write_CText("Fire Found");

UART1_Write((char)26);//send Control + Z

UART1_Write((char)13);

UART1_Write((char)10);

}

}

/*****************************************************************************

********************** SMS_Int ************************************

*****************************************************************************/

void SMS_Int(void)

{

UART1_Write_Text("AT\r");

Delay_ms(500);

UART_Write_CText("AT+cmgf=1\r");

Delay_ms(500);

UART_Write_CText("AT+cmgs=");

UART1_Write((char)'"');

UART_Write_CText("01799251992");

UART1_Write((char)'"');

UART1_Write((char)13);

UART1_Write((char)10);

Delay_ms(500);

}

/********************** End Of The Program *********************************/

Appendix B

REFERENCES:

Website:1) http://en.wikipedia.org/wiki/Main_Page2) http://electrosome.com/3) http://www.engineersgarage.com/4) http://www.wirelessdevnet.com/5) https://www.techshopbd.com/

Books:

6) Advanced PIC Microcontroller Projects in C - Dogan Ibrahim

7) Microcontroller Based Temperature Monitoring And Control - Dogan Ibrahim8) Microcontroller Programming The Microchip PIC - Julio Sanchez9) Interfacing PIC Microcontrollers Embedded Design By Interactive Simulation Martin P. Bates10) PIC16F877A Datasheet.Figure SEQ Figure \* ARABIC 1 Block Diagram of Proposed System

Figure SEQ Figure \* ARABIC 2 Methodology

Figure SEQ Figure \* ARABIC 3 Selection Process

Figure SEQ Figure \* ARABIC 4 Microprocessor vs. Microcontroller

Figure SEQ Figure \* ARABIC 5 Harvard Architecture

Figure SEQ Figure \* ARABIC 6 Von Neumann Architecture

Figure SEQ Figure \* ARABIC 7 Temperature Sensor

Figure SEQ Figure \* ARABIC 8 Circuit Diagram of Voltage Signal based Sensor

Figure SEQ Figure \* ARABIC 9 RTD Circuit Diagram

Figure SEQ Figure \* ARABIC 10 LM35 IC Temperature Sensor

Figure SEQ Figure \* ARABIC 11 Humidity Sensor

Figure SEQ Figure \* ARABIC 12 Correlation of Measuring Scale of Humidity

Figure SEQ Figure \* ARABIC 13 Types of Humidity Sensor

Figure SEQ Figure \* ARABIC 14 Capacitive Type Humidity Sensor

Figure SEQ Figure \* ARABIC 15 Resistive Type Humidity Sensor

Figure SEQ Figure \* ARABIC 16 Capacitive Humidity Sensor

Figure SEQ Figure \* ARABIC 17 MQ - 9 Gas Detector

Figure SEQ Figure \* ARABIC 18 External structure of MQ-9 Gas Detector

Figure SEQ Figure \* ARABIC 19 Steel Mesh of MQ-9 Gas Detector

Figure SEQ Figure \* ARABIC 20 Internal Parts of the Sensor

Figure SEQ Figure \* ARABIC 21 MQ-9 Internal Element

Figure SEQ Figure \* ARABIC 22 Main Sensing Element

Figure SEQ Figure \* ARABIC 23 Working Principle of Thermocouple-Thermopile PIR Sensor

Figure SEQ Figure \* ARABIC 24 Thermocouple-Thermopile PIR Sensor

Figure SEQ Figure \* ARABIC 25 Working Principle of Bolometer

Figure SEQ Figure \* ARABIC 26 Pyroelectric Detector

Figure SEQ Figure \* ARABIC 27 PIR Sensor Circuit

Figure SEQ Figure \* ARABIC 28 Fresnel Lance

Figure SEQ Figure \* ARABIC 29 Operation of a PIR Sensor

Figure SEQ Figure \* ARABIC 31 Block diagram of implementation of GSM network in the project.

Figure SEQ Figure \* ARABIC 32 Telit G862 GSM Module

Figure SEQ Figure \* ARABIC 33 SIM900 GSM Module

Figure SEQ Figure \* ARABIC 34 WAVECOM GSM MODEM

Figure SEQ Figure \* ARABIC 35 Message Based Home Automation and Security System Circuit Diagram

Figure SEQ Figure \* ARABIC 36 Power Supply Circuit Diagram

1248