Sie sind auf Seite 1von 5

Dogan:Mobile Europe cover template.

qxd 11/3/10 10:07 Page 2

GSM/GPRS

SMS-Based GSM/GPRS
Remote Data-Logging System
Dogan Ibrahim, lecturer at the Near East University Cyprus, describes the design
of a microcontroller-based remote data logging system, where the collected data
is sent as SMS using a GSM/GPRS modem
A DATA LOGGER is an electronic GSM operator Carrier Frequency (MHz) Ownership
instrument used to collect information about
Orange/T-Mobile 1800/2100 France Telecom
physical quantities in the real world. Data
loggers incorporate sensors which convert O2 900/1800/2100 Telefonica
physical quantities into electrical signals that can Vodafone 900/1800/2100 Vodafone
be stored on a computer or on any other digital
medium. Among the commonly used sensors Table 1: GSM operators in the UK
are temperature, pressure, force, sound level,
flow, speed, position, relative humidity, wind- breakdowns, communications noise or long as a mobile phone service is available.
speed, angle of rotation and so on. communications failure.  Data is sent without any loss using the reliable
In general, data loggers are either standalone PC-based data loggers rely on a local PC to SMS messaging service.
or PC-based. Standalone sensors are usually store the collected data. In such systems a data  Data can be sent to any number of recipients
small dedicated instruments with low power logger instrument, equipped with required by simply changing the mobile phone number
operation and some form of non-volatile data sensors, collects data and sends it to a local PC or by adding more numbers.
storage (e.g. an SD card). These data loggers for storage. The data logger is under control of  Both the data logger and the recipients can
store data unattended over a period of time and the PC at all times. PC-based data loggers are be mobile.
then the stored data are loaded into a PC for well suited to controlled environments such as  Data sending period or the amount of data
offline analysis and graphing. homes, offices and factories where the sent can easily be changed in the program.
Some standalone data loggers incorporate operating conditions can easily be controlled and  The system is low power and can easily be
wireless communication modules such as RF the system can be attended to in case of failure. operated from a solar or wind energy source
communications. The collected data in such This article describes the design of an SMS- in fixed location applications.
instruments can be uploaded to a PC in real- based data logger system. An example project is
time for analysis. Alternatively, the data can be given in detail in the paper where the ambient The GSM System
collected over a period of time and then the temperature is read every hour and is sent to a GSM (Global System for Mobile
complete package of data can be sent remotely mobile phone as an SMS message. The Communications) is currently the most widely
to a PC. described system is a standalone data logger used standard for mobile telephone systems in
Standalone data loggers have the advantages and offers the following advantages: the world. It is estimated that over 80% of the
that they operate independent of a PC and,  The system is independent of a PC for its mobile market uses the GSM standard, with
because of their low power consumptions, they operation. estimated 3 billion people across over 200
can be powered from solar or wind energy  Data collection is ubiquitous, where data can countries.
sources. In addition, they do not suffer from PC be collected at any place and at any time as GSM is a cell-based (cellular) network where
mobile phones access the network by
connecting to the cell in their immediate
vicinities. GSM is based on an all-digital
technology. These networks operate in a
number of different carrier frequencies. In
Europe most networks operate at either 900 or
1800MHz. In most of Americas the carrier
frequency is either 850 or 1900MHz. In the UK
there are over 75 million subscribers. Table 1
shows the main GSM operators in the UK with
their frequency bands.
Figure 1: Block diagram of the system
Other GSM operators, for example Virgin

32  April 10 - Electronics World


Dogan:Mobile Europe cover template.qxd 11/3/10 10:08 Page 3

GSM/GPRS

LED State SIM340Z Function


OFF Modem is OFF
64ms ON/800ms OFF GSM network not found
Figure 2: SIM340Z
GSM/GPRS modem 64ms ON/3000ms OFF GSM network found
64ms ON/300ms OFF GPRS communication

shown in Figure 1. A semiconductor Table 2: LED showing the modem status


