Sending SMS

Some of our PLCs are equipped with LTE modem capable of sending SMS. In this tutorial we will learn how to configure such PLC and how to use function block for sending SMS.

Axon M/Lx65 Neuron S103-G

For sending SMS over LTE modem, you don't need to configure the modem as described in LTE configuration. Instead, you need to configure Alarm channel. Double click on the PLC in the Left panel. Select a Messaging subpanel, right click on the blank list of channels and select Add alarm channel from the context menu:

A new alarm channel will appear. By default it is filled with preconfiguration for sending emails. Click on the Type (now prefilled with “Smtp”) and change it to Gsm:

Move over to the channel's properties and change the Port Number to LTE:

If the SIM card is protected with a PIN code, enter it, otherwise leave empty:

Most modems (UniPi's as well) need initialization commands. Click to three-dot icon next to AT Commands Definition. A window will pop up:

In the drop down menu select the correct modem. For UniPi Axon product line it is UniPi Axon LTE:

Don't forget to apply this selection by clicking on Apply and closing this dialog:

The channel is configured and now the changes need to be commited. Click on the OK in the red bar:

To use the modem in program, look for “SendSMS Triggered” function block and place it into a program:

The function block expects 4 inputs and we will create a auxiliary variables for better debugging. Starting with the variable for input channel. Create a string variable and set its initial value to the name of the created alarm channel. By default it will be alrchannel:

The same we will do for the rest of the variables:

  • recipient: string variable containing a phone number in international format such as 00420777666555)
  • message: string variable containing the actual SMS message
  • trigger: bool variable which will execute the sending of the message on rising edge

The result should look similar:

Now deploy the solution and start the debugging mode. On each change of the variable trigger from False to True, the message will be send:

If the SMS has been send correctly, the Result output will be 0. Otherwise an error code will be issued and you can consult help (F1) for the given function block to determine the cause of the error.