Overview
Industrial alarm notification and remote telemetry over cellular networks remains one of the most resilient communications channels for SCADA applications. When IP networks are unavailable, unreliable, or cost-prohibitive, GSM Short Message Service (SMS) provides a low-bandwidth, store-and-forward channel that operates independently of customer LAN infrastructure. This reference covers the integration of Siemens SIMATIC S7-1200 and S7-1500 controllers with industrial GSM/GPRS modems for bidirectional SMS exchange, using AT commands issued over the CPU's serial interface or a CM (Communication Module).
Three reference architectures are documented:
- Direct PLC-to-modem control via TIA Portal function blocks writing AT commands through the onboard RS-232/RS-485 interface (e.g., on S7-1200 CB 1241, CM 1241, or S7-1500 CM PtP RS-232/422/485 modules).
- HMI-mediated SMS dispatch from a SIMATIC HMI (Comfort Panel, Unified Panel) using the WinCC flexible / TIA Portal script interface, as documented in Siemens Support Entry 21184132.
- Cloud SMS gateway (Azure Communication Services, Twilio, Sinch), where the PLC publishes the alarm to an MQTT broker or HTTP endpoint, and the cloud operator delivers the SMS. Microsoft's Azure Communication Services SMS quickstart documents the REST contract for the cloud path.
This reference focuses on the on-premises direct-modem path, which remains the dominant industrial practice for retrofit sites where local-area IP is not available or unreliable.
Prerequisites
| Item | Specification | Notes |
|---|---|---|
| Controller | SIMATIC S7-1200 (CPU 1211C/1212C/1214C/1215C/1217C) or S7-1500 (CPU 1511/1513/1515/1516/1517/1518) | Firmware ≥ V4.2 for S7-1200, ≥ V2.0 for S7-1500 |
| Serial module | CB 1241 RS-485 (with RS-232/RS-485-to-USB converter) or CM 1241 RS-232 / CM 1241 RS-422/485, or CM PtP for S7-1500 | Freeport / ASCII protocol mode |
| GSM modem | Siemens TC35i, MC35i, TC65, or third-party Wavecom Fastrack M1306B, Sierra Wireless GL6100, ELSist NETMOS, or Quectel M66 | 2G (GSM/GPRS) minimum; LTE Cat-M1 / NB-IoT for 4G replacement |
| Antenna | Quad-band GSM antenna, 50 Ω SMA | Place outside any metal enclosure |
| SIM card | 2G/3G/4G voice + SMS enabled, PIN removed, voicemail disabled | Operator must support SMS-Centre (SMSC) |
| TIA Portal | V16 or later (V17/V18 supported) | SCL / LAD / FBD editors |
| Power supply | 9-30 VDC for modem, sufficient current (TC35i peak ≈ 2 A during Tx burst) | Linear or regulated SMPS |
| Cabling | DB9 female-female null-modem cable, or RS-422 twisted pair | Maximum 15 m at 9600 baud |
Hardware Selection
| Modem | Technology | Interface | Power | Mounting | Status |
|---|---|---|---|---|---|
| Siemens TC35i | GSM 900/1800 GPRS class 10 | RS-232 (V.24) | 8-30 VDC, peak 2 A | DIN-rail via adapter | Discontinued (replacement: TC65) |
| Siemens MC35i | GSM 900/1800 GPRS class 8 | RS-232 | 8-30 VDC | DIN-rail | Discontinued |
| Siemens TC65 | GSM/GPRS, Java ME embedded | RS-232 + USB | 8-30 VDC | DIN-rail | Mature |
| Wavecom Fastrack Supreme 20 | GSM/GPRS | RS-232 (DB15) | 5-32 VDC | DIN-rail | Mature, widely supported |
| Sierra Wireless GL6100 | GSM/GPRS | RS-232 / USB | 8-30 VDC | DIN-rail | Obsolete (replacement: WP76xx) |
| ELSist NETMOS / NETMOS Lite | GSM, integrated PLC | RS-232/485/ETH | 10-30 VDC | DIN-rail | Active industrial SMS gateway |
| Quectel M66 | GSM 850/900/1800/1900 | UART | 3.4-4.3 VDC | Module only | Active |
| Quectel BG96 | LTE Cat-M1 / NB-IoT / GSM | UART + USB | 3.3-4.3 VDC | Module only | Active (4G migration) |
The TC35i remains the most documented modem for Siemens SMS integration; replacement parts in 2024-2026 should specify TC65, Quectel M66, or BG96 for LTE sites. For a fully integrated solution with no separate PLC, the ELSist NETMOS series bundles a small PLC core with an integrated GSM radio and is widely used in Italian industrial plants.
AT Command Reference for SMS
Modems accept Hayes AT commands. Only the commands relevant to SMS exchange are listed below. Each command terminates with <CR><LF>. The PLC must parse the echo and the result code to verify success.
| Command | Direction | Purpose | Typical Response |
|---|---|---|---|
| AT | PLC→Modem | Attention, presence check | OK |
| ATE0 | PLC→Modem | Echo off (recommended for PLC traffic) | OK |
| AT+CMGF=1 | PLC→Modem | Select text-mode SMS (UTF-8/GSM 7-bit) | OK |
| AT+CMGF=0 | PLC→Modem | Select PDU mode (binary, mandatory for Unicode) | OK |
| AT+CSCA="+39xxxxxxxxx" | PLC→Modem | Set SMSC number (often auto-provided by SIM) | OK |
| AT+CMGS="+393331234567" | PLC→Modem | Initiate SMS send to phone; prompt > returns |
> |
| <message body><CTRL-Z> | PLC→Modem | Transmit message terminated with SUB (0x1A) | +CMGS: <mr> OK |
| AT+CMGL="ALL" | PLC→Modem | List all stored messages | +CMGL: <idx>,"REC READ",<oa>,<ts><CR><LF><body>... OK |
| AT+CMGR=<idx> | PLC→Modem | Read message at index | +CMGR: ... <body> OK |
| AT+CMGD=<idx> | PLC→Modem | Delete message at index | OK |
| AT+CMGD=1,4 | PLC→Modem | Delete all read messages | OK |
| AT+CNMI=2,1,0,0,0 | PLC→Modem | Enable unsolicited +CMTI notification on new message arrival | OK |
| AT+CPIN? | PLC→Modem | Check SIM PIN status | +CPIN: READY (or +CPIN: SIM PIN) |
| AT+CREG? | PLC→Modem | Network registration status | +CREG: 0,1 (home) or 0,5 (roaming) |
| AT+CSQ | PLC→Modem | Signal quality | +CSQ: <rssi>,<ber> where rssi 0-31 |
| AT+CLIP=1 | PLC→Modem | Enable caller line ID (for voice fallback) | OK |
Error responses must be parsed:
-
+CMS ERROR: <err>— SMS-specific error; see 3GPP TS 27.005. -
+CME ERROR: <err>— Modem equipment error; see 3GPP TS 27.007.
SMS PDU vs Text Mode
Text mode (AT+CMGF=1) is the simplest: the body is a literal ASCII or GSM 7-bit string. It supports the GSM 7-bit default alphabet (160 characters) and UCS-2 (70 characters). The GSM 7-bit default character set misses several Latin-1 accented characters (e.g., è, à are in the extended table, but € and many others are not). For Italian or German plant text, prefer extended 7-bit (160 chars with escape-prefixed characters) or fall back to UCS-2 (70 chars).
PDU mode (AT+CMGF=0) submits the message as a hexadecimal string (e.g., 079193...). It is mandatory for:
- Unicode messages
- Concatenated SMS longer than 160 characters
- Flash SMS (class 0)
- Delivery reports
Most industrial SMS dispatch can stay in text mode for short 7-bit messages.
Step-by-Step: Sending SMS from TIA Portal
1. Configure the Serial Module
In the device configuration of the S7-1200 or S7-1500:
- Select the CM 1241 (RS-232) or CM PtP module.
- Set the port to Freeport (ASCII) mode.
- Set baud rate to 9600 8N1 (default for TC35i, MC35i, Wavecom).
- Enable "Send/receive break" and "Suppress additional CR/LF" as required by your modem firmware.
2. Build the Send Function Block
The following SCL code implements a state machine that:
- Waits for
bTrigger. - Issues
AT+CMGF=1\r. - Issues
AT+CMGS="+39xxxxxxxxx"\r. - Sends the message body terminated with
<CTRL-Z>(0x1A). - Waits for
+CMGS:andOK.
FUNCTION_BLOCK "FB_SendSMS_AT"
{ S7_Optimized_Access := 'TRUE' }
VERSION : 1.0
VAR_INPUT
bTrigger : BOOL; // Rising edge starts a send
sPhone : STRING[20]; // E.164 format, e.g. +393331234567
sBody : STRING[160]; // GSM 7-bit text
iTimeoutMs : INT := 5000; // Per-state wait limit
END_VAR
VAR_OUTPUT
bBusy : BOOL;
bDone : BOOL;
bError : BOOL;
wErrCode : WORD; // 0 = OK, else timeout/parser code
END_VAR
VAR
iState : INT := 0;
tonWait : TON;
sRxBuf : STRING[256];
END_VAR
BEGIN
CASE iState OF
0: // Idle - wait for trigger
bBusy := FALSE;
bDone := FALSE;
bError := FALSE;
wErrCode := 0;
IF bTrigger THEN
bBusy := TRUE;
iState := 10;
END_IF;
10: // AT+CMGF=1
"SND_SEND"(sCmd := CONCAT('AT+CMGF=1', '$R$L'));
iState := 20;
20: // Wait for OK
"RCV_RECV"(sRxBuf := sRxBuf);
IF FIND(sRxBuf, 'OK') > 0 THEN
iState := 30;
ELSIF FIND(sRxBuf, 'ERROR') > 0 THEN
bError := TRUE; wErrCode := 16#9001; iState := 99;
END_IF;
30: // AT+CMGS="<number>"
sRxBuf := '';
"SND_SEND"(sCmd := CONCAT(CONCAT('AT+CMGS="', sPhone), '"$R$L'));
iState := 40;
40: // Wait for '>' prompt
IF FIND("RCV_RECV_BUF"(), '>') > 0 THEN
iState := 50;
END_IF;
50: // Send body + CTRL-Z
"SND_SEND"(sCmd := CONCAT(sBody, '$1A')); // 0x1A = SUB = CTRL-Z
iState := 60;
60: // Wait for +CMGS confirmation
IF FIND("RCV_RECV_BUF"(), '+CMGS:') > 0 AND FIND("RCV_RECV_BUF"(), 'OK') > 0 THEN
iState := 80;
ELSIF FIND("RCV_RECV_BUF"(), '+CMS ERROR') > 0 THEN
bError := TRUE; wErrCode := 16#9003; iState := 99;
END_IF;
80: // Done
bDone := TRUE;
bBusy := FALSE;
iState := 0;
99: // Fault
bBusy := FALSE;
iState := 0;
END_CASE;
END_FUNCTION_BLOCK
The integrator must implement SND_SEND, RCV_RECV, RCV_RECV_BUF, RCV_BUF_CLEAR as wrappers around the Siemens Send_P2P / Receive_P2P library blocks from the "SIMATIC S7-1200 / S7-1500 Point-to-Point Communication" package.
3. Map to Ladder for Diagnostics
For field commissioning, expose iState, wErrCode, sRxBuf to a watch table and an HMI tag set. Plant electricians often find it easier to troubleshoot a 0-99 integer state than a nested SCL block; expose the current state on the HMI status line.
4. HMI-Triggered Send
In TIA Portal, create a button on a Comfort Panel screen. On MouseDown, set a tag that triggers bTrigger on the FB. The HMI tag does not need to be on the same CPU; on a Unified Panel you can use the "Send E-mail / SMS" runtime API directly:
| Runtime API | Method | Notes |
|---|---|---|
HMIRuntime.UI |
Screen.Items("BtnSend").EventHandler |
TIA Portal V17+ |
HMIRuntime.Alarming |
Logging.SendMail (legacy) |
WinCC flexible ≤ 2008 |
| Siemens FAQ 21184132 | HMI-side SMS via dial-up connection to modem | WinCC flexible 2008 SP2 / TIA Portal |
Per the Siemens Support Entry 21184132, the HMI can be configured with a dial-up connection (modem or GSM) using RAS, and SMS dispatch is handled via the WinCC flexible / TIA Portal alarm logging SMTP/SMS gateway. This is convenient when the PLC is headless but requires a SIM-equipped Comfort Panel.
Step-by-Step: Receiving SMS
Receiving requires unsolicited modem notification. Without it, the PLC must poll AT+CMGL="ALL", which is inefficient and adds radio load.
1. Enable Unsolicited Notifications
Send once at startup:
AT+CNMI=2,1,0,0,0
This causes the modem to issue +CMTI: "SM",<index> whenever a new SMS arrives in the SIM storage.
2. Receive State Machine
FUNCTION_BLOCK "FB_RecvSMS_AT"
VAR_INPUT
iTimeoutIdle : INT := 60000; // poll fallback
END_VAR
VAR_OUTPUT
sLastSender : STRING[20];
sLastBody : STRING[160];
bNewMessage : BOOL;
END_VAR
VAR
sRx : STRING[256];
iIdx : INT;
END_VAR
BEGIN
// Called every PLC cycle - filter URC tokens from the incoming buffer
"RCV_RECV"(sRx := sRx);
IF FIND(sRx, '+CMTI:') > 0 THEN
// Extract index between commas
iIdx := STRING_TO_INT(MID(sRx, FIND(sRx, ',') + 1, 3));
// Issue AT+CMGR=<iIdx> then delete
"SND_SEND"(sCmd := CONCAT(CONCAT('AT+CMGR=', INT_TO_STRING(iIdx)), '$R$L'));
bNewMessage := TRUE;
END_IF;
END_FUNCTION_BLOCK
For typical industrial deployments the body contains short commands such as ON1, OFF, RESET, or RST. Parsing logic compares the body to a fixed list of accepted commands and rejects anything else to avoid spoofed control.
3. Command Parsing
| Received text | Action |
|---|---|
ON1 |
Set M0.0 (Pump 1 run) |
OFF |
Reset all output bits |
RESET |
Acknowledge all alarms |
STAT |
Reply with current alarm summary |
| (anything else) | Reply UNKNOWN CMD and ignore |
Reply with the same FB_SendSMS block. Always whitelist source numbers (compare sLastSender to a tag list of allowed E.164 numbers) to prevent unauthorized control.
Verification
After commissioning, run the following sequence:
-
Cold-start test: power down the panel and modem; power up; confirm
ATreturnsOKwithin 10 s. -
Signal check:
AT+CSQshould return rssi ≥ 10 (≥ -85 dBm); below 5 the link is unreliable. -
SIM check:
AT+CPIN?returns+CPIN: READY; if+CPIN: SIM PIN, the SIM still has PIN protection enabled — remove via a phone or useAT+CPIN="1234"with the PIN. -
Network check:
AT+CREG?returns+CREG: 0,1or+CREG: 0,5. - Outbound: trigger an alarm and verify delivery to a mobile phone.
-
Inbound: from a phone, send
STATto the SIM and verify the PLC replies within 30 s. -
Power-fail: cut modem power for 5 s; on restore, verify the PLC re-initializes the modem (re-issues
ATE0,AT+CMGF=1,AT+CNMI=2,1,0,0,0). -
Watchdog: implement a cyclic heartbeat (PLC writes
ATevery 60 s); if noOKfor 5 cycles, raise an HMI alarm and cycle modem power via a relay.
Troubleshooting Matrix
| Symptom | Probable Cause | Fix |
|---|---|---|
No OK on AT
|
Wrong baud rate, inverted TX/RX, missing common ground | Verify baud; swap TD/RD; ensure DC common |
+CPIN: SIM PIN |
SIM has PIN lock | Remove PIN via phone, or AT+CPIN="<pin>"
|
+CREG: 0,2 then 0,3
|
No network, roaming blocked | Check antenna; verify operator coverage; check SIM activation |
+CSQ: 99,99 |
Modem not registered yet, or antenna disconnected | Wait 60 s; reconnect antenna |
AT+CMGS returns +CMS ERROR: 514
|
SIM not ready | Retry after +CPIN: READY
|
AT+CMGS returns +CMS ERROR: 500
|
Unknown cause; usually SMSC missing | Set AT+CSCA="+39xxxxxx"
|
AT+CMGS returns > but body not sent |
CTRL-Z missing | Verify 0x1A termination; check serial config for binary transparency |
PLC does not see +CMTI
|
AT+CNMI not set, or echo enabled floods buffer |
Send AT+CNMI=2,1,0,0,0 and ATE0
|
| Inbound body truncated at 160 chars | Text-mode 7-bit limit | Switch to PDU mode and concatenate (UDH), or split message |
Message body shows ? instead of è/à
|
7-bit default alphabet missing character | Use extended 7-bit, GSM escape 0x1B prefix, or UCS-2 |
| Modem memory full ("intasato") | Stored messages never deleted | Issue AT+CMGD=1,4 on every read |
ATE0 does not disable echo |
Different firmware on 4G modem | Use ATQ1 for quiet mode, or both |
Security and Operational Notes
- Whitelist caller IDs in the FB.
- Use a body-format challenge (e.g., PLC replies with a 4-digit OTP; command is executed only after OTP returned via second SMS).
- Disable SIM OTA update and avoid leaving the modem exposed on the public Internet (no port-forwarding to RS-232).
- Require operator-grade SMS filtering where supported (e.g., Vodafone "Network Manager").
Cloud Alternative: Azure Communication Services SMS
For greenfield sites without legacy 2G modems, the PLC can call a cloud SMS gateway over MQTT or HTTPS. The PLC's data block contains the recipient list and message body; an HMI script or a Python runtime on the SIMATIC IOT2050 publishes to an MQTT topic; a Lambda or Azure Function consumes the topic and calls Azure Communication Services SMS send:
POST https://<resource>.communication.azure.com/sms/send?api-version=2021-03-07
Content-Type: application/json
Authorization: Bearer <token>
{
"from": "+393331234567",
"smsRecipients": [ { "to": "+393337654321" } ],
"message": "Alarm: Tank 3 high level",
"smsSendOptions": { "enableDeliveryReport": true }
}
This trades a hardware modem for an Internet dependency — acceptable for sites with reliable IP, inappropriate for remote sites with no LAN. Latency is typically 1-5 s end-to-end, comparable to direct-modem SMS dispatch (1-3 s).
FAQ
What baud rate should I configure between the S7-1200 and TC35i modem?
Use 9600 8N1 with hardware flow control disabled. The TC35i and MC35i default to 9600 baud at power-up; AT&W saves the change to NVRAM. For LTE Cat-M1 modems (BG96), start at 115200.
Why does my Comfort Panel not show the SMS option in alarm logging?
SMS dispatch via alarm logging requires a configured modem or RAS dial-up connection on the HMI itself, not on the PLC. See Siemens Support Entry 21184132 for the WinCC flexible / TIA Portal configuration procedure, which requires the HMI to host a dial-up adapter and a configured SMSC number.
Can I send Unicode (emoji, Chinese) characters from the PLC?
Yes, but only in PDU mode (AT+CMGF=0). The PLC must encode the body as UCS-2 little-endian, prefix the UDH with the data-coding-scheme byte 0x08, and submit as hex string. The SMS length drops to 70 characters per part; concatenated SMS up to 1530 characters per part is achievable with UDH concatenation headers.
My modem returns +CMS ERROR 515 — what does that mean?
3GPP TS 27.005 code 515 is "SIM PIN required" — the SIM has not been unlocked. Either remove the PIN via a mobile phone, or issue AT+CPIN="<pin>" from the PLC at startup. Note: many industrial sites ban PIN-protected SIMs because the modem becomes bricked if it forgets the PIN after a firmware upgrade.
How do I handle concatenated SMS (longer than 160 characters)?
Switch to PDU mode (AT+CMGF=0) and use the Information Element 0x00 (concatenated SMS, 8-bit reference). The first part contains UDH 05 00 03 <ref> <total> <seq>. Reassemble parts on the receiver side by sorting on the (ref, seq) tuple. For PLC dispatch, use a user library that chunks the body into 153-character parts (7-bit) or 67-character parts (UCS-2).