analogue sensor is used as the
temperature sensor. The microcontroller converts power operation, among others.
the sensor output voltage from analogue to The design makes use of the following
digital. The GSM/GPRS modem is under the microcontroller features: 1060 bytes (12%) of
control of the microcontroller. Standard AT program memory, 153 bytes (41%) of RAM
commands are used to communicate with the memory, 3 digital I/O pins, 1 analogue input pin,
modem and to send the temperature as an SMS USART, interrupt (USART).
message to a mobile phone. A SIM card The modem used in the design is a SIM340Z
Mobile, Asda Mobile, Tesco Mobile and others, provides the subscriber details to the system. module (see Figure 2) manufactured by
use services of the main operators. Some mobile The temperature sensor used in the design is SIMCOM. This is a quad-band GSM/GPRS
phones are designed to be quad-band and they a 3-pin LM35DZ type analogue semiconductor. modem and offers 850/900/1800/1900MHz
cover the frequencies 800/900/1800/1900MHz. This sensor can be used to measure operation, small footprint (40mm x 33mm x
Such phones can be used in most countries. temperatures in the range 0ºC to 70ºC. The 2.85mm), low weight (8g), GSM 07.07 and
Triband phones cover the frequency bands output voltage of the sensor is given by Vo = 07.05 compatible, control via AT commands,
900/1800/1900MHz and can be used in most of 10mV/ºC. So, for example, at 10ºC the sensor low power operation (3.4V-4.5V), SIM card
Europe and Americas. output voltage is 100mV. Similarly, at 30ºC the interface, keypad and LCD interfaces.
The transmission power in the handset is output voltage is 300mV. The SIM340Z modem is easily interfaced to a
limited to 2W in the 800/900MHz bands and to A PIC16F887 type microcontroller is used in microcontroller using only three serial
1W in the 1800/1900MHz bands. The new 3G the design (any other type of microcontroller communication pins (TXD, RXD and RTS). The
standard phones use the frequency band could also be used as long as it satisfies the modem provides signals to drive a SIM card
2100MHz. The GSM system was designed with memory and I/O requirements). This is a 40- directly. In addition, an LED can be connected to
a moderate level of security where the subscriber pin RISC based microcontroller having 8192 the modem to show the working status of the
is authenticated using a pre-shared key and the bytes flash program memory, 368 bytes RAM modem (see Table 2). The modem also provides
communication between the subscriber and the memory, 256 bytes EEPROM memory, 35 I/O a buzzer interface where a buzzer or a small
network is encrypted. pins, 14 channel 10-bit A/D converter, speaker can be connected to indicate an
analogue comparator, USART, interrupt incoming call. In addition, the modem provides
The System’s Block Diagram capability, up to 20MHz operation, 3 timers signals for a keypad and an LCD to be
The block diagram of the designed system is and watchdog timer, 2 comparators and low connected for dedicated autonomous mobile
communication applications. A small connector
is provided on the modem for an external
antenna to be connected. Figure 3 shows a
functional block diagram of the SIM340Z
modem.

The SIM Card


The SIM (Subscriber Identity Module) card is a
small (15mmx25mmx0.76mm) smart-card, used
to store the subscriber information and identify
of a subscriber to the cellular network. A user
can change handsets by simply removing the
SIM card from one phone and inserting it into
another phone.
The use of a SIM card is mandatory in a
mobile phone as it stores the International
Figure 3: SIM340Z
Mobile Subscriber Identity (IMSI) number,
functional block diagram
security authentication and ciphering

www.electronicsworld.co.uk  33
Dogan:Mobile Europe cover template.qxd 11/3/10 10:08 Page 4

