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: [email protected] 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: [email protected]
Every conceivable measure has been taken to ensure the correctness and com-pleteness of this documentation. However, as errors can never be fully ex-cluded 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 gen-erally trademark or patent protected.
Table of Contents • 3 Application note A111900
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 ... 75 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
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 stipu-lated 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 special-ists having qualifications in PLC programming, electrical specialspecial-ists or persons instructed by electrical specialists who are also familiar with the valid stan-dards. 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 admit-ted within the framework of the possibilities documenadmit-ted 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 Kontakttech-nik 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.
Important comments • 5
Application note A111900
1.2 Range of validity
This application note is based on the stated hardware and software of the spe-cific manufacturer as well as the correspondent documentation. This applica-tion note is therefore only valid for the described installaapplica-tion.
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
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 exam-ple. 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 mes-sage.
To gain a better understanding of this procedure, arriving messages can be dis-played 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 automati-cally should be deactivated (refer to manufacturer's manual).
3 Reference Material
Manufacturer Name Version / Item No.
WAGO Ethernet controller 750-842
WAGO 4-channel dig. output module 750-504
WAGO Serial interface RS232 750-650 / 003-000
WAGO End module 750-600
WAGO Interface module 289-545
Siemens Data cable for S25..S45 Siemens Mobile phone S25 / S35 / S45
Nokia Data cable for 6210 DLR-3
Solution • 7
Application note A111900
4 Solution
Picture 4-1: GSM_SMS call up
The standard interface module from WAGO (item no.: 289-545) makes it pos-sible to use a standard mobile phone data cable.
TxD - (3) RxD - (2) RTS/CTS - (7+4) GND - (5) 750-504 750-650/003-000 750-842 750-600 289-545
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 acti-vated by setting the START_SEND_SMS parameter once (see also library de-scription ML00300d).
Programming the Controller • 9
Application note A111900
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 de-composes 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 applica-tion example. For example, the second lamp (fisrt parameter following the pro-cedure name) is switched on by a message containing "lamp,2,1,0“ (second pa-rameter). With the third parameter set, no return message needs to be sent af-terwards.
10 • Programming the Controller
5.2.1 LAMP (procedure)
WAGO-I/O-PRO 32 procedure example
Category: Demonstration
Name: LAMP
Used for: Programmable couplers
Parameter: Range: Comment:
1 ½ Addressing lamp => 1 -> 1st storey 2 -> ground 2 0/1 0 -> lamp off
1 -> lamp on
3 0/1 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
Category: Demonstration
Name: MESSAGE
Used for: Programmable couplers
Parameter: Range Comment:
None
Function description:
This procedure sends a return message (SMS) to the procedure initiator (sender nummer).
Display • 11
Application note A111900
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.
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"|/'; WAGO_761_510_INIT : STRING := 'ATE0+CMGF=0+CNMI=2,1,0,0,1+CPMS="MT","MT","MT"|///';
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
Tables • 13
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: [email protected] Internet: http://www.wago.com