01362503

6

Click here to load reader

Upload: shrishail-hiremath

Post on 04-Jul-2015

114 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 01362503

A. Alheraish: Design and Implementation of Home Automation System

Contributed Paper Manuscript received July 10, 2004 0098 3063/04/$20.00 © 2004 IEEE

1087

Design and Implementation of Home Automation System A. Alheraish, Member, IEEE

Abstract — M2M Wireless communication of various machines and devices in mobile networks is a fast growing business and application area in industry, maintenance business, customer service, security and banking areas. This paper presents design and implementation of remote control system by means of GSM cellular communication network. The design integrates the device to be controlled, the microcontroller, and the GSM module so that it can be used for a wide range of applications. Detailed description and implementation of each design element are presented. To verify the principle operation of the M2M design, two home applications are experimentally tested using PC-based environment1.

Index Terms — Home automation; surveillance, home monitoring, GSM,

I. INTRODUCTION

M2M (short for machine-to-machine, man-to-machine or mobile-to-machine) is estimated to get an exponential growth in the coming years. M2M enables the flow of data between machines and machines and ultimately machines and people. Regardless of the type of machine or data, information usually flows from a machine over a network, and then through a gateway to a system where it can be processed and analyzed. On other words, M2M allows a machine or device to transmit or receive its data remotely over a network. This makes M2M a very good solution for many problems such as reducing the cost (e.g. the cost of the labors that control or check the machine will be reduced by controlling and checking the machine remotely), and reducing the time of monitoring and controlling the machine (especially when the machine is very far, the time to get to the machine is very long compared to a single click or sending a simple text message). Machines and devices could be vending machines, elevators, pumps, meters, traffic lights, and displays [1]. These need to be constantly monitored, controlled, have information collected from them and sent to them, parameters set and online transactions conducted in order to work effectively.

Designing an M2M system for monitoring and controlling

machine and devices in remote locations can be done through a variety of communications options such as wireless LAN technology, dial-up modems, private radio networks, satellite communication, and cellular network. Out of these options, the cellular network is getting so much attention these days for transporting M2M data, particularly the most widely adopted GSM (global system for mobile communication) digital standard. Some of the reasons are: 1) the wide spread

coverage of GSM which makes the machine online for almost all the time; 2) the GSM network has a low cost compared to constructing a network for M2M and also compared to other mobile communication such as satellite communication; and 3) the GSM network security is very high so the information can not be taken by any outsider. In GSM network, there are a several options for M2M such as Dual Tone Multi Frequency (DTMF), Short Message Service (SMS), and General Packet Radio Service (GPRS). These options make the designer choose the best and effective option for the design.

DTMF makes the mobile send a few tones in the human being speech frequency each tone has a different frequency. The DTMF can be used in M2M in simple applications such as the alarms and in banking when the costumer calls the bank and the bank asks for the costumer account number then the costumer enters the number from the telephone keypad. The DTMF messaging does not use the GSM network resources efficiently because it takes seconds rather than milliseconds to send instructions but it makes the operator have an easy way to deal with the service.

SMS offers today a package type sending as widely used, reliable and suitable global alternative means to interface machines and devices into mobile network. Text message's 160 characters is enough in most machine applications and the messages are easy to implement into existing systems and to interface to other applications. The M2M machine will convert the message into a PDU (Packet Data Unit) mode consisting of a stream of data in hexadecimal mode rather than the alphabetic characters in order to make it easier to the system to understand it. The advantage of the SMS is that it can be sent in milliseconds with more detailed information about the machine relative to the DTMF. In most cases SMS is the correct way to get wireless M2M started.

