Modbus TCP Server Send SMS example: Difference between revisions

From Teltonika Networks Wiki
No edit summary
No edit summary
Line 67: Line 67:


The first 10 registers are reserved for the phone number ('''1 register = 4 symbols''') additionally you will require to put in front '+' which is equal to 00 here. If your number (together with 00) does not take 10 registers we will require you to fill out the left registers with 0 values, that's why we use the '''\u0000 symbol''', which means 0 value.
The first 10 registers are reserved for the phone number ('''1 register = 4 symbols''') additionally you will require to put in front '+' which is equal to 00 here. If your number (together with 00) does not take 10 registers we will require you to fill out the left registers with 0 values, that's why we use the '''\u0000 symbol''', which means 0 value.
Here we will explore two examples, one for the ASCII data type and one for the HEX.


----
----


'''Example Message request:'''
'''Example Message request for ASCII:'''


003706xxx1594\u0000\u0000\u0000\u0000\u0000\u0000\u0000test
003706xxx1594\u0000\u0000\u0000\u0000\u0000\u0000\u0000test
Line 78: Line 80:
'''Explanation:'''
'''Explanation:'''


* 00 = + symbol
* '''00''' - + symbol
* 3706xxx1594 = phone number
* '''3706xxx1594''' - phone number
* \u0000\u0000\u0000\u0000\u0000\u0000\u0000 - our number only takes up to 3 registers, all other registers will be filled with 0 value
* '''\u0000\u0000\u0000\u0000\u0000\u0000\u0000''' - our number only takes up to 3 registers(4 symbols = 1 register), all other registers will be filled with 0 value
* test - the message that will be sent
* '''test''' - the message that will be sent
 
----
 
'''Second example Message request for HEX:'''
 
30 30 33 37 30 36 78 78 78 31 35 39 34 00 00 00 00 00 00 00 74 65 73 74
 
----
 
'''Explanation:'''
 
* '''30 30''' - equals to 00(+ symbol)
* '''33 37 30 36 78 78 78 31 35 39 34''' - equals to 3706xxx1594 number
* '''00 00 00 00 00 00 00''' - our number only takes up to 3 registers(4 symbols = 1 register), all other registers will be filled with 0 value
* '''74 65 73 74''' - equals to 'test' in HEX
 
For this example you will need to use ASCII to HEX converter which will convert your number and message to HEX format, the one used in this example was: https://www.utilities-online.info/ascii-to-hex
 
Example of the conversion:
 
[[File:Networking rut configuration modbus tcp master ascii to hex v1.png|border|class=tlt-border|1100px]]


----
----

Revision as of 12:47, 31 January 2023

Main Page > General Information > Configuration Examples > Modbus > Modbus TCP Server Send SMS example

Introduction

The information on this page is updated in accordance with 00.07.03.2 firmware version. .

Modbus is a serial communications protocol. Simple and robust, it has become a de facto standard communication protocol and is now a commonly available means of connecting industrial electronic devices.

In this configuration example, we will configure Modbus TCP Slave and Modbus TCP Master. We will send a Set Parameters request from Modbus TCP Master to Modbus TCP Slave, which will send an SMS message provided in the Modbus TCP Master Set PArameter request.

If you're having trouble finding this page or some of the parameters described here on your device's WebUI, you should turn on "Advanced WebUI" mode. You can do that by clicking the "Basic" button under "Mode", which is located at the top-right corner of the WebUI.

Prerequisites

  • At least one TRB/RUT device with the SIM card, for this example we will be using one device
  • One end device (PC, Laptop, Tablet, Smartphone) to configure the router
  • One Mobile Phone in order to test the configuration

Configuring Modbus TCP Slave and Modbus TCP Master

Firstly, we will configure Modbus TCP Slave on the router and then on the same device we will configure Modbus TCP Master in order to send Modbus requests to the same device.


Configuring Modbus TCP Slave

In order to start our configuration you will need to open your device's WebUI (by entering the device's IP address of your device), then navigate to Services → Modbus → Modbus TCP Slave.

In order to configure Modbus TCP Slave follow the steps provided below:

Explanation:

  1. Enable the Modbus TCP Slave
  2. Select the port on which Modbus TCP Slave will communicate with the Modbus TCP Master (for this example: 502)
  3. Enable persistent connection (not mandatory)
  4. Save the configuration

Configuring Modbus TCP Master

Lets continue with the configuration, now we will configure Modbus TCP Master on the same device. Navigate to Services → Modbus → Modbus TCP Master. Press the button ADD and follow the steps provided below:

Explanation:

  1. Enable the instance
  2. Create a name for Modbus TCP Master
  3. Provide the Slave ID (in this case: 1)
  4. Provide IP address of the Slave ID, in this case, this router's IP (192.168.1.1)
  5. Provide Modbus TCP Slave ID (in this case 502)
  6. In this part we will configure two different SMS messages (hex and ASCII formats) and one send a request to send those messages, we will configure it a little bit later, so leave this part empty for now.
  7. Save the configuration

Configuring Modbus TCP Master Request Configuration

Now that we have Modbus TCP Master and Modbus TCP Slave configurated, we will need to create Request Configuration. The Request configuration will be used to store the SMS message and the number of the recipient. Lastly, we will send the SMS message to the recipient with the set Command. To store Phone numbers and SMS messages we will use ASCII and HEX Data Types, you can configure either one of them, and both of them will work.


So first of all, we will create a Request in which we will store the Recipient number and SMS message, we will use ASCII Data Type, Set Multiple holding registers(16) Function and 398 Register.


In the Register Count / Values field we will be written the ASCII format (human-readable format) and in the Data Type we will select ASCII format, so there will be no data conversion that it is why we will be writing in the human-readable format.


The first 10 registers are reserved for the phone number (1 register = 4 symbols) additionally you will require to put in front '+' which is equal to 00 here. If your number (together with 00) does not take 10 registers we will require you to fill out the left registers with 0 values, that's why we use the \u0000 symbol, which means 0 value.

Here we will explore two examples, one for the ASCII data type and one for the HEX.


Example Message request for ASCII:

003706xxx1594\u0000\u0000\u0000\u0000\u0000\u0000\u0000test


Explanation:

  • 00 - + symbol
  • 3706xxx1594 - phone number
  • \u0000\u0000\u0000\u0000\u0000\u0000\u0000 - our number only takes up to 3 registers(4 symbols = 1 register), all other registers will be filled with 0 value
  • test - the message that will be sent

Second example Message request for HEX:

30 30 33 37 30 36 78 78 78 31 35 39 34 00 00 00 00 00 00 00 74 65 73 74


Explanation:

  • 30 30 - equals to 00(+ symbol)
  • 33 37 30 36 78 78 78 31 35 39 34 - equals to 3706xxx1594 number
  • 00 00 00 00 00 00 00 - our number only takes up to 3 registers(4 symbols = 1 register), all other registers will be filled with 0 value
  • 74 65 73 74 - equals to 'test' in HEX

For this example you will need to use ASCII to HEX converter which will convert your number and message to HEX format, the one used in this example was: https://www.utilities-online.info/ascii-to-hex

Example of the conversion: