3 Main Project From Ch 1
-
Upload
daniel-abara -
Category
Documents
-
view
28 -
download
1
Transcript of 3 Main Project From Ch 1
1
CHAPTER ONE
INTRODUCTION
1.1 What is SMS (Short Message Service)?
SMS is an acronym for Short Message Service. Short message service is a globally
accepted wireless service that enables the transmission of alphanumeric messages between
mobile subscribers and external systems such as electronic mail, paging and voicemail
systems [1]. It is a wonderful technology which makes it possible to send and receive
messages between mobile phones commonly called handsets. SMS first appeared in Europe
in 1992. It was included in the GSM (Global System for Mobile Communications) standards
right at the beginning. The GSM and SMS standards were originally by the European
Telecommunications Standards Institute (ETSI). Now the Third Generation Partnership
Project (3GPP) is responsible for the development and maintenance of the GSM and SMS
standards. As the name Short Message Service suggests, the one SMS message can only
contain 140 bytes (1120 bits) of data which is equivalent to 160 characters if 7-bit character
encoding is used (as in Latin characters like English alphabets), and 70 characters if 16-bit
encoding is used (as seen in non-Latin characters like Chinese which use 16-bit encoding).
SMS messages have support for international languages and works well with languages
supported by Unicode including but not limited to Arabic, Chinese, Japanese and Korea [2].
SMS messages besides text may enable transfer and reception of pictures, ringtones and so
on.
Features of SMS
The number one advantage of SMS is that it is supported by “ALL” GSM mobile
phones, and most pay plans provided by GSM carriers provide affordable plans which
include SMS service. Another distinguishing characteristic of SMS is that an active mobile
phone is able to receive or submit a short message at any time, independent of whether or not
a voice or data call is in progress. The delivery of the short message by the network is also
guaranteed by SMS. Usually, when there is temporary network failure, this failure is
identified and the short message is stored in the network until the destination becomes
available. SMS makes use of low-bandwidth message transfer. Generally, the benefits of
SMS to users are focused on convenience, flexibility and integration of messaging services
and access to data. Hence, a user should be able to use the handset as an alternative to a
2
computer. One downside of the SMS technology is that one message can only carry very
limited amount of data, say 160 characters. Therefore, an extension called concatenated SMS,
sometimes called long SMS was developed. This long SMS can contain more than 160
English characters, by breaking down a long message at the sender‟s mobile phone into
smaller parts, and sending each of these parts as a single (short) SMS message. At, the
destination, the recipient‟s mobile phone will re-assemble the parts into the original long
SMS message [2].
1.2 Basic Elements In SMS Technology
1.2.1 SMS Center
The SMS center, SMSC, is used to handle the SMS operations of a wireless network. When
an SMS message is sent from a mobile phone, it goes to an SMS center first. The SMS center
then forwards the SMS message to the required destination mobile phone. An SMS message
may need to pass through more than one SMSC before getting to its final destination. It is just
like data packets pass through several routers before reaching the required destination
network in a packet switched network technology. The basic duty of an SMS center is to
route or direct the SMS messages and also to keep track and regulate the process. When the
destination is unavailable, the SMSC would usually keep the message and forward it when
the destination mobile phone becomes available. Most mobile carriers have their respective
SMS centers and respective center addresses. This address is usually configured by default in
the SIM card provided by the carrier, and typically is an ordinary phone number. It may be
reconfigured for other carriers if necessary.
1.2.2 Validity Period
There are often times when the recipient‟s mobile phone is unavailable maybe due to network
failure or low battery. The SMS message in such a case is temporarily stored in the SMS
center, and then forwarded to the destination mobile phone when it becomes available. A
time period may be specified within which the SMS message will be available in the SMSC,
before the message is deleted. Hence, after this period, the SMS message will no longer be
forwarded to the recipient‟s mobile phone even if it becomes available. This time period
within which the SMS message is valid in the SMS center and can be forwarded to the
recipient‟s phone is called the Validity Period.
3
1.2.3 Message Submission Report
When an SMS leaves a sending mobile phone, it goes to the SMS center. The SMS center
usually sends back a message submission report to the sending mobile phone to ascertain
whether there are any errors such as incorrect SMS format, low account balance and so on. If
there is no such error, the SMSC sends a positive submission report to the sending mobile
phone else it sends a negative submission report to the sending mobile phone [2]. The mobile
phone then notifies the user that the message submission for sending has failed.
1.2.4 Message Delivery Report
When a sent SMS gets to the recipient‟s mobile phone, the mobile phone will send back a
delivery report to the SMS center to acknowledge receipt of such SMS and inform on any
errors if any. If there are no errors, the report sent to the SMSC would be a positive report
else it would be a negative report. If the mobile phone of the SMS sender was configured to
receive delivery reports, the SMSC would then forward that delivery report to that mobile
phone. If the SMSC does not receive the delivery report within a certain time period, it
assumes that the delivery report has been lost.
1.2.5 Home Location Register (HLR)
The home location register (HLR) is used for permanent storage and management of records.
These records include subscription periods and service profile databases. The SMS Center
checks here for routing information about the indicated subscriber.
1.2.6 Mobile Switching Center (MSC)
This determines the flexibility and switching capability of the entire system. The mobile
switching center carries out the switching requirements. It establishes control between the
SMS system and other data systems on any network.
1.2.7 Visitor Location Register (VLR)
This is similar to the Home location register but unlike the HLR, it stores temporary
information and not permanent information. It is a database consisting of temporary
information about subscribers which the Mobile Switching Center needs in order to satisfy or
service the subscribers.
4
1.2.8 Mobile Station (MS)
This is a wireless terminal which has the ability to receive and send short messages as well as
other voice calls. Short message service makes use of the Mobile application part (MAP),
which defines the rules and mechanisms to be used in communication in wireless networks,
and makes use of the SS7 transaction capability application part (TCAP). The wireless
network infrastructure used in the Mobile station is based on the Signaling system No. 7
(SS7).
1.2.9 Base Station System (BSS)
This is the place where all radio-related activities or operations are carried out. The base
station system is made up of the base station controllers denoted as BSCs and the base
transceiver stations denoted as BTSs. The BSS transmit voice and data traffic between the
mobile stations.
1.2.10 Short Message Entity
This is a device which can be used to receive or send alphanumeric messages such as a
mobile phone or handset. It is the primary source and final destination of the Short Message.
1.3 Signaling Elements Used In SMS
The mobile application part (MAP) layer defines the operations necessary to support the short
message service. Bothe American and international standards bodies have defined a MAP
layer using the services of the signaling system No. 7 transaction capabilities part. The
international standard is defined by the European Telecommunication Standards Institute and
is referred to as GSM MAP, while the American Standard is referred to as IS-41 and is
published by the Telecommunication Industry Association [1]. The following MAP
operations are necessary to provide the end-to-end short message service.
1.3.1 Point-to-point Short Message Delivery
This signaling mechanism makes it possible for the SMS center to transfer short messages to
the Mobile Switching Center (MSC) which serves the addressed mobile station and in turn
attempts to deliver the message to a Mobile Station whenever it is registered. This operation
works together with the base station subsystem while the message is being forwarded from
the Mobile switching center, to the Mobile station. The outcome is either success, if the
5
message is delivered or failure, if the message is not delivered. The point-to-point short
message system is made possible using Short Message Delivery Point-to-point (SMD-PP)
and forward Short message mechanisms catered for in IS-41 and GSM respectively.
1.3.2 Routing Information Request
To send and deliver short message, the SMS center needs to obtain the necessary routing
information to determine the service Mobile switching center for the mobile station used at
the time of the delivery attempt. This is made possible by accessing information from the
Home Location Register, using the SMSrequest mechanism of IS-41 and
sendRoutingInfoForShortMsg mechanism of GSM.
1.3.3 Short Message Waiting Indication
This signaling operation is very useful and comes to play when a short message delivery
attempt to the SMS center is negative, that is, it fails. The short message waiting indication
provides a means for the SMS center to request the Home location register to add it (the SMS
center) to the list of SMS centers to be informed when the indicated mobile station becomes
accessible. This short message waiting indication is achieved using SMS notification
indicator mechanism in IS-41 and set message waiting data mechanism in GSM.
1.3.4 Service Center Alert
The service center alert functions as a means for the home location register to tell the SMS
center which has previously initiated unsuccessful short message deliver attempts to a
specific mobile station, that the mobile station is now recognized by the mobile network to be
accessible. It is made possible by the use of SMS notification mechanism in IS-41 and alert
service mechanism in GSM.
1.4 Applications and Advantages of SMS Technology
Most of the applications of SMS technologies are direct consumer applications. However,
there are also some corporate applications of SMS technologies. These applications of SMS
are detailed as follows.
6
1.4.1 Simple Peer-to-peer Messaging
Most often people interact with one another using short messages usually to say hello,
arrange meetings, to pass around information and so on. Users usually find it more
convenient to use SMS than email when they need to send short quick information among
mobile users due to the fact that mobile phones most times will be close to the user, often in
his or her pocket. Hence, the recipient receives and makes use of the message within a very
short while after it is sent by the sender. This application of SMS is popular with young
people who are willing to learn how to user new technologies.
1.4.2 Provision of Information
SMS can be used to broadcast a lot of information on request to users. This information may
include share prices and quotes, scores and results from sports, weather forecasts, news
headlines, jokes and tips and many others. Usually, a user would send a request for particular
information from his or her mobile phone let‟s say health tips. This information requested (in
this case, help tips), is composed into a short message, which is delivered to the user as
requested. Also, unrequested information may also be sent to users, usually in the form of
advertisement of a product or service to be offered.
GSM carriers, companies and banks also use SMS for providing customer service
related information to their clients when necessary whether requested or not. In vehicle
positioning, Short Message Service is used to send the co-ordinates (longitude and latitude)
which correspond to a vehicle‟s location via GPS (Global Positioning System). This
integrates satellite positioning systems that tell people where a vehicle is on the surface of the
earth [3].
1.4.3 Remote Monitoring
SMS can be used to manage appliances and machines in a distant or remote environment.
This makes it possible to remotely control these appliances and machines by the use of
specific instructions place in SMS messages or to receive fault alert messages from these
appliances. The information is automatically delivered at the receiving device without any
human or physical presence. Examples of such systems are remote meter reading, remote
control of devices, fault alert systems etcetera.
7
Advantages of Short Message Service
The advantages of SMS technology include but are not limited to the following:
(a) The storage and forwarding mechanism is very useful when a recipient is unavailable,
because it helps to prevent unnecessary loss of relevant information.
(b) Short Message Service provides an effective, reliable and low-cost communication
method for short message delivery.
(c) Simultaneous message delivery to multiple subscribers is possible hence one can send
short messages to more than one person at the same time.
(d) Short message service can easily be integrated with internet based (web) applications
and other data applications or systems to achieve several purposes.
Limitations of Short Message Service
Although SMS has many advantages, there still exist some limitations of its use, these
limitations include the following:
(a) The ideal message length for simple SMS text messages is 160 characters only and
nothing more.
(b) SMS ideally does not support audio or graphics; hence we have MMS which is
similar to SMS which includes the audio and graphic technologies.
(c) The storage and forwarding mechanisms of SMS although very useful, makes it
unusable for WAP applications.
(d) The signaling channel used for SMS is also used for other purposes; this somehow
reduces the message transmission data rate.
1.5 Introduction To GSM Modems
What is a GSM Modem?
GSM is an acronym for Global System of Mobile Telecommunication. A GSM modem is a
wireless modem that makes use of a GSM wireless network for its operation. A normal
wireless modem is similar to a dial-up modem. The main difference between them is that a
dial-up modem sends and receives data through a fixed telephone line while a wireless
modem sends and receives data through radio waves (wireless technology) [2].
A GSM modem may be an external device or a PC card, also called PCMCIA card.
Usually, a GSM modem is connected to a computer through a serial cable or a USB cable.
The modem in form of a PC card is designed to be used with a laptop computer and should be
8
inserted into one of the PC Card slots of the laptop computer. A GSM modem requires a SIM
card from a wireless carrier or service provider in order to function just like a GSM mobile
phone. It is a hardware component that allows the capability to send and receive SMS to and
from a system. The communication with the system takes place through RS232 serial port. A
GSM modem could be the traditional PCMCIA card or a mobile phone but the use of mobile
phones limits the hardware functionality.
1.5.1 GSM Modem Versus Mobile Phone
Which is better, Mobile phone or GSM Modem? Usually, GSM modems are recommended
for use with a computer to send and receive messages. This is because some mobile phones
are limited in some ways compared to GSM modems. Some of these limitations are as
follows.
Firstly, some mobile phones (example: Sony Ericsson R380) cannot be used with a
computer to receive concatenated SMS messages. As explained earlier, concatenated
messages are those which contain more than 140 bytes of data, which is the normal capacity
for simple messages.
Secondly, many mobile phone models cannot be used with a computer to receive
Multimedia messages (MMS), (messages that include video, pictures and audio). This is
because when they receive a MMS notification, they handle it automatically instead of
forwarding it to the computer [2].
Thirdly, many mobile phones do not support some AT commands, command
parameters and parameter values. As we may think, GSM modems support a more complete
set of AT commands than mobile phones.
Also, most SMS-relying applications have to be available 24hours a day. For instance,
and SMS messaging application that provides audio downloading services as the ones used in
download of latest ringtones should always be online such that the user can never experience
downtime. If such applications use mobile phones to send and receive SMS messages, then
the mobile phones would have to be switched on all the time, which means the battery will
have to be charged all the time.
Besides the above problems, mobile phones and GSM modems are more or less the
same for sending and receiving SMS messages from a computer, or another mobile phone.
There is not much difference between mobile phones and GSM modems in terms of SMS
transmission rate, since the determining factor for the SMS transmission rate is the wireless
9
network. For this project, a Sagem MyX5-2 mobile phone is used and is sufficient for the
required functionality of the system.
1.5.2 Things To Consider When Using GSM modem or Mobile Phones
For safety of the system where these devices are integrated, the following are some
precautions that should be taken.
1. Modems generate audio frequency (RF) power hence care must be taken on safety
issues related to RF interference as well as regulations of RF equipment.
2. Mobile phones should not be used in scenarios dealing with aircraft, petrol stations or
other places that may lead to hazard or where the GSM products are prohibited.
3. When integrating such system for vehicle control, check for any regulation or law
authorizing the use of GSM in vehicles in your country before installing the modem.
Also, qualified personnel should carry out the installation after consulting the vehicle
dealer for any possible interference with electronic parts/devices in the car.
4. If used in a car automation system, the GSM modem/mobile phone should be
connected to the vehicle‟s supply system by using a fuse-protected terminal in the
vehicle‟s fuse box.
5. To ensure longer life-span of the GSM modem/mobile phone, do not expose the
modem to extreme conditions such as high humidity or rain, high temperatures, direct
sunlight, harsh chemicals, dust or water.
6. When using modems especially traditional GSM modems, avoid disassembling or
modifying the modem, there is no user serviceable part inside the modem. In case of
problem, please contact authorized dealer.
1.6 General Concept
The principle used in this design is centered on Short Message Service (SMS). The SMS
signal is transmitted through GSM wireless network from a mobile phone which acts as a
transmitter, to another GMS mobile phone on the system itself, which acts as the receiving
modem. The receiving mobile phone converts the received signal to binary which is sent to a
microcontroller via serial communication. The microcontroller is programmed to control
some given loads based on the signal received from the transmitting mobile phone.
10
1.6.1 Serial Communication
Serial transmission technology is increasingly used for the transmission of digital data. A
large number of up-to-date communications networks apply serial transmission. The
numerous applications include computer networks for numerous applications office
communications, building and manufacturing automation systems, internet and ISDN
(Integrated Services Digital Network, which is a system of digital phone connections which
has been available for over a decade. This system allows voice and data to be transmitted
simultaneously across the world using end-to-end digital connectivity).
Serial data transmission implies that one bit is sent after another (bit-serial) on a
single transmission line. Since the microprocessors in the devices process data in bit-parallel
mode, the transmitter performs parallel-to-serial single line conversion, while the receiver
performs serial to parallel conversion. [4]. See fig. 1 for more details.
Fig. 1.1 Simple 2-wire line for bit-serial transmission. [4]
As can be noted from above, serial communication is a process of sending data one bit at a
time, sequentially, over a communication channel or computer bus. This is in contrast to
parallel communication where several bits are sent as a whole, on a link with several parallel
channels. It is mostly applied for all long-haul communication and most computer networks,
where cost of cable and synchronization difficulties makes parallel communication
impractical.
1
2
3
4
5
6
7
8
8
7 6 5 4 3 2 1
8
7
6
5
4
3
2
1
8
7 6 5 4 3 2 1 8-bit unit 8-bit unit
2 lines
Transmitter Receiver
8,7,6,5
4,3,2,1
11
Transmission Standards:
The various coding techniques define how the binary states are represented, that is, how the
signal states change during the transmission of a serial bit flow. These specifications are
frequently adopted by - mainly internationally standardized - transmission standards. In the
field of communications, the interface specification have been defined by the ITU
(International Telecommunication union) or adopted from other standards. Out of these
standards, the one of interest which is used frequently for computer and control applications
is the RS232 or V.24 serial interface. This is also used in this project. This is applied in point-
to-point connections between two devices. The complete specification for four-wire full-
duplex transmission as well as definitions for the handshaking line is presented in the US
standard RS232C, or in the almost identical international standard ITU-T V.24. [4].
1.6.2 Introduction to AT Commands
AT commands are instructions which are used in controlling modems. AT is the abbreviation
for „Attention’. Every command line starts with “AT” or “at”, hence modem commands are
called AT commands. Many of these commands which are used to control wired dial-up
modems, like ATD (that is, Dial), or ATA (that is, Answer), are also supported by GSM
modems and mobile phones. Besides these general command sets, GSM modems and mobile
phones support another AT command set which is specific to the GSM technology, which
includes SMS-related commands like AT+CMGS (Send SMS message), AT+CMSS (Send
SMS message from storage), AT+CMGL (List SMS messages) and AT+CMGR (Read SMS
message). The “AT” prefix informs the modem about the start of a command line. It is not
part of the AT command name in AT+CMGS, +CMGS is the actual AT command name. [2].
These commands are applied in this work for reading SMS, getting SMS notification and
more. It is used together with Assembly language coding scheme. This is used in the
programming of microcontrollers. Some tasks that can be achieved using AT commands with
a GSM modem or mobile phone are:
(i) To get basic information about the mobile phone or GSM modem. For instance, name
of manufacturer (AT+CGMI), Model number (AT+CGMM) and lots more.
(ii) To get basic information about the subscriber like MSISDN (AT+CNUM).
(iii)To get information about the mobile phone such as mobile phone activity status
(AT+CPAS), radio signal strength (AT+CSQ), battery level and battery charging
status (AT+CBC) etc.
12
(iv) To establish a data connection between two peers or a connection to a remote modem
(ATD, ATA etc.).
(v) To send (AT+CMGS, AT+CMSS), read (AT+CMGR, AT+CMGL), write
(AT+CMGW) or delete (AT+CMGD) SMS messages and obtain notifications of
newly received messages (AT+CNMI).
(vi) To read (AT+CPBR), write (AT+CPBW) or search (AT+CPBF) phonebook entries.
(vii) To save and restore configurations of the mobile phone or GSM modem. For
instance, save (AT+CSAS) and restore (AT+CRES) settings related to SMS
messaging such as the SMS center address.
Usually, the mobile phone manufacturers do not implement all AT commands, command
parameters and command values in their mobile phones. Also, some AT commands require
the support of mobile network operators.
1.6.3 Microprocessors and Microcomputers
It is no exaggeration to say that microcomputers and microprocessor have revolutionized the
electronics industry and have made wonderful impacts in our lives. The development of
extremely high service Integrated Circuits has greatly reduced the sizes and costs of
microcomputers which designers routinely consider in using their power and versatility in a
wide variety of products and applications. [5]
1.7 Objective of the Project
The primary or main objective of this project is to design and fabricate a GSM based
automation system using Short Message Service (SMS) from mobile phones.
1.8 Scope of this Work
This project work entails the design and construction of an automation system using Short
Message Service (SMS). It is limited to the availability of GSM (Global System of Mobile
Telecommunication) network coverage over the area of control. The project further caters
primarily for the control of home based appliances such as light bulbs, fans.
13
1.9 Significance of Project
The significance of this project is that is makes a fully integrated, versatile, intelligent home
system that eases the user‟s decision for operation of home appliances. Apart from the control
of these appliance locally or physically, the home owners are able to operate or control them
remotely while they are away from home. It will benefit the people who always leave their
home for outstation duty or those who are always travelling. It will also be helpful for a
family who are going for a long vacation especially during festivities.
14
CHAPTER TWO
OVERVIEW OF HOME AUTOMATION SYSTEMS
2.1 Household Automation
Home automation is the residential extension of building automation. It is the automation of
the home, housework or household activity [6]. By definition, automation refers to the
automatic operation or control of equipment, a process, or a system without conscious
thought. It also can be defined as the use of computers to perform tasks previously performed
by people. The home automation is one that provides a comfortable and productive
environment via automated control systems such as fire safety, security and energy or
lighting management. This reflects the evolution from energy management systems in which
a central computer was used to control the building services. According to Bill Gates, home
automation is predicted to become a boom industry by technology pundits. It can provide
additional time for recreational pursuits; monetary savings through power management and
peace of mind that valued homes and contents are being monitored 24 hours a day. For
elderly or disabled people, home automation would provide them more advantage and give
them more fulfillments with their appliances since they can achieve their hearts desires with
ease.
The concept of automation has existed for many years. It began with a student
connecting two electric wires to the hands of an alarm clock in order to close a circuit of a
battery and light bulb. Later, companies developed automated systems of their own to control
alarms, sensors, actuators and video cameras and in so doing, created the first automated
buildings [7].The term “intelligent systems” or “intelligent home” followed. Due to the
obvious advantages of these systems, their influence on the conventional home was
predictable and finally, in 2988, the term domotics was coined. Domotics is the application of
computer and robot technologies to domestic appliances. Domotics is a portmanteau word
formed from „domus‟ (a Latin word which means house) and „robotics‟. A modern definition
of Domotics could be the interaction of technologies and services applied to different
buildings and structures with the purpose of increasing security, comfort, communications
and energy savings [7].
At the beginning, automated devices were independent or, sometimes grouped in
small independent systems. The idea of giving them some operability among each other using
a common language keeps developing, consequently following such idea; the first Home
15
automation systems (HASs) appeared bringing a new concept of a home network full of
possibilities. However, there were also some new factors to bear in mind. A strong reason for
Home automation systems are becoming popular because they are so many attractive features
that can easily lure companies to enter quickly into this emerging market. HASs also
represent a great research opportunity in creating new fields in engineering, architecture and
computing [7]. It should be noted that these new technologies are still in their early stages
with a lack of robust standards creating compatibility issues affecting their reliability.
Another problem is that these systems are not always fully accepted by final users, especially
the old and disables, which even need it the most. As an example, one effort to make these
systems usable and affordable by any user helped the use of old, cheap and simple
technologies like the X-10 protocol to transfer data in the home-network. Relatively, this
approach created low cost HASs.
There are many recent tendencies to integrate various kinds of embedded devices and
consumer appliances into software systems, tendencies that have emerges from the ideas of
pervasive computing. This evolution offers many useful possibilities in Domotics. Lately, it
is being proved that Domotics has many interesting fields, and among them, using remote-
controlled Home automation systems to control the home network is one of the most
challenging. The possibility of having ubiquitous access to many devices within a building at
anytime from anywhere, resolves many of the problems that users often face when they
return home, saving significant amount of time. It also notably increases the security in any
kind of building and it may even provide a backup control system for local system
breakdowns [7]. This access could be achieved from many different digital devices and it is
known that the network hierarchy has been rapidly moving lower in the chain towards
smaller and more personal devices [8]. Considering these latest tendencies, everything points
at prompt remote control standardization in home networks.
Recently, with the explosive growth of the internet and telecom technology, home
automation is experiencing an accelerating growth based on different kinds of residential
network. There exist several types of transmission media for residential installations such as
radio and microwave etc. Compared to many other methods of transmission, the GSM
wireless transmission has a good advantage in setting up a home automation system without
installation of many additional devices, with relatively low cost.
16
2.2 GSM Control Systems
(i) GSM/Mobile/Cell phone based device monitoring and control system: This system
monitors and controls any digital or analog devices from a cell phone. It can be used to
control up to 16 electrical devices. With the circuit, it is possible to switch ON or OFF, or
restart some Linux servers, modems, printers, door and electrical locking devices, irrigation
pump, garage door, house lights, water pumps. As every automation system, it makes human
life easier and better.
(ii) GSM Based Automation Irrigation Water Controller System: This system is designed
to send SMS alerts whenever the electrical power status changes to ON or OFF. The mobile
phone can be used to switch ON or OFF the water pump from any location in the world.
(iii) GSM based remote monitoring and control of digital energy meter: This is useful for
remote meter reading. It is such that the power supply can be disconnected in an event of
non-payment of electric bill.
(iv) GSM Based Highway vehicle traffic monitoring system: The purpose of this project is
to monitor the vehicles moving on highways at remote locations. It counts the number of
vehicles passing on both directions using infrared and laser sensor system. It makes use of a
microcontroller to store the vehicle count. The information can be sent periodically or by
demand to the user via SMS.
(v) Ezy Switch: This can be used to remotely control and monitor your heating, security
systems and domestic/commercial appliance. Ezy switch is a simple switch control design
that connects to electrical devices. It your equipment can be switched ON or OFF, it can be
controlled from a mobile phone with Ezy switch. It can take up to 8 monitored devices and 4
power controlled devices. It can be integrated in domestic systems, security systems (for
controlling alarms, light sensors), heating and ventilation systems, agriculture (to remotely
control milk sheds, water pumps, monitor fuel tanks and irrigation equipment. The block
diagram of the Ezy switch system is as shown on the following page. [9]
(vi) Control of Remote Domestic System Using Dual Tone Multi Frequency (DTMF):
This method uses a system of control using Dual tone Multi Frequency from mobile phones.
17
It makes use of a mobile phone to transmit the DTMF signals and a receiver to receive them.
A decoder typically IC 8870 is used to decode the DTMF signals and then pass them to a
microcontroller which is interfaced with the necessary loads. The block diagram of this
system is given below.
Fig. 2.1: Block Diagram of DTMF Remote Control System [10]
2.3 Smart Homes Today
The “smart” concept has become a marketing catchword, still employed today, to sell a wide
range of products; hence we have smart phones, smart cameras, smart design and lots more.
However, sometimes marketing buzzwords alone cannot guarantee the sell. Xanadu was the
first example of a mass-produced smart home. It was built throughout the 1980s in the US
around the original EPCOT idea; these houses were commercially built dwellings that made
extensive use of smart home technologies. The Xanadu home had a computer that monitored
and controlled all its systems, the kitchen, living room, bathrooms, and bedrooms with all of
them having their own electrical and electronic devices to control the appliances present in
the house. [11]. The house was eloquently described as Xanadu: The Computerized House of
Tomorrow and its peculiar appeal were set by the advert: a house with a brain, where every
room adjusts automatically to match your changing moods.
Tansmitter (mobile phone)
Receiver (mobile phone)
Channel
Condenser Microphone
Audio amplifier
Decoder IC 8870
Microcontroller
Relay – to control devices
18
Fig. 2.2: Picture of a Xanadu House [11]
As the time moved on, and most of the houses were still unsold, the technology contained
soon became obsolete. The Xanadu houses started being demolished to make space for more
“commercially viable” projects and by October 2005, they were all gone. Even with the
commercial setback, the concepts of the Xanadu homes were sound and a combination of
elements such as computers, robotics and artificial Intelligence (AI) were to push the Smart
Home concept further, even if sometimes only in research laboratories [11]. Several ideas
provided great indication that the technology may have been finally mature enough to deliver
commercially viable solutions for instance, a device named Waldo, which interfaced with an
Apple computer, could use voice recognition and speech synthesis technology to control
appliances.
Today, several projects funded by universities and the industries alike are still
investigation the possibilities that smart homes can offer. Some of the projects based on
Smart Homes are enumerated as follows:
(a) CISCO Internet Home – This project aims at investigating the benefits of a high-
speed, always available internet connection which will enable an array of consumer
devices and appliances in the home. It was developed in conjunction with leading
19
consumer companies. It further demonstrates how the internet can enhance daily
living for consumers in the home and communities, for the future.
(b) MIT House – This is led by a multi-disciplinary team composed by architects,
computer experts, engineers and behavioral scientists who investigate key issues and
what services could be offered in the home of the future. The main focus of this is on
the design of the home and its related technologies, products and services, in order to
see how they can evolve to meet the opportunities and challenges in the new home.
(c) Microsoft Research EasyLiving – This Started in 1998, EasyLiving is a project
funded by Microsoft research, and it is about creating an intelligent environment that
will make computing more accessible and more pervasive that today‟s desktop
computer. Its goal is to develop prototype architecture and technologies for building
intelligent systems and environments which facilitate people interaction with other
people, computers and other devices.
(d) UMASS intelligent home project – This project from University of Massachusetts
makes use of simulations of agent-based intelligent systems that also use robotics in a
domestic context.
(e) Adaptive House - This project, led by University of Colorado, is to develop a smart
home system that programs itself by observing the lifestyle and desires of the
inhabitants, and by learning to anticipate and accommodate their needs.
(f) Duke Smart home Program – This is Duke University‟s dynamic „living laboratory‟
environment that contributes to the innovation and demonstration of future residential
building technology. The pivoting concept of this project is the belief that smart
homes can improve the quality of life for people of all ages and incomes.
(g) Aware Home Research Initiative (AHRI) – This is an interdisciplinary research
project held at Georgia Tech and is aimed at addressing the fundamental technical,
design and social challenges presented by such questions by using off-the-shelf and
state-of-the-art technologies.
(h) CENELEC Smart Housev - Funded by the European Committee for Electro Technical
Standardization (CENELEC), the aim of this project is to grow and sustain
convergence and interoperability of systems, services and devices that will provide
citizens with access to increased functionality, accessibility, reliability and security
that a Smart House, with common and open architectures, can deliver [11]
20
2.4 SMS Mobile Control System Architecture
The receiver phone is integrated with a microcontroller (eg. PIC16F873A, AT89C52)
which receives SMS message from the transmitter mobile phone and sends a command to
control the output. The system utilizes a low cost microcontroller that is currently available in
the market, and the system makes use of both hardware and software to give required results.
The sequence of events that takes place for the working of the system is as follows:
(a) The remote user sends text messages (SMS) including the necessary commands to the
receiver mobile phone.
(b) The receiver mobile phone receives messages sent from transmitter mobile phone.
(c) The receiver mobile phone decodes the received message and sends the commands to
the microcontroller.
(d) The microcontroller acts on the received commands to control the needed outputs.
Such a system uses the following technologies:
Cellular phone, Networks and Communication Protocols: The widely available networks
are based on GSM. GSM provides a wide coverage area existing in many countries and
locations of the world and can be utilized more cost-effectively for such system. The
communication protocols which can be used include Dual Tone Multi Frequency, DTMF,
Short Message Service, SMS etc. SMS is the most efficient communication protocol. A
mobile phone or cellular device is necessary to create and transmit SMS or DTMF.
I/O Interfaces between Microcontroller and devices: Serial or parallel I/O ports will be
considered for to connect the GSM mobile phone receiver and the Microcontroller. Using the
microcontroller, a control circuit will be implemented to control the electrical appliances such
as lighting points, fans and many others. The Figure 4 below gives the general architecture of
a mobile control system using SMS, to control devices like Air conditioner, lighting points
and security devices.
21
Fig. 2.3: Block Diagram of System [9]
2.4.1 Microcontroller System
The microcontroller is a microcomputer with provisions for input and output
embedded in it. It has all the components of a microprocessor packaged or embedded on a
single chip. It consists of timers, Analog to Digital converters (ADCs), Universal
Synchronous Asynchronous Receiver Transmitter (USART) and others. It is an 8-bit device
with a flash memory which can be erased and rewritten hence it is called Electrically
Erasable Programmable Read Only Memory (EEPROM). The instruction set varies from
microcontroller to microcontroller. The three major features of the controller are:
(a) To receive instructions and decode them to give device address and command for the
device, then send corresponding signals to the driver circuit or actuator.
(b) To ensure dual independent action – device ON or OFF.
(c) To provide feedback status of any device or devices under control whether ON or
OFF.
2.5 Market for Remote Control Systems/Smart Homes
The 20th
century introduced a dramatic revolution in domestic technology which
culminated with the emergency of the remote controlled or smart home concept. However, in
many cases, the research carried out for smart home systems has been focusing more on the
technical possibilities with little consideration of the social aspects or the actual needs of the
22
potential user [11]. Hence these systems seem to be stuck in the early adopter phase of
Roger‟s technology Adoption lifecycle.
Fig. 2.4: Roger’s Technology Adoption Lifecycle [11]
A survey carried out for the UK-based Joseph Rowntree Foundation in 2000 reported that we
may be close to a change of attitude where home remote control systems or smart home
systems may soon become popular and widespread. Many of the people interviewed stated
their interest for a technology that would save time and effort in their home. The research
further outlined concerns about how complicated such a system might still be to operate. It
was also suggested that the young people would be more in favour of such technology that
elderly people, due to their degree of familiarity with modern computer systems [11].
A similar study identifies other types of users who could benefit from this technology.
Similar studies identify other types of user who could benefit from home remote
control systems and smart systems. The relatively recent concept of networking opens new
opportunities for professionals to work from their homes. These individuals may spend more
time in their homes and become more interested in taking advantage of the potential benefits
of the home automation or smart systems.
2.5.1 Potential Benefits
The ability to monitor and control all the devices in the home from a central location
can introduce time-saving benefits. Furthermore, over half of the participants of a survey
reported that they would welcome a new technology that would save time and effort in their
homes [11]. An effective smart home or home remote control system may be able to make
23
complex decisions that are likely beyond the technical expertise of the inhabitants of the
house, for example, an expert system built into a smart home system could contain a detailed
knowledge of thermal systems, of human physiology and other house installations and be
able to determine the optimal choice of temperature and humidity based on the information
received by the thermometers and humidity sensors located inside and outside the house. It is
anticipated that smart homes of the future will be able to integrate all heating, air
conditioning, lighting, home entertainment, and security systems together. Although safety,
security and centralized control are the main requirements, the result of this integration
together with modern networking technology, will open new possibilities that may not exist
today. The able represents the following areas where home remote control may exist today.
Table 2.1: Examples of Smart Home appliances [11]
AREA EXAMPLES
Welfare Health and monitoring, remote diagnosis, remote personal trainer
Entertainment Music television and video downloading
Environment Remote control of lighting, heating/air-conditioning, energy
usage and costs.
Safety Alerting of problems eg. Gas leaks and so on.
Communication Video phone, calendar reminders, communication inside and
outside home
Appliances Self-diagnosis or problems, and assistance in their operations,
automated food ordering.
Studies have demonstrated how mobile phones and short message service (SMS) messages
have become a popular way to keep in touch and how this can increase the sense of safety
and connectedness among family members [11]. These benefits may be further expanded by
integrating this mobile communication network now composed also by other devices and
hand-held computers.
Finally, smart home and remote control systems can increase the quality and facilitate
the life of people with disabilities. Today‟s digital controls and communication systems can
already allow health and support services to carry out routine diagnostics, monitoring and
basic services while allowing the person to remain comfortably at home.
24
CHAPTER THREE
DESIGN CONSIDERATIONS
3.1 System Specification
The digital IC used in the design and implementation of GSM based automation
system using SMS is AT89C51 microcontroller. The voltage requirement for it is +5v. This
+5v is supplied to the controller from the power supply unit with a 7805 regulator IC. For the
12v d.c relay that is used in the output interface, the voltage required to switch it is +12v and
this is tapped from the unregulated voltage of the power supply. The alternative to this way is
to connect another 12 volts regulator at the input of the unregulated voltage to get exactly 12
volts. Other components used are ULN2003A (output driver), BC337 (transistor), Sagem
mobile phone (receiver). Each of them requires +5v d.c to function. The step-down
transformer that is used for the power supply is 240v a.c to 12v a.c with the current rating of
800mA. The system‟s main features are summarized in table 2.
Table 3.1: System’s main features
ITEM CONTENT
Controller IC AT89C51 microcontroller
Text Format Alphanumeric
Power supply 11-20V d.c/220V a.c
Receiver modem Sagem phone
The hardware subsystem is made up of the input interface, the output interface, the
feedback and the control system.
3.1.1 The Input Interface: The input interface comprises of a GSM mobile phone as
transmitter and a GSM mobile phone as receiver, with the GSM network coverage acting as
the bridge between them, and the serial connection between the receiver mobile phone and
the microcontroller.
The ready indicator indicates when the system is ready to receive signals after
initialization.
25
Choice of GSM Network/Mobile Phone
The GSM network was used as the medium and the Sagem phone for the following reasons:
(a) The GSM network has wide coverage over several locations
(b) Most GSM mobile phones have the ability to send and receive short messages (SMS)
which is very important for this system.
(c) The chosen sagem phone is easily made to be compatible with RS232 standard serial
connection and is capable of sending and receiving attention (AT) commands.
(d) The GSM network is relatively fast and reliable.
Choice of Microcontroller (AT89C52)
The microcontroller has the following desirable features:
(a) It supports multilevel programming
(b) It has fast response time
(c) It has 32 input/output ports.
(d) It has serial communication capability
(e) It has enough memory space (4k)
(f) It is cheap and easily available
(g) It has relatively low power consumption.
3.1.2 The Output Interface
The output interface is made up of the ULN2003A driver and the necessary relay devices
rated 12volts each. The loads to be controlled or operated by the system are 4 loads.
26
Fig. 3.1: Section showing the output devices
Fig. 3.2: Output Section showing ULN2003A coupled to the output devices
27
Choice of 240V/10A Relay.
The load rating is 100w, 220v. But power, P = I x V - - (i)
Thus current, I = P/V = 100/220 = 0.45A
Thus the relay meets the current and voltage requirement of the load
Choice of Transistor BC337
The resistance of relay coil = 400Ω (given)
From Ohm‟s law, V = IR, - - - - - (ii)
where I = current, R = Resistance,
Hence, Current, I through the coil = V/R = 12/400 = 30mA
The transistor BC337 can handle this current very well (its hfe = 200 typical)
From kickoff‟s voltage law:
Vcc – IbR2 – Vbe = 0 - - - - - (iii)
For silicon transistors, Vbe = 0.7v
5 – 0.7 = IbR2, 4.3 = IbR2
But Ib = Ic/hfe - - - - - - (iv)
Where Ic = transistor collector current=800mA
And emitter forward current gain, hfe = 200
Ib = 0.8/200 = 0.004A
R2 = 4.3/Ib = 4.3/0.004
R2=1kΩ
Choice of the Freewheel Diode, 1N4001
The free wheel diode D1 protects the transistor from inductive click of the relay. The peak
inverse voltage of 1N4001 = 50v. These are well above 30mA and 12v.
28
3.2 The DC Power Supply
The block diagram of the power supply is shown in figure 5.
Fig. 3.3. Block Diagram Of The Power Supply
3.2.1 Power Supply Requirements
For one to determine the power supply requirements of the entire system, it is necessary to
analyse the current and voltage requirement of the loads and various components used in the
systems design. This will also aid in calculation of entire power requirement of the system.
Table 4.7 shows load , current and power analysis of of the system
Table 3.2 load, current and power analysis of the system.
S/N Component Voltage
Requirement,
V(volt)
Current
Requirement,
I(mA)
Power
Requirement
V x I(mW)
3 AT89C52 5 20mA x 22=
440
2200
5 12v relay 12 30 360
6 Sagem 5 30 150
Step down
transformer
Rectification
Filteration
Regulation
Regulated
output
voltage
29
Phone
10 LEDs 5 10 50
11 Loads 220ac 0.455ac 400w
Maxmum dc
Voltage = 12v
Ac voltage
= 220v(typical)
Total dc
Current
= 510mA
Total dc power
Consumption
= 2705mW.
Total ac power
Consumption
=400W
From the calculations above in Table 3.2, the powe supply must have the following
specification:
i d.c current of 510mA
ii d.c voltage of 12v and 5v.
iii a.c voltage of 220v
iv a.c current of 0.455amp
Transformer Consideration
240/12v, 510mA step down transformer is required. The transformer that is next to 240/12v,
500mA, is 240/12v, 800mA.
Rectifying Diodes Consideration
The rectifier diodes must be able to withstand 510mA and inverse voltage of 12v. IN4001 is
chosen because it has forward current of of 1amp and peak inverse voltage (PIV) of 50v.
Filter Capacitor Consideration
It can be shown that for a full wave bridge rectifier that
dV = load current(I)/2fc, where
dV = ripple voltage
30
f = frequency of the mains supply = 50Hz
C= capacitance of the filter capacitor
Now, let dV be 3v,
Then C = I/(2fdV) - - - (v)
= 0.51/(2 x 50 x 3) =~ 1700uF.
A standard value that is closest to this value is 2200uF.
The capacitor must be able to withstand 2times of the transfomer voltage,
i.e 2 x 12 = 24v.
Thus we 2200uF,25v capacitor
Regulator Consideration
The system requires regulated 5v and unregulated 12v. The current requirement is not more
than 1amp. Thus 7805(5v regulator), will serve the purpose.
31
Fig. 3.4 Circuit diagram for Remote Control
RECEIVER PHONE
4B
5B
6B
7B
P3.0
P3.1
RECEIVER PHONE
P1.0
P1.1
P1.2
P1.3
AT89C52
4C
5C
6C
7C
COM
L1
L2
L3
L4
12v
12v
12v
12v
RL1
RL2
RL3
RL4
+Vcc
1k
1k
1k
1k
GSM NETWORK
31
40
Vcc
12v
1k
Vcc
P3.2
32
3.3 The Software Subsystem
3.3.1 Algorithm:
Step 1: Start
Step 2: Phone Initialization and ready indicator
Step 3: Check phone for any received SMS
Step 4: If new SMS is received, goto step 5, else goto step 3.
Step 5: Identify loads to be switched OFF/ON, and perform required option.
Step 6: Verify that the required operation is performed, if yes, goto step 7, if no, goto step 5.
Step 7: End and go back to step 1.
From the algorithm, the flow chart was developed as shown in Fig. 3.5
33
See appendix I for Assembly code.
Fig. 3.5 Flow chart of the switching
Start
Initialize the System
Check for any received SMS
Is there Any
SMS?
Identify the loads to be operated and
perform the action
Has the action
been performed?
End
NO YES
NO YES
34
CHAPTER FOUR
CONSTRUCTION PROCEDURES
4.1 Purchasing and Preparation of Components
To implement this project, a market survey had to be carried out to ascertain the availability
and affordability of the components and materials. Furthermore, component cost estimate
was done before any purchases were made so as to guide against unnecessary purchase and
waste of resources. As part of the other components to be purchased, two SMS enabled
mobile phones; an RS232 standard serial cable and 2 SIM cards were also purchased.
4.2 Installation and Soldering
The components were arranged in compliance with the circuit diagram of the system, and
installed on the Vero board. The pins were well put through the pin holes on the board to
avoid mechanical faults. A soldering iron and soldering lead was used to solder the pins to
the board and to another pin contact where necessary. Care was taken while soldering the
components so as not to short any of them or over heat them.
The SIM cards were installed in the two mobile phones by taking off the back panel
of the phone, removing the battery and placing the SIM in the slot provided. The RS232 cable
was used to connect the SMS-receiving mobile phone to the microcontroller.
The test loads (4 loads) were placed on a separate wooden board and wired together,
and a supply from the ULN2003a feeds these loads. As is the case in this project, the circuit
board containing the loads could be disconnected for movement purposes (transfer of the
device from one location to another), and re-connected when necessary.
4.3 Assembly Coding
To successfully write a code for any design, it is necessary to first create an algorithm and
flowchart to guide the working principles of the system or design. This project is not
different. A flowchart was drawn to analyze the working of the system, and this flowchart
was used to code the working of the microcontroller based on the received signals or SMS
transmitted from the external mobile phone(s) to the receiving mobile phone, which connects
to the microcontroller. This idea can be coded using several programming language apart
from Assembly language. It depends on the proficiency of the designer in the chosen
35
language. For this design, assembly language was used because the designer is fairly
proficient in it, and it is more commonly used for similar designs.
After the code was written, it was burnt to the EEPROM of the microcontroller
through a development board connected to a PC, running a software application known as an
Integrated Development Environment (IDE). The IDE is used to assemble and burn the code
to the EEPROM.
4.4 Testing
The entire system has to be tested after all the installation and soldering has been done, to
ensure that it is functioning as required. For this design, all the inherent parts of the circuit
performed consistently. Also, the test yielded the following results based on the program of
control that was written.
Table 4.1 Results of System Test
CODE SENT LOAD 1 LOAD 2 LOAD 3 LOAD 4
*1*# ON OFF OFF OFF
*2*# ON ON OFF OFF
*3*# ON ON ON OFF
*4*# ON ON ON ON
*5*# OFF ON ON ON
*6*# OFF OFF ON ON
*7*# OFF OFF OFF ON
*8*# OFF OFF OFF OFF
The 4 loads are supplied from the 4 supply lines from the ULN2003a driver.
As we can see from table 4.1 above, the first 4 codes sent from the transmitter mobile
phone(s) are used to switch on loads 1, 2, 3 and 4 respectively, and the last 4 SMS codes are
used to switch off loads 1, 2, 3 and 4 respectively. We can also induce from the table above
that we cannot control two devices at once using this design. When we switch loads 1 ON
(*1*#), and then send a code to switch loads 2 ON (*2*#), loads 2 comes ON but loads 1 still
remains ON, till we send a separate code to switch it OFF (*5*#). In the same way, when we
send a code to switch a particular load OFF, if there were any other loads ON, they will
36
remain ON till we switch them OFF by sending codes separately. Only the one whose code
we specify is switched OFF.
In summary, the home automation system on test performed exceptionally well to its
accuracy and capability. However, we can control only one supply line (from the ULN2003a)
at a time. In the case of this design, each of these supply lines is connected to 1 load.
37
CHAPTER FIVE
SUMMARY AND CONCLUSION
5.1 Summary
Automation systems generally play important roles in our society. This remote control
of home appliances (4 light bulbs) studied in this work is just one of such systems. It provides
a means whereby an individual or certain group of individuals can control a domestic system
using the Short Message Service (SMS) generated from a mobile phone which (the SMS), is
transmitted to the receiver mobile phone connected to the domestic system. This control
method uses commercial mobile communication networks as the path of data transmission.
SMS based remote control for home appliances are important for the human generation,
because mobile technology is used very often these days. The SMS based remote control for
home appliances is easy to implement so that an electrical device can be switched ON/OFF
via SMS. In a simple automation system as this one, where the internet facility and even PC
are not provided, one can use mobile phones which are simple and cost effective.
Alternatively, we can use DTMF (Dual tone Multi-Frequency) instead of SMS to
achieve the same or better results. This is based on the ability of some mobile phones to
generate signals which have horizontal and corresponding vertical frequencies on each key.
Hence, when these keys are pressed, the combination of the vertical and horizontal
frequencies are sent to the device, which incorporates a DTMF decoder, to decode the signals
to decipher which key or keys were pressed on the phone, and pass this information to a
controller to perform the required operation.
This system is limited to the area of coverage of the carrier network used for the SIM
card attached to the receiving mobile phone connected to the microcontroller. Also, due to
this design, the loads can only be controlled 1 at a time separately.
5.2 Advantages of Such System
(a) Convenience: SMS technology is easy to use and learn and can be accessed easily
when needed as long as there is GSM coverage over that area.
(b) Accessibility: Instructions can be sent to the microcontroller to be controlled and
monitored from any location provided there is existence of an active GSM network
from anywhere in the world.
38
(c) Portability: A microcontroller can be controlled and monitored from any GSM phone
that supports SMS. Considering the fact that most GSM phones support SMS, the
system is therefore highly portable.
(d) Saves Time: An SMS bases remote monitoring system saves time as the user is not
required to gain access to an internet connection or make a direct contact with the
system, hence the stress of moving to and from the device to operate it is cut off hence
time is saved.
(e) Cheapness: SMS services are generally cheap and are sometimes provided for free (at
least for certain periods) by service providers. Furthermore, most service providers do
not charge users for receiving SMS.
Applications
This system with a little modification in the design can be adapted for the following
applications.
i. Combination lock
ii. Home security system
iii. Mobile/wireless Robot control
iv. Wireless Radio control
v. Remote switches
5.3 Recommendation
This project aimed at implementing a remote method of controlling home appliances and was
successful. However, they are some recommendations which should be considered for future
related works.
(a) Inclusion of feedback mechanism from the device, so that the user knows that the
command he or she sent has successfully reached the device and the required
operation has been performed, not just relying on the delivery report from the carrier
network which does not give feedback on whether the required operation has been
effected.
(b) Inclusion of a charging system within the device itself so that the battery of the
receiving mobile phone attached to the device can be charged at regular intervals to
enhance availability of the system.
39
5.4 Conclusion
This project presents a method to control domestic loads using SMS generated and
transmitted from a mobile phone and received by another mobile phone connected to the
remote system. This control method makes use of commercial career networks as the path of
data transmission. Mobile phones have become an indispensable part of our life. This system
mainly uses a microcontroller and a cellular phone for its operations, and can be used as a test
bed for any application that requires on-off switching based systems. Wireless controlled
home appliances in the comforts of any environment will without doubt improve our way of
living.
40
APPENDIX A
Assembly Program
; The software for sms_device control
;Daniel Abara
; June 14, 2011, 12:26AM
; message format: *message*#
;MESSAGE MUST BE AT LEAST 4 DIGITS
; ON LOAD1=*1*#
; ON LOAD2=*2*#
; ON LOAD3=*3*#
; ON LOAD4=*4*#
; OFF LOAD1=*5*#
; OFF LOAD2=*6*#
; OFF LOAD3=*7*#
; OFF LOAD4=*8*#
; PHONE_NUM EQU=30H-3FH
org 00h
jmp start
load1 bit p3.2
load2 bit p3.3
load3 bit p3.4
load4 bit p3.5
LED EQU P1
message equ 5Ah
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
ORG 23H
LJMP TAKE_ACTION
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
Org 30h
start: SETB load1 ; off all loads
SETB load2
SETB load3
SETB load4
MOV R5,#8
MOV A,#0FFH
INIT: CPL A
MOV P1,A
CALL wait
DJNZ R5,INIT
mov scon,#50h ;configure the serial port mode
mov TMOD,#20h ;setting the serial port to receive data
41
mov TH1, #-24 ;setting the baud rate to 1,200
setb TR1 ;enable timer1
CALL WAIT5_SECS
CALL ONESEC
CALL ONESEC
CALL ONESEC
CALL WAIT
CALL WAIT
CALL WAIT
;*******************************************
clr RI
CLR TI
MOV IE,#10010000b ;ENABLE SERIAL INTERUPT
wait_4_msg:CPL P3.7 ; LED BLINK
CALL WAIT
jmp wait_4_msg
TAKE_ACTION:CLR IE.7 ; DIS ENABLE INTERRUPT
call ONESEC
call SEND_READ_COMMAND
CALL ONESEC
CALL READ_SMS
CALL ONESEC
CALL DEL_MSG
CALL ONESEC
MOV A,MESSAGE
IDENTIFY_MSG:
ON_LOAD1:CJNE A,#'1',ON_LOAD2
MOV A,#1
CPL A
MOV LED,A
LJMP SWITCH_ON_LOAD1
ON_LOAD2:CJNE A,#'2',ON_LOAD3
MOV A,#2
CPL A
MOV LED,A
LJMP SWITCH_ON_LOAD2
ON_LOAD3:
CJNE A,#'3',ON_LOAD4
MOV A,#3
CPL A
MOV LED,A
LJMP SWITCH_ON_LOAD3
42
ON_LOAD4:CJNE A,#'4',OFF_LOAD1
MOV A,#4
CPL A
MOV LED,A
LJMP SWITCH_ON_LOAD4
OFF_LOAD1:CJNE A,#'5',OFF_LOAD2
MOV A,#5
CPL A
MOV LED,A
LJMP SWITCH_OFF_LOAD1
OFF_LOAD2:CJNE A,#'6',OFF_LOAD3
MOV A,#6
CPL A
MOV LED,A
LJMP SWITCH_OFF_LOAD2
OFF_LOAD3:CJNE A,#'7',OFF_LOAD4
MOV A,#7
CPL A
MOV LED,A
LJMP SWITCH_OFF_LOAD3
OFF_LOAD4:CJNE A,#'8',IGNORE
MOV A,#8
CPL A
MOV LED,A
LJMP SWITCH_OFF_LOAD4
IGNORE: MOV LED,#00
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_ON_LOAD1:CLR LOAD1
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
43
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_ON_LOAD2:CLR LOAD2
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_ON_LOAD3:CLR LOAD3
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_ON_LOAD4:CLR LOAD4
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_OFF_LOAD1:SETB LOAD1
CALL WAIT5_SECS
CLR RI
CLR TI
44
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_OFF_LOAD2:SETB LOAD2
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_OFF_LOAD3:SETB LOAD3
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
SWITCH_OFF_LOAD4:SETB LOAD4
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
CALL WAIT5_SECS
CLR RI
CLR TI
SETB IE.7
RETI
WAIT5_SECS:mov r7,#36
mov r6,#40
45
mov r5,#176
waita_: djnz r5,waita_
djnz r6,waita_
djnz r7,waita_
ret
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%
SEND_READ_COMMAND:clr TI
READuu: clr A
movc A,@a+dptr
CJNE A,#'#',READ_COMMAND_
clr RI
RET
READ_COMMAND_:MOV SBUF,A
JNB TI,$
CLR TI
INC DPTR
JMP READuu
;%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%
READ_SMS:MOV R0,#30h
MOV R1,#00
clr RI
mov r1,#00h
GO_AHEAD:JNB RI,$
clr p3.4
clr RI
MOV A,SBUF
MOV @R0,A
inc R1
CJNE R1,#46,GO_AHEAD
MOV @R0,A
INC R0
GO_AHEAD2:JNB RI,$
clr RI
MOV A,SBUF
MOV @R0,A
INC R0
CJNE R0,#5BH,GO_AHEAD2
RET
SEND_PHONE_NUM:
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
MOV DPTR,#PHONE_NUM
SEND: clr A
movc A,@a+dptr
CJNE A,#'#',SMSG2
JMP CONT
46
SMSG2:MOV SBUF,A
JNB TI,$
CLR TI
INC DPTR
JMP SEND
;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&7
clr TI
CONT: MOV R0,#30H
XXXh: MOV A,@R0
CJNE R0,#40H,PHONE_NO
MOV A,#13
MOV SBUF,A
JNB TI,$
CLR TI
RET
PHONE_NO:MOV SBUF,A
JNB TI,$
CLR TI
INC R0
JMP XXXh
DEL_MSG:clr TI
MOV DPTR,#MEM_MSG
Muu: clr A
movc A,@a+dptr
CJNE A,#'#',DEL_MEM_
RET
DEL_MEM_:MOV SBUF,A
JNB TI,$
CLR TI
INC DPTR
JMP Muu
wait: mov r3,#8
mov r2,#8
mov r1,#236
waita: djnz r1,waita
djnz r2,waita
djnz r3,waita
ret
onesec:MOV R2,#90
MOV R1,#162
on_e: DJNZ R1,on_e
DJNZ R2,on_e
NOP
RET
INIT_MSG:DB'AT+CMGF=1',13,'#'
NEW_MSG:DB'AT+CNMI=1,1,1,1,1',13,'#'
47
PHONE_NUM:DB'AT+CMGS=#'
MEM_SIM:DB'AT+CPMS="SM"',13,'#'
MEM_MSG:DB'AT+CMGD=1,4',13,'#'
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
end