Sending / receiving SMS using a GSM modem Application note

Sending / receiving SMS
using a GSM modem
Application note
A111900, English
Version 1.0.4
2 • General
Copyright  2003 by WAGO Kontakttechnik GmbH & Co. KG
All rights reserved.
WAGO Kontakttechnik GmbH & Co. KG
Hansastraße 27
D-32423 Minden
Phone: +49 (0) 571/8 87 – 0
Fax:
+49 (0) 571/8 87 – 1 69
E-Mail: info@wago.com
Web:
http://www.wago.com
Technical Support
Phone: +49 (0) 571/8 87 – 5 55
Fax:
+49 (0) 571/8 87 – 85 55
E-Mail: support@wago.com
Every conceivable measure has been taken to ensure the correctness and completeness of this documentation. However, as errors can never be fully excluded we would appreciate any information or ideas at any time.
We wish to point out that the software and hardware terms as well as the
trademarks of companies used and/or mentioned in the present manual are
generally trademark or patent protected.
Application note
A111900
Table of Contents
•3
TABLE OF CONTENTS
1 Important comments.................................................................................. 4
1.1
Legal principles ...................................................................................... 4
1.1.1 Copyright ............................................................................................... 4
1.1.2 Personnel qualification........................................................................... 4
1.1.3 Intended use ........................................................................................... 4
1.2
Range of validity .................................................................................... 5
1.3
Symbols.................................................................................................. 5
2
Description .................................................................................................. 6
3
Reference Material..................................................................................... 6
4
Solution ....................................................................................................... 7
5 Programming the Controller .................................................................... 8
5.1
Sending / receiving SMS messages ....................................................... 8
5.2
Parsing received messages ..................................................................... 9
5.2.1 LAMP (procedure) ............................................................................... 10
5.2.2 MESSAGE (procedure) ....................................................................... 10
6
Display....................................................................................................... 11
7 Tables ........................................................................................................ 12
7.1
Various Initialization strings ................................................................ 12
7.2
Files required ....................................................................................... 12
Application note
A111900
4•
Important comments
1 Important comments
To ensure fast installation and start-up of the units described in this manual,
we strongly recommend that the following information and explanation is
carefully read and adhered to.
1.1 Legal principles
1.1.1 Copyright
This manual is copyrighted, together with all figures and illustrations contained therein. Any use of this manual which infringes the copyright provisions
stipulated herein, is not permitted. Reproduction, translation and electronic
and photo-technical archiving and amendments require the written consent of
WAGO Kontakttechnik GmbH & Co. KG. Non-observance will entail the
right of claims for damages.
1.1.2 Personnel qualification
The use of the product detailed in this manual is exclusively geared to specialists having qualifications in PLC programming, electrical specialists or persons instructed by electrical specialists who are also familiar with the valid
standards. WAGO Kontakttechnik GmbH & Co. KG declines all liability resulting from improper action and damage to WAGO products and third party
products due to non-observance of the information contained in this manual.
1.1.3 Intended use
For each individual application, the components supplied are to work with a
dedicated hardware and software configuration. Modifications are only admitted within the framework of the possibilities documented in the manuals. All
other changes to the hardware and/or software and the non-conforming use of
the components entail the exclusion of liability on part of WAGO Kontakttechnik GmbH & Co. KG.
Please direct any requirements pertaining to a modified and/or new hardware
or software configuration directly to WAGO Kontakttechnik GmbH & Co.KG.
Application note
A111900
Important comments
•5
1.2 Range of validity
This application note is based on the stated hardware and software of the specific manufacturer as well as the correspondent documentation. This application note is therefore only valid for the described installation.
New hardware and software versions may need to be handled differently.
Please note the detailed description in the specific manuals.
1.3 Symbols
Danger
Always observe this information to protect persons from injury.
Warning
Always observe this information to prevent damage to the device.
Attention
Marginal conditions must always be observed to ensure smooth operation.
ESD (Electrostatic Discharge)
Warning of damage to the components by electrostatic discharge. Observe the
precautionary measure for handling components at risk.
Note
Routines or advice for efficient use of the device and software optimisation.
More information
References to additional literature, manuals, data sheets and INTERNET pages
Application note
A111900
6•
Description
2 Description
This application example demonstrates how to send and receive short messages using a GSM modem.
For demonstration purposes the "lamp" procedure has been used in this example. This procedure allows up to three parameters to be parsed. The procedure
name and the parameters included in the message are separated by a comma.
It is therefore possible to switch one or several lamps by sending a SMS message.
To gain a better understanding of this procedure, arriving messages can be displayed and direct message input is possible before sending the message.
For this application a standard mobile phone is used as GSM modem.
The following mobile phones have been tested:
Siemens S25 with Siemens data cable
Siemens S35 with Siemens data cable
Siemens S45 with Siemens data cable
Nokia 6210 with DLR-3 data cable
Ericson T68i with data cable
Furthermore, the following GSM modules were tested:
Siemens C35i
Siemens M20T
Siemens TC35i
INSYS GSM small
When using GSM modules, all AT commands that can be executed automatically should be deactivated (refer to manufacturer's manual).
3 Reference Material
Manufacturer
WAGO
WAGO
WAGO
WAGO
WAGO
Name
Ethernet controller
4-channel dig. output module
Serial interface RS232
End module
Interface module
Siemens
Siemens
Data cable for S25..S45
Mobile phone S25 / S35 / S45
Nokia
Nokia
Data cable for 6210
Mobile phone 6210
Version / Item No.
750-842
750-504
750-650 / 003-000
750-600
289-545
DLR-3
6210
Application note
A111900
Solution
•7
4 Solution
TxD - (3)
RxD - (2)
RTS/CTS - (7+4)
289-545
GND - (5)
750-600
750-842
750-504
750-650/003-000
Picture 4-1: GSM_SMS call up
The standard interface module from WAGO (item no.: 289-545) makes it possible to use a standard mobile phone data cable.
Application note
A111900
8•
Programming the Controller
5 Programming the Controller
Programming the controller includes sending / receiving SMS messages as
well as parsing received messages (RPC interface).
5.1 Sending / receiving SMS messages
Sending and receiving messages is done using the "GSM_SMS" module from
the "SMS_01.LIB" library.
Received messages are registred in the "RECEIVED_SMS" structure by the
module (see picture 5.1-1)
Picture 5.1-1: GSM_SMS call up
Messages to be sent are registred in "SEND_SMS". The transmission is activated by setting the START_SEND_SMS parameter once (see also library description ML00300d).
Application note
A111900
Programming the Controller
•9
5.2 Parsing received messages
Received messages are delivered to the SMS_RPC module to be parsed. This
module first checks whether a new valid message has been received and decomposes the message into its individual parts by calling the
"PARSE_SMS_MESSAGE" function.
Subsequently, the individual parts of the message are located in the "message“
structure.
The procedure name (function name) can now be parsed using an appropriate
"IF command" and the corresponding procedure is called.
Procedure calls can be added to the application by the user at any time, since
this part of the program is located outside the library.
Picture 5.1-2: call up interface (RPC)
The "lamp" and "message" procedures have been implemented in this application example. For example, the second lamp (fisrt parameter following the
procedure name) is switched on by a message containing "lamp,2,1,0“ (second
parameter). With the third parameter set, no return message needs to be sent
afterwards.
Application note
A111900
10 •
Programming the Controller
5.2.1 LAMP (procedure)
WAGO-I/O-PRO 32 procedure example
Demonstration
LAMP
Programmable couplers
Category:
Name:
Used for:
Parameter:
1
Range:
½
2
0/1
3
0/1
Comment:
Addressing lamp => 1 -> 1st storey
2 -> ground
0 -> lamp off
1 -> lamp on
0 -> no return message
1 -> SMS return message to the sender
Function description:
Using this procedure, a digital output is switched on or off according to the
parameters.
After switching, a return message (SMS) is generated for the sender provided
the third parameter is set to 1.
5.2.2 MESSAGE (procedure)
WAGO-I/O-PRO 32 procedure example
Demonstration
MESSAGE
Programmable couplers
Category:
Name:
Used for:
Parameter:
None
Range
Comment:
Function description:
This procedure sends a return message (SMS) to the procedure initiator (sender
nummer).
Application note
A111900
Display
• 11
6 Display
The display supporting this application example is divided into three parts: the
SMS reception window (blue), the SMS transmission window (green) and the
picture of a building showing how the message is processed.
Picture 6-1: Display
Application note
A111900
12 •
Tables
7 Tables
7.1 Various Initialization strings
NOKIA_6210_INIT : STRING :=
'ATE0|/AT+CMGF=0|/AT+CNMI=2,2,0,0,0|';
SIEMENS_S45_INIT : STRING :=
'ATE0|/AT+CMGF=0|/AT+CNMI=1,1,0,0,1|';
SIEMENS_C35i_INIT : STRING :=
'AT+CPIN=1234|/ATE0|/AT+CMGF=0|/AT+CNMI=1,1,0,0,1|//';
SIEMENS_M20_INIT : STRING :=
'AT+CPIN=1234|/ATE0|/AT+CMGF=0|/AT+CNMI=1,1,0,0,1|/';
ERICSON_T68i_INIT : STRING :=
'ATE0|/AT+CMGF=0|/AT+CNMI=3,1,0,0,0|/AT+CPMS="ME","ME"|';
INSYS_GSM_SMALL_INIT : STRING :=
'AT+CPIN=1234|/ATE0|/AT+CMGF=0|/AT+CNMI=1,1,0,0,1|/AT+CPMS="SM","SM","SM"|/';
SIEMENS_TC35i_INIT
: STRING :=
'AT+CPIN="1234"|/ATE0|/AT+CMGF=0|/AT+CNMI=3,1,0,0,1|/AT+CPMS="MT","MT",”MT”|';
WESTERMO_GDW11_INIT : STRING :=
'AT+CPIN=1234|/ATE0|/AT+CMGF=0|/AT+CNMI=1,1,0,0,1|/AT+CPMS="SM","SM","SM"|/';
NEUHAUS_GMOD_S3_INIT : STRING :=
'ATE0|/AT+CMGF=0|/AT+CNMI=2,1,0,0,0|';
(* Echo off | PDU-Mode | Messagerouting *)
AT commands that can be executed automatically must be deactivated using appropriate
software (refer to manufacturer's manual).
7.2 Files required
Column headline
GSM_SMS_01_lib.pro
Project example
GSM_SMS_01.Lib
Protocol driver used to control a GSM modem
Serial_Interface_01.Lib
Driver for serial interfaces
SerComm.Lib
Basic functionality of serial interfaces
SerComm.HEX
Hex file for basis functionality
Standard.Lib
Standard functions
Standard.HEX
Hex file for the standard functions
Application note
A111900
WAGO Kontakttechnik GmbH & Co. KG
Postfach 2880 • D-32385 Minden
Hansastraße 27 • D-32423 Minden
Phone:
05 71/8 87 – 0
Telefax: 05 71/8 87 – 1 69
E-Mail:
info@wago.com
Internet:
http://www.wago.com