GPRS is an enhancement to existing GSM networks that introduces packet data transmission. This service is always on which makes the user monitor the machine on time and takes the readings much higher than the other services. The GPRS allows the user to be logged on the e-mail, internet and other services all the time. When the design needs high data rate and online connection with other systems the GPRS is the best way to take. It is also a solution for the application that needs the internet for updating data, delivering daily reports, sending e-mails to the costumers, and providing a live video feed from the site. The cost of the GPRS is higher than the other services, but the advantage is that the service will be always on. The always on networks lead to a great development of the M2M systems and more applications such as in a telemedicine to provide a live monitor of the patient [2].

A. Alheraish is with the Electrical Engineering Department, King Saud

University, Riyadh, Saudi Arabia, (e-mail: [email protected]).

Page 2: 01362503

IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 2004 1088

The aim of this paper is to design and implement a complete M2M system over a GSM network. First, we describe the hardware components of M2M system, namely: the machine, microcontroller, and M2M engine (module). Basically, the M2M device converts the machine function into electrical signal through a transducer (if the machine is already electronic it goes directly) and the signals enter a microcontroller. The microcontroller takes these signals and convert them into an AT commands which can be sent by the mobile into the GSM network then to the other machine or the human. The information that sent via GSM network is sent by SMS. Second, we develop general design procedures to build the M2M system. This will help designer to program a system according to a specific application. Finally, we present experimental work to verify the principle of M2M system operation.

II. DESCRIPTION OF M2M SYSTEM M2M enables the machines whether they are electrical,

electronic, or mechanical to communicate with each other using the GSM. In order to make this communication, certain components have to be used and connect together to perform this task. The M2M upgrades the machines to make them connect to the GSM and then to connect to other machines or users. The information that will be sent to the network has to be taken to a microcontroller to make the interface between the machine and M2M engine (module). The module logs on to the GSM network to send or receive the data needed for monitoring or controlling. Basically the M2M systems consist of three major components as shown in Fig. 1.

Figure 1. Diagram of M2M components

A. The Machine The machine is usually the part that will be monitored or

controlled. The machine is either electric or mechanic. In order to apply an M2M to a machine, there must be a way to

communicate the machine with the microcontroller. In the case of the electrical machine, the communication will be via an interface then to the microcontroller, but in the case of the mechanical machine sensors have to be placed before the interface to convert the mechanical signals into electrical signals.

B. The Microcontroller This part acts like the brain of the system. The

microcontroller (or PC) is able to communicate with the M2M engine when there is a need to access the network for sending or receiving data. Since the microcontroller is an electronic device, the signals that enter it must be electrical. In order to make an electrical or mechanical machine communicate with the microcontroller an interface has to be used. The microcontroller takes the data from the interface and makes some calculations if needed then translates the data into AT commands so the module can understand it. The controller also takes the data from the module then translates the data to the interface to control the machine. The number of monitored systems does not depend on the number of inputs that the microcontroller has. For instance, if the microcontroller has four inputs then it can monitor more than four machines using the time division multiplexing technique.

C. The M2M engine (module) The module acts like an interface between the microcontroller and the GSM network. The M2M engine makes the system log on the GSM network and ready to make any communication or transferring of data. The module must have a Subscriber Identity Module card (SIM card) to make the network identify the user and provide the user the GSM services. The module takes the AT commands from the microcontroller and send them to the other end of M2M system by the GSM network. The AT (ATtention) commands have a very large number of commands; each command performs a certain task. There are several types of M2M engines available in the market, out of these types the focus of this paper will be on GM47 developed by Sony Ericsson. The GM47module is intended for use in 900/1800 and 850/1900 MHz GSM bands respectively. The module is used to make a connection to the GSM network and send and receive SMS and GPRS services and to make a voice calls as well. The GM47 module is not a stand alone device; it is used as an engine of the M2M system.

III. ALGORITHM FOR IMPLEMENTING M2M SYSTEM

The proposed M2M design in this paper uses a PC as the terminal user instead of microcontroller. In such a design, GSM-dial up and communication protocol is embedded in the PC. The operation system is on Window XP for PC and visual C++ for control program coding. The PC processes the incoming data from RS-232 by running a visual C++ program, and sends data via M2M module to control any connected device. Fig. 2 shows a flowchart of the operation of the M2M system. The main blocks of the flowchart are explained next.

