1. Overview
The Siemens CP 1242-7 GPRS V2 (article number 6GK7242-7KX31-0XE0) extends the S7-1200 family with GSM/GPRS connectivity. In addition to IP-based telecontrol, the V2 firmware exposes a SMS signaling and switching channel that lets a station send operator alarms to mobile handsets and accept command SMS replies to drive Boolean outputs. The functionality is delivered as a reusable code library on top of TIA Portal and is documented in the Siemens application example, entry ID 58638283, titled "Signaling and Switching via SMS with S7-1200 and CP 1242-7 V2". The reference PDF is hosted on the Siemens Industry Online Support portal: 58638283_S7_1200_SMS_DOC_V13_en.pdf. The same entry page (which also serves as the download portal for the global library) is available at Siemens Support Entry 58638283.
This article closes the two most common gaps that prevent a first-time user from getting an SMS out of the box:
- The SMS blocks are not bundled with TIA Portal; they live inside a downloadable global library (
.zalfile) shipped with entry 58638283. - The reference project is published under complete protection, which prompts for a user name and password when you open it. The protection credentials and the function block API are listed on page 56 of the documentation PDF.
The procedures below target TIA Portal V15 with STEP 7 V15, but the same library works with V13 SP1 through V17 as long as the project is recompiled under the active version.
2. Prerequisites
| Item | Specification |
|---|---|
| S7-1200 CPU | Any CPU with left-side bus (CPU 1211C / 1212C / 1214C / 1215C / 1217C supported) |
| CP 1242-7 GPRS V2 |
6GK7242-7KX31-0XE0 (Firmware ≥ V2.0) |
| TIA Portal | V15 or V15.1 (Basic sufficient; Professional recommended for libraries) |
| STEP 7 | V15 / V15.1, language English or German |
| Antenna | GSM quad-band, e.g. ANT794-4MR (6NH9860-1AA00) with SMA male |
| SIM card | Mini-SIM (2FF), SMS-capable, PIN disabled or known, network unlocked |
| Siemens Support account | Free registration at support.industry.siemens.com to download entry 58638283 |
3. Hardware Identification: V1 vs. V2
The CP 1242-7 line has two firmware generations. Only the V2 generation ships the SMS blocks.
| Feature | V1 (6GK7242-7KX30-0XE0) | V2 (6GK7242-7KX31-0XE0) |
|---|---|---|
| Telecontrol / GPRS | Yes | Yes |
| SMS send/receive (SndSms / RcvSms) | No | Yes |
| DNP3 / IEC 60870-5-104 | Optional via add-on | Yes |
| Max. SMS per hour (recommended) | — | ~30 (operator-dependent) |
Before proceeding, confirm the module label. If the label reads 6GK7242-7KX30-0XE0, the SMS blocks will compile but fail at runtime because the V1 firmware does not expose the underlying CFB blocks SEND_SMS / RECEIVE_SMS over the internal bus.
4. Mechanical Setup and SIM Insertion
- Power down the S7-1200 rack.
- Snap the CP 1242-7 onto the leftmost free slot of the CPU (left of the CPU, right of any existing CPs).
- Insert the SIM card into the spring-loaded slot behind the small door on the front of the CP. The contact surface faces the front of the module, the cut corner points outward.
- Connect the GSM antenna to the SMA connector and route the cable away from the CPU's 24 V wiring.
- Power up the station. The STATUS LED should pulse green within a few seconds; the CONNECT LED remains off until the configuration has been downloaded.
5. SIM and APN Parameters
The CP must know how to attach to the GSM network even when only SMS is used, because subscriber authentication runs over the same cellular control plane.
| Parameter | Typical value | Notes |
|---|---|---|
| APN |
internet (most European operators), wap.cingular (legacy AT&T), telstra.internet (Telstra) |
Only used for GPRS attachment; can be left in place even if you only use SMS |
| APN user | blank / blank
|
Many consumer SIMs have no APN user |
| APN password | blank | — |
| Dial-in number | *99***1# |
Standard GPRS dial string |
| SMSC (Service Center) | Operator-provided, e.g. +491710760000
|
Auto-discovery works on most EU networks; for North American carriers, set explicitly |
| SIM PIN | Leave blank if PIN is disabled | If PIN is enabled on the SIM, enter it here; entering the wrong PIN three times will lock the SIM |
6. TIA Portal Project Structure
- Open TIA Portal V15 and create a new project: Project → New… with a meaningful name, for example
CP1242_SMS_Demo. - Insert an S7-1200 station: Add new device → Controllers → SIMATIC S7-1200 → CPU → your CPU (for example,
CPU 1217C DC/DC/DC, 6ES7217-1AG40-0XB0). - Open Device configuration on the CPU. The CP 1242-7 must be dragged from the hardware catalogue (Communication → CP 1242-7) onto the left slot of the CPU. The catalogue entry must read V2 (not V1).
- Save and compile the device configuration. The CP now appears as
CP 1242-7_1in the project tree.
7. CP 1242-7 V2 Configuration
Select the CP in the device view and configure the following tabs:
7.1 Ethernet addresses
Leave the IP address set to 0.0.0.0 if the station is purely SMS-driven. If you also intend to do telecontrol, assign a fixed IP and subnet mask that matches the LAN the CPU is on.
7.2 Mobile network
- APN: enter per Section 5.
- User name / Password: as supplied by the operator.
-
Dial-in number:
*99***1#. - SMSC address: leave blank for automatic, or enter the explicit center number.
- PIN: enter if the SIM requires one.
7.3 Time-of-day synchronisation (optional)
If the CPU clock must be synchronised via the cellular network, enable Synchronisation and select the NTP server of the mobile operator. SMS does not depend on this setting.
8. Importing the SMS Global Library
The library is not part of the TIA Portal installation. It is downloaded as a zipped archive from Siemens Support under entry 58638283.
- Go to Siemens Support Entry 58638283 and download the ZIP archive that contains the global library (
.zalfile) and the documentation PDF. - Extract the ZIP to a working folder. Locate the file
CP1242-7_SMS_Vxx.zal. - In TIA Portal, open the Libraries task card (right side of the workbench).
- Click the small icon "Open global library" in the toolbar of the Libraries task card.
- Navigate to the extracted
.zalfile and confirm. The library appears under Global libraries. - Expand the library. You will find the master copies:
-
CP1242_SMS (FB)— high-level wrapper used by the example program -
SndSms (FB)— send one SMS -
RcvSms (FB)— poll incoming SMS - Associated data block types and a UDT for phone numbers
-
- Drag
SndSmsandRcvSmsfrom Master copies into a new Program blocks folder of your CPU to instantiate them. TIA Portal will auto-generate instance DBs (SndSms_DB,RcvSms_DB).
CP1242_SMS master copy and no individual SndSms/RcvSms, you are looking at an older revision of the library. Open the documentation PDF and confirm that the block list matches your version. Older libraries used the same block names but added a CP1242_SMS aggregator; both architectures are documented.9. Resolving the Password Prompt
The example project shipped with the entry is protected against accidental editing. When you try to open the project, TIA Portal will ask for a User type, User name and Password. Three resolutions exist:
- Read the documentation, page 56. The project protection credentials, the block interface, and the ladder example are printed there. The credentials change between revisions; always cross-check against the PDF revision that ships with the library you downloaded.
- Create your own copy. Instead of opening the supplied project, create a fresh project (Section 6), then import only the global library (Section 8). The library itself is not write-protected; only the sample project is. You will then build the program from scratch against the unprotected library blocks.
- Strip the protection in TIA Portal. If you must edit the supplied project and you have the credentials, change the protection under Project tree → right-click project → Properties → Protection, set the protection level to "No protection", recompile, and save.
10. The SndSms Block Interface
| Port | Direction | Type | Description |
|---|---|---|---|
EN |
IN | BOOL | Master enable; rising edge triggers one send attempt |
REQ |
IN | BOOL | Send request latch (set TRUE for the duration of transmission) |
PhoneNumber |
IN | STRING[20] | Recipient in international format, e.g. '+49171...'
|
SmsText |
IN | STRING[160] | Payload; GSM 7-bit default alphabet, 160 chars max, 153 if concatenated |
DONE |
OUT | BOOL | One-shot TRUE on successful transmission |
BUSY |
OUT | BOOL | TRUE while a send is in progress |
ERROR |
OUT | BOOL | TRUE if transmission failed |
STATUS |
OUT | WORD | Error code (see Section 16) |
SMS_ID |
OUT | DWORD | Reference id assigned by the CP |
11. The RcvSms Block Interface
| Port | Direction | Type | Description |
|---|---|---|---|
EN |
IN | BOOL | Master enable; keep TRUE for continuous polling |
PollCyc |
IN | TIME | Polling interval, e.g. T#2s
|
NewSms |
OUT | BOOL | One-cycle TRUE when a new message is available |
PhoneNumber |
OUT | STRING[20] | Sender number (international format) |
SmsText |
OUT | STRING[160] | Decoded message body |
SmsTime |
OUT | DATE_AND_TIME | GSM timestamp |
ERROR |
OUT | BOOL | TRUE on poll/parse error |
STATUS |
OUT | WORD | Error code |
12. Building the Program (OB1 Skeleton)
The following LAD/ST skeleton wires the two blocks to a 2-Hz clock bit and a Boolean trigger.
Network 1 — RcvSms enable, always on
// RcvSms_DB (EN := TRUE, PollCyc := T#2s, NewSms => Tag_NewSms, ...)
Network 2 — SndSms trigger from a rising edge
// SndSms_DB (REQ := "SendTrig", PhoneNumber := '...', SmsText := 'Alarm: Tank High');
Network 3 — Acknowledge and parse the incoming command
IF Tag_NewSms THEN
// compare RcvSms_DB.SmsText against 'PUMP_ON', 'PUMP_OFF', 'STATUS'
// set corresponding output bits, latch until next command
END_IF;
+ and country code (+49 for Germany, +1 for North America). Numbers in national format will be rejected by some carriers or routed incorrectly when the CP is roaming.13. Compile and Download
- Right-click the CPU in the project tree → Compile → All. Resolve any type conflicts before downloading.
- Connect the engineering PG to the CPU via PROFINET or PROFIBUS.
- Right-click the CPU → Download to device → Hardware and software.
- In the download dialog, tick "Include SMSC and APN parameters" if your TIA Portal version prompts for it. This guarantees the mobile network configuration reaches the CP, not only the CPU.
- After the download, the CP will reset, register on the GSM network and attempt to attach to the GPRS APN. Registration takes 20-60 seconds on a cold boot.
14. Verification Procedure
- Open an online watch table on the instance DBs.
- Force
REQofSndSms_DBto TRUE. ExpectBUSYTRUE for 2-5 seconds, thenDONETRUE for one cycle and a non-zeroSMS_ID. - Check the recipient handset: an SMS with the text configured in
SmsTextmust arrive within 30 seconds. If the operator network is congested, delivery can take up to 5 minutes. - Send an SMS from a handset to the SIM number installed in the CP. Within the
PollCycinterval,NewSmsmust pulse TRUE andPhoneNumber/SmsTextmust populate. - From the handset, send the command string (e.g.
PUMP_ON). Verify that the corresponding Boolean is set in the CPU.
15. CP 1242-7 V2 LED Diagnostics
| LED | State | Meaning |
|---|---|---|
| STATUS | Solid green | CP configured and running |
| STATUS | Flashing green | No configuration / start-up |
| STATUS | Off | No power or hardware fault |
| CONNECT | Solid green | GPRS PDP context active |
| CONNECT | Flashing green | Logging in / attaching |
| CONNECT | Off | No GPRS context (SMS still works) |
| SIGNAL QUALITY | 3 green | Excellent (CSQ > 15) |
| SIGNAL QUALITY | 2 green | Good (CSQ 10-15) |
| SIGNAL QUALITY | 1 green | Marginal (CSQ 5-9) — SMS may delay |
| SIGNAL QUALITY | Off | No signal — re-locate antenna |
16. STATUS Word Error Codes (SndSms / RcvSms)
| Hex | Meaning | Corrective action |
|---|---|---|
0000 |
No error | — |
7000 |
No job active | Set REQ TRUE to start |
7001 |
First call / job running | Wait; poll BUSY
|
7002 |
Subsequent call | Internal handshake — normal |
80A1 |
SIM PIN wrong or SIM locked | Correct the PIN or unlock the SIM with a phone |
80A2 |
No network / no SIM | Check antenna, SIM insertion, operator coverage |
80A7 |
SMSC missing or rejected | Enter a valid SMSC in CP properties |
80B1 |
Phone number invalid | Use international format with leading +
|
80B2 |
Message text too long | Limit to 160 GSM 7-bit chars or use concatenation |
80C0 |
Network timeout | Check signal quality and APN; retry |
80C3 |
Operator rejected SMS | Verify recipient is not on a DND list, SMS plan active |
80F1 |
Internal CP firmware fault | Power-cycle; if persistent, reflash CP firmware |
17. Troubleshooting Matrix
| Symptom | Likely cause | Fix |
|---|---|---|
SndSms ERROR=TRUE, STATUS=80A2
|
SIM not seated or no coverage | Re-seat SIM; verify on a mobile phone first |
SndSms STATUS=80B1
|
Phone number malformed | Re-enter with + and country code |
| Library does not appear after import |
.zal extracted incorrectly or wrong version |
Re-download entry 58638283 and verify file integrity |
| Password prompt on opening the project | Project shipped under complete protection | Use page 56 credentials or build a fresh project against the unprotected library |
RcvSms NewSms never pulses |
Poll cycle too long, or message from a non-7-bit source | Reduce PollCyc to T#1s; have the sender use plain ASCII |
| CONNECT LED never lights but SMS works | APN attachment intentionally disabled | Expected when the project is SMS-only; ignore |
| SMS arrives with garbage characters | Sender used Unicode (UCS-2) on a non-ASCII alphabet | Constrain the sender to GSM 7-bit default alphabet |
| Block compiles only under V13 SP1, fails in V15 | Library uses an SCL construct incompatible with V15 | Re-download library version tagged for V15 or later |
18. Migration Notes
If you are upgrading an existing project from a CP 1242-7 V1 to a V2 module:
- The hardware article number changes from
6GK7242-7KX30-0XE0to6GK7242-7KX31-0XE0. The device configuration must be replaced, not patched. - Any program that uses
SEND_SMS/RECEIVE_SMSas native CFBs from the V1 catalogue will disappear after the swap and must be replaced with theSndSms/RcvSmslibrary blocks. - The TIA Portal project version can stay the same; only the device configuration and the program blocks need re-compilation.
19. Field-Commissioning Checklist
- Confirm CP part number
6GK7242-7KX31-0XE0on the label. - Verify SIM works in a mobile handset: outgoing SMS, incoming SMS, no PIN prompt.
- Insert SIM, attach antenna, power up.
- Download hardware + software to the S7-1200/CP pair.
- Wait for STATUS solid green (configuration accepted).
- Force one
SndSmsin the watch table; confirm DONE=TRUE and handset receives the message. - Send a command SMS from a handset; confirm
RcvSmspopulates and the user program reacts. - Log the
SIGNAL QUALITYLED state and the operator name (visible in the online diagnostics of the CP) for future maintenance.
Where do I download the SndSms and RcvSms blocks?
They are not part of TIA Portal. Download the global library ZIP from Siemens Industry Online Support entry 58638283 at support.industry.siemens.com/cs/ww/en/view/58638283, extract the .zal file, and open it from the Libraries task card.
What is the password for the example project?
Siemens does not publish a generic default. The credentials and the block interface description are listed on page 56 of the application example PDF (58638283_S7_1200_SMS_DOC_V13_en.pdf). As an alternative, create a fresh project and use only the unprotected global library.
My CP is a 6GK7242-7KX30-0XE0 (V1). Can I still send SMS?
No. The SMS function blocks require the V2 firmware (6GK7242-7KX31-0XE0). The V1 firmware does not expose the underlying CFBs and the library calls will return STATUS=80F1 at runtime. Replace the CP or keep it for telecontrol only.
Do I need an active GPRS data plan to send SMS?
No. SMS is delivered over the GSM control channel and does not require a PDP context. The APN must still be configured so the CP can attach to the operator, but the dial-in number and APN credentials can be generic (e.g. APN internet, user blank, password blank) if no data plan is purchased.
SndSms reports STATUS 80B1 even though the number looks correct.
Phone numbers must be in international format with a leading + and country code (e.g. +49171...). Numbers starting with a leading 0 or with spaces will be rejected. The CP does not interpret national prefixes.
The RcvSms block never reports a new message — is the polling wrong?
Verify PollCyc is no longer than a few seconds and that the CP has logged in (STATUS solid green). Also confirm the sender is using the GSM 7-bit default alphabet; Unicode messages from modern handsets can be silently dropped by the CP if the firmware revision is older than V2.1.