This is an old revision of the document!


Receiving/sending SMS

Some of our PLCs are equipped with a GSM module that is capable of sending and receiving SMS. In this tutorial, we will learn how to configure such PLC and how to use function blocks for sending SMS.

Neuron S103-G

To send an SMS, it is necessary to set up communication with the modem, using the Alarm channel. Double-click on the PLC in the Left panel. Select the Messaging subpanel, right-click on the blank channel list and select Add alarm channel from the context menu:


A new alarm channel will appear. By default, it is set to send e-mail messages. 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 COM1 (TTL):


If the SIM card is protected with a PIN code, enter it in the appropriate, otherwise leave it 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:


Then select the correct modem from the drop-down menu. For Unipi Neuron controllers, this is the Unipi Neuron GSM - G510:


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 committed. 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.