Mechanical

Machine

Electrical or Electronic

Machine

Machine

Sensors

Controller

Interface

M2M

Microcontroller

M2M engine (module)

SIM Card

AT commands

Digital signals

Page 3: 01362503

A. Alheraish: Design and Implementation of Home Automation System 1089

Figure 2. Flowchart of M2M algorithm

A. Steps of initializing the module Before programming there are some steps that have to be made in each program that controls the module. These steps initialize the module and make the programming functions work [3].

• Include the required include files into the project directory. At least deftypes.h, RS232.h, SerComm.h, and ATCommand.h. Include also all the h files of the ensembles you use in the project.

• Include EWMSDK.lib into the project.

• Include all the EWMSDK library, or at least the LLAPI layers (AT Command, PDU, Serial Communications and RS232), into the project.

Call AT_InitializeData. Although this is not compulsory for Windows systems, in which memory reservation and initialization is realized each time a program is called, using AT_InitializeData, is very useful in cases when dealing with embedded systems that not reinitialize memory after a reset. Note: AT_InitializeData, restores the table of serial channels, and events. This function is used before initializing channels or registering events.

• Call AT_SetTimer, in Windows environments, when the designer wants to take advantage of the Windows specific methods of periodically searching for events. This function makes Windows to call periodically AT_CheckEvents.

• MS_EstablishChannel is used to open the serial channel that is going to be used in communications with GM47. MS_ReleaseChannel is used before closing the application in order to leave the channel prepared for other applications.

• Call CFG_SetCommandEcho, with Value parameter set at 0, in order to work without local echo. EWMSDK will not work if ATE is set to 1.

• Call VM_SetATResponseFormat with Value parameter set to 1, in order to use the module in verbose mode.The library requires that ATV must be set to value 1 (ATV1). However, this is the usual state of modems. Don't work in ATV0 mode.

Use CFG_SetReportEquipmentError with mode parameter set to 1, if you want the library to offer you specific error code results returned by the module. This function calls the AT Command AT+CMEE. This command has three different modes. In mode 0, and mode 2, the library does not interpret the error codes returned by the module, and the functions return a generic error. In mode 1, the numeric result code returned by the module, is also returned by the library, and can be consulted by the user in the correspondent table in the GM47 Integrator's manual.

B. Check and read the message The program code will periodically check and read any

received message from the M2M module using AT commands. The command that performs this task is AT+CMGR=1, which will read only message no. 1 in the memory of the M2M module. If there is an incoming message, the message will be stored as a string; otherwise it will be deleted. The message is deleted using AT+CMGD=1 command.

C. Decode Since the SMS message includes details such as date, time,

sender's number and the text message, the program must decode the text message and exclude all other details. If the received message matches any of the pre-stored messages (that are stored according to the application requirements), then it will be sent to the application control action; otherwise it will be deleted.

D. Application Control For control purpose, the designer can program a system

according to a specific application. The control can be performed through output of the module which contains a LED circuit that can connect a wide range of applications (experimental work of this control will be presented in Section 6). Alternatively, the control can be performed through the output of the PC such as printing, scanning and other function that a PC can routinely do.

Start

Initializing RS 232 Connection

Check and Read

The Message

There is an Incoming Message

There is no Incoming Message

Delete the message

Save the incoming message as a string

Power OFF

End

No Yes

Decode

Initializing the module

ATE0 AT+CMEE=1 AT+CPMS="ME","ME","ME" AT+CMGF=1

Compare with stored strings

AT+CMGR=1

There is no Similar String

AT+CMGD=1

There is Similar String

Control either: 1. Outputs of

the module. 2. Any output

from the computer.

Application Control

Page 4: 01362503

IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 2004 1090

IV. APPLICATION EXAMPLE