GSM/GPRS
information, password (card PIN), phone book
details, log of sent and received messages,
received and dialled call log and so on. The card
has six pins and is usually held in a SIM card
holder (see Figure 4). Card pins have the
following definitions (as specified by the ISO
7816 standard):
Pin 1 (VCC): This pin provides the card’s power
supply. A SIM card is typically operated between
3V and 5V.
Pin 2 (RST): This is the RESET pin. A low-level
on this pin resets the card to a known state.
Pin 3 (CLK): This pin provides the card with the
clock signals. The clock is between 1 and 5MHz,
with a duty cycle between 40% and 60%.
Pin 4 (GND): This is the ground pin of card’s
power supply.
Pin 5 (VPP): This pin is not used anymore. It was
used to provide programming voltage required
to write and erase the card’s internal non-volatile
memory.
Pin 6 (I/O): This is the input and output pin of
the card. Half-duplex asynchronous serial
communication is used to read and write data to
the card.
When the card contacts are activated, the RST
pin is held at a low level and the VCC supply is
Figure 5: Circuit diagram of the system
applied. After maintaining the RST signal at a
low state for at least 40,000 clock cycles, it is
raised to a high state and communication with the card starts by driving the I/O line while the important to note that the modem operating
RST is held high. voltage is between 3.5V and 4.5V, with a
recommended typical value of 4V. The power
The Circuit Diagram supply should be capable of providing up to 2A
The circuit diagram of the designed system is current which may be required in transient
shown in Figure 5. The microcontroller interface operations.
is extremely simple. An 8MHz crystal is used as
the clock source. The temperature sensor is The Construction
connected to analogue input AN0 of the The system was constructed using an EasyPIC
microcontroller. USART serial input pin RXD 5 microcontroller development board, together
(RC7) and TXD (RC6) are connected to the TXD with a Smart GSM/GPRS development board.
and RXD pins of the SIM340Z modem Both development boards are developed and
respectively. manufactured by mikroElektronika. EasyPIC 5,
The RTS input of the modem is driven by port shown in Figure 6, is a popular, highly versatile,
pin RC2. This pin should be forced Low when general-purpose, microcontroller development
the modem is operated using only the TXD and board which offers support for 8, 14, 18, 20, 28
RXD pins. The SIM card is connected to the and 40-pin PIC microcontrollers; USB 2.0 on-
modem via current limiting resistors where the board programmer via PC; mikroICD in-circuit
modem provides the power supply voltage, I/O, debugger; 4 digit 7-segment display in
CLK and RST inputs. The LED status output pin multiplexed mode; 36 LEDs; 36 push-button
(NETLED) of the modem is connected to an LED switches; RS232 interface; text and graphics
through a transistor switch circuit. An RF based LCD; touch-screen controller; USB and
antenna supplied with the modem is connected PS/2 connectors; and removable crystal.
to the antenna socket of the modem. The The USB based in-circuit debugger (mikroICD)
microcontroller can be reset via its MCLR input is extremely useful during the development and
using an external push-button switch. Similarly, debugging of complex programs. With the help
the modem can be reset via its PWRKEY input of a high-level software compiler, programmers
using an external switch. can set breakpoints, single-step an application
The PWRKEY input should be held Low for at program, or can display the variables as the
Figure 4: A typical SIM card holder
least four seconds to re-start the modem. It is program is running.

34  April 10 - Electronics World


Dogan:Mobile Europe cover template.qxd 11/3/10 10:08 Page 5

GSM/GPRS
A GSM/GPRS In this project, the easier Text mode has been
development board used. An SMS text message can consist of
(www.mikroe.com), alphanumeric characters with up to 160
shown in Figure 7, was characters long with 7-bit coding and 140
used to provide the characters long with 8-bit coding. Basically, SMS
modem functionalities. This is a store-and-forward type service where the
board offers support for messages are not sent directly from the sender
five different GSM modems, to recipient but via an SMS Service Centre
SIM card holder, antenna (SMSC). Mobile telephone networks have
holder, audio amplifier and messaging centres that handle the delivery of
audio interface with messages to their destinations. There is by
microphone and speaker, default no confirmation of the delivery of a
RS232 interface for PC or message. But users can turn ON this option so
microcontroller interface, LED that a confirmation of delivery can be sent to
showing the modem status, the sender when a message is delivered
interface signals on 10-way successfully.
connectors for easy interface Figure 6: EasyPIC 5 microcontroller Sending an SMS message in Text mode is very
development board
to microcontroller easy and an example is given below that shows
development systems. how the message “Hello there!” can
The SIM340Z modem card is mounted on the be sent to mobile number
GSM/GPRS development board (to the bottom “123456890”, assuming that
centre part) with its antenna attached at the the SMS service centre
side of the board. PORT C of the EasyPIC 5 number has already been
development board was connected to modem loaded to the SIM card, which
terminals of the GSM/GPRS board via a 10-way is the case by default, and that
ribbon cable, as in Figure 8. Jumper J1 on the there is no PIN associated with
GSM/GPRS board was set to select the card:
communication with an MPU. The EasyPIC 5  Set SMS mode to Text:
board was powered from the USB port of a AT+CMGF=1
PC (laptop), while the GSM/GPRS board was  Set the character mode to GSM:
powered from an external 12V mains adaptor. AT+CSCS=”GSM”
 Set the SMS parameters:
The AT Commands AT+CSMP=17,167,0,241
The AT commands are used to control Figure 7: GSM/GPRS  Set the recipient mobile phone
the operations of modems. These development board number and the text message:
commands were first developed for the AT+CMGS=”1234567890”
Hayes Smartmodem 300 in late 1970s. a list of the important AT commands available > Hello there! [Cntrl-Z]
An AT command consists of the letters “AT”, for sending an SMS message (further Note that after sending the recipient mobile
followed by a number of characters specifying information can be obtained from the SIMCOM phone number, the modem responds with
the command tail. Some commands are used to SMS Application note AN_SMS_V1.01). character “>” and that the message must be
set the configuration of modems, some are used There are two ways of sending and receiving terminated with the “Cntrl-Z” character.
to interrogate modems and get their SMS messages using AT commands: by PDU It is worthwhile to look at briefly the meaning
configurations, while some other commands are (Protocol Description Unit) mode and TEXT of the various SMS parameters set by command
used to dial numbers, send SMS messages and mode. The PDU mode offers to send binary data CSMP. The format of this command is (further
so on. in 7-bit or 8-bit mode and is helpful for sending information can be obtained from the AT
In addition to the standard AT command set, compressed data or binary data. PDU mode data command interface document):
the SIM340Z GSM/GPRS modem supports consists of hexadecimal string of characters, AT+CSMP = <fo>, <vp>, <pid>, <dcs>
commands to configure the modem and send including the SMS service centre, sender Field <fo> is set to 17, which indicates that
SMS messages to mobile phones. Table 3 gives number, time stamp etc. the message is to go from a mobile device to a
service centre and the <vp> field is valid.
AT Command SMS Function Field <vp> selects the message validity period
AT+CMGF Select SMS message format and a value between 144 to 167 selects the
AT+CMCS Select SMS character set period as:
AT+CSCA SMS service centre address 12 hrs + ((vp – 143) x 30 min)
With a setting of 167, the message validity
AT+CMGS Send SMS message
period is:
AT+CSMP Set SMS text mode parameters 12 hrs + (167 – 143) x 30 min) = 24 hrs
Field <pid> is used to indicate the higher layer
Table 3: SIM340Z modem SMS commands
protocol being used and is set to 0 here.

www.electronicsworld.co.uk  35
Dogan:Mobile Europe cover template.qxd 11/3/10 10:08 Page 6

GSM/GPRS
the program are declared. The main program
forces the modem RTS pin to 0, configures the
analogue input channel AN0 and enables the
USART interrupts.
The USART is initialised with a Baud Rate of
19200 and a loop is formed to force the modem
Baud Rate to this value. The program then sets
the modem into Text mode with GSM character
code, 24-hour message validity period and the
message class of 0. Then the program enters an
endless loop where the temperature is read
every hour and sent to the specified mobile
phone as an SMS text message. The
temperature is read from analogue channel AN0,
converted into millivolts and then divided by 10
to find the actual physical temperature in oC.
USART interrupts are used to receive the
modem responses. A response can be “OK” or
“RDY” and is terminated with a carriage-
return and line-feed character pair. After
sending an AT command, the program waits
Figure 8: The test system showing EasyPIC 5 until a successful response is received from the
connected to the GSM/GPRS board modem.
The software developed in this project can be
improved by the following modifications:
Field <dcs> is used to determine the way  Several temperature readings can be collected
the information is encoded. This field is set to and then sent at the same time using one
241 which sets the message class to 1 and SMS message.
uses the default alphabet. Note that setting  The SMS messages can be sent in response to
the message class to 0 causes the message to a request from the recipient. Thus data can
be displayed immediately without being stored be collected and received whenever required.
by the mobile phone, this is also called a flash  A flash memory (e.g. an SD card) can be
message. added to store the collected data.
Modems commands normally return status  GPRS mode or FTP can be used to send large
and error codes in response to AT commands. amount of data.
It is important that any software sending  An RTC chip can be added to the system to
control codes to a modem should check these time-stamp the collected data. 
return codes to make sure that the modem
has been configured and responded with no
errors. Most successful commands return the
two character code “OK”.

The Software
The software was developed using the
mikroC compiler. This is a popular
microcontroller C language compiler
developed by mikroElektronika. mikroC
language supports a large variety of interface
devices and protocols, and provides built-in
library of functions for devices such as SD
card, CompactFlash card, I2C bus, RS232
and RS485, LCD, USB, CAN bus and so on.
Figure 9 shows operation of the software
using a PDL (Program Description Language)
type description.
At the beginning of the program the digital
and analogue I/O ports are configured, various
constant character strings such as the AT Figure 10: A typical message
Figure 9: PDL description of the software commands and mobile phone number used in sent to a mobile phone

36  April 10 - Electronics World

Das könnte Ihnen auch gefallen