This document describes the design and implementation of a home automation system using machine-to-machine (M2M) communication over a GSM cellular network. It discusses the components of an M2M system including the machine/device being monitored or controlled, a microcontroller, and a GSM module. It provides details on using SMS, DTMF, and GPRS for M2M communication and presents a flowchart algorithm for implementing an M2M system using a PC and GSM module. Experimental testing is done to verify the system by controlling a lamp and variable fan speed remotely.
2. IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 20041088
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
3. 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
4. IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 20041090
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
5. 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)
6. IEEE Transactions on Consumer Electronics, Vol. 50, No. 4, NOVEMBER 20041092
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.