The above described system can be used in so many applications, such as: remote programmable logic controllers (PLCs), remote vending machine, remote banking access, home security system, remote irrigation system, remote data acquisition system, and telemedicine [4]. In all of the above applications, the GSM network represents the link over which digital data are transmitted or received from the far end control unit (the mobile phone) to the end user application (GSM module + µ- Controller + general purposes input/output module + actuators ). Typical Example is shown in Fig. 3 for a proposed home security system. This system enables the far end user through SMS facility to:

1. Monitor the state of his home door and detect any illegal intrusion.

2. Select and change a certain pass-word for key locking the door.

3. Control the home lighting system to give impression for the outsiders that there is anybody inside.

The password may be any 4 characters where their ASCII codes are inserted in the deriving program either using the key pad or by

sending an SMS message from the far end mobile. The intrusion detector is a simple LED (Light Emitting Diode) and an infrared sensor. These two elements are fixed across the door for which an on/off signal can be sent in case of intrusion. Notice that the alarm of an illegal intrusion will be ignored when the program receives the correct password. The control of the lighting system can be performed simply by using voltage controlled power switches connected shunt with the usual on/ off switch of selected rooms and appliances in the house. The control signals of these switches come from port C of the µ - controller as it programmed as an output port.

V. EXPERIMENTAL WORK AND SYSTEM OPERATION

In order to verify the principle of operation of M2M system, two simple applications: on/off lamp control and variable fan control will be implemented and tested, according to the flowchart given in Fig. 2. Fig. 4 shows a block diagram of the main components of the tested M2M system. This figure shows that the M2M engine will receive the signal from the GSM network to control a simple device. This control will be through a PC and the tested device will be connected to M2M engine.

Figure 3. GSM based home security system

The PC will control M2M engine by taking the received signal from the module and process it then send back the appropriate control signal. The simple device can be connected to the PC or the module but it is easier to connect it to the module because there are I/O terminals in the module and can be controlled with AT commands. The required components are as follows:

1. The module.

2. PC.

3. Tested device.

4. SIM card.

GSM Module with RS232C

Far End Control Mobile Phone

GSM link

Intrusion Detector

1-bit

Power Switch drivers & Status signals

Key Lock Control 1- bit

Infrared Sensor

Key Lock Solenoid

Lighting System and Home appliances

ATMEL 89Χ52 µ-Controller

UART Input Output Ports

Level Shifter + RS232C

Connector and Cable

dc power supply

5V+/- 12V

Page 5: 01362503

A. Alheraish: Design and Implementation of Home Automation System 1091

Figure 4. Block diagram of M2M experiment

A. On-Off lamp Control Lets assume that the user wants to control remotely a lamp

(light). The user selects "lamp on" for ON light and "lamp off" for OFF light as control messages. By sending an SMS from a remote mobile to the M2M system, the message will be processed by the M2M system. If the received message is not "lamp on" the system will reject it. But if the message is "lamp on" the lamp will turn on. The lamp will not change until a message "lamp off" is received. The lamp will not be affected if any message is received except "lamp off" which will turn off the lamp.

To implement the operation of this example, we highlight the function of application control stage in Fig. 2. The output of the M2M module is connected through a LED. The LED is connected between pin 20 (analog output) and pin 2 (ground) as shown in Fig. 5. After this connection is made the AT command that makes the analog output voltage of the module (pin 20) high is "at*E2IO=1,"DA1", ,255" where at*E2IO controls the input/output pins and 1 means write (it can be 0 to read the voltage from any external device), "DA1" means the digital to analog converter which is pin 20, and 255 is the maximum voltage at pin 20 which is 2.75 V. The voltage across the pin varies from 0 to 2.75V with 256 steps which means the programmer can choose the amount of voltage from 0 to 255 where zero means zero volt and 255 means 2.75V. The programmer can take the advantage of the steps to control the voltage of the LED and make it work with multilevel amount of light.

Figure 5. The LED connection

In order to control a lamp that operates at higher voltages than 2.75V, which is usually the case, an additional circuit is

needed as shown in Fig. 6. The circuit consists of the following: Transistor, 12V DC power supply, 220 Ω resistance, Relay, and 220 or 110 V light bulb.

Figure 6. The additional circuit connections

B. Variable Speed Fan Control This section describes how to control a multilevel (multi-

speed) fan. The GM47 module supports 256 levels. Three levels are chosen to operate the fan: level 70 for low speed, level 150 for medium speed, level 255 for high speed. The fan works with 12V power supply. The execution of the program is the same as in the previous section but with one modification. This modification is in checking the incoming message. The program decides between four messages "fan low", "fan med", "fan hi", and "fan off" to control low, medium, high speeds, and fan switch off respectively. The output of the module is 2.75V which is not enough to operate the fan properly. In order to overcome this problem, an additional circuit is required as shown in Fig. 6. This circuit amplifies the signal from (0 - 2.75V) to (0 - 12V) to make the fan works with variable speed.

Analog output (Pin 20)

12V DC

Analog ground (Pin 2) and power supply ground

Figure 7. Circuit connection for the multilevel fan

Relay

220 V or 110 V

Analog output (Pin 20)

12V DC

Analog ground (Pin 2) and power supply ground

220 Ω

M2M engine

I/O terminals

PC

Tested Device

Pin 20 (Analog output)

Page 6: 01362503

IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 2004 1092

VI. CONCLUSION This paper examined the design and implementation of

M2M system. The conclusions drawing from this paper are as follows. 1) The M2M system is reliable and can be used using so many technologies such as DMTF, SMS, and GPRS and the designer has to choose the suitable technology for the design. 2) The M2M system is suitable for many applications especially for simple applications. In order to make M2M system suitable for sophisticated applications, the designer has to use microcontrollers, digital to analog converters, and analog to digital converters. 3) This paper shows the use of the M2M system with the aid of the PC, but in order to have a standalone system which has smaller size and portable the designer has to use a microcontroller and download the program to it. 4) The M2M system can be taken as a solution, so the designer has to study the problem and propose the appropriate approach for design any specific application. This means that it is difficult to make a general M2M system to solve all problems.

ACKNOWLEDGMENT The author would like to thank Eng. Saud Alsherahi and

Prof. Abu Al-Ela for their constructive and stimulating comments. The author would also like to thank LM Ericsson in Saudi Arabia, particularly Bo Nilsson ,Dr. Fahad Alzahrani, and Eng. Ahmed Alfifi for their support of this research.

REFERENCES [1] G. Aranguren, L. Nozal, A. Blazquez, and J. Arias, "Remote control of

sensors and actuators by GSM", IEEE 2002 28th Annual Conference of the Industrial Electronics Society IECON 02, vol. 3 , 5-8 Nov. 2002, pp.2306 - 2310.

[2] B. Woodward, H. Istepamian, and C. Richards, "Design of a Telemedicine system using a mobile telephone", IEEE Transaction on Information Technology in Biomedicine, vol, 5, No. 1, March 2001.

[3] Ericsson Telecom Environment, "GM47/GM48 Developer's Kit", Sony Ericsson Mobile Communication International, 2002.

[4] M. Abou El-Ela, "GSM network based PLC system", submitted to 2nd International Industrial Engineering Conference, 19-21 Dec, 2004.

Abdulmohsen Alheraish Assistant Professor of Communications Networks, Electrical Engineering Department, King Saud University (KSU). Received the M.Sc. in Telecommunications from the University of Missouri-Columbia, USA and the Ph.D. in ATM Networks from the University of Strathclyde, Scotland, UK. His areas of interest include performance modeling, quality of service, voice and video over ATM/IP and network design and planning. Currently, he carried out research on wireless communication issues with a focus on home automation; surveillance, and home monitoring. In 2003, He founded machine-to-machine lab at KSU.