Changes

581 bytes removed ,  17:19, 19 April 2023
no edit summary
Line 13: Line 13:  
[[File:Networking Topology MQTT MODBUS flespi configuration v1.png|center|class=tlt-border|800x800px]]
 
[[File:Networking Topology MQTT MODBUS flespi configuration v1.png|center|class=tlt-border|800x800px]]
   −
===Configuring RUT955 Modbus TCP Slave===
+
===Configuring RUT955 MQTT Gateway===
 
----
 
----
Go to '''Services → Modbus → Modbus TCP Slave''':
+
Go to '''Services → Modbus → MQTT Gateway''' and there:
   −
#Check '''Enable'''
+
# '''Enable''' the '''instance''';
#Enter port that will be used, in this example 502 will be used
+
# '''Enter Host''' (copied from flespi connection settings without 'wss://' and port);
#Enter device ID
+
# '''Enter Username''' (Copied from flespi Connection settings generated '''token''');
#Press '''Save & Apply'''
+
# '''Enter Password'''.
[[File:Networking_MQTT_MODBUS_flespi_configuration_slave1_v1.png|border|class=tlt-border|1044x1044px]]
     −
''*In this configuration LAN port is used hence “Allow Remote Access” is not needed''
+
[[File:MQTT Gateway config.png|border|center|class=tlt-border|862x412px]]
   −
''Modbus TCP Slave RUT955 is now configured''.
+
'''Note''': ''Everything else can be left as default or changed according to your needs.''
   −
===Configuring RUT955 Modbus TCP Master===
+
===Configuring RUT955 Serial Gateway===
 
----
 
----
Go to '''Services → Modbus → Modbus TCP Master'''
+
Under the MQTT Gateway configuration, create the Serial Gateway:
 +
# Enter the desired device ID;
 +
# Select the desired serial interface.
   −
#Press '''Add'''
+
[[File:Serial gateway config.png|border|center|class=tlt-border|868x308px]]
# Check '''Enable'''
  −
# Enter the name for the slave device
  −
# Slave ID must match with the previously configured Slave device ID
  −
#Enter the IP address of the Modbus TCP Slave device
  −
#Chose same Port as in Slave device - 502
  −
#Enter Period in seconds, how often requests will be sent to the Slave device
  −
#Enter new request name and press '''Add''' in Requests configurations
  −
#Choose Data type and Function, enter First register/coil/input to be read or written and Register count. You can name each individual configuration, and then select enable on configurations that you want to use. In this example, register to get Routers name is used.
  −
#Press the Test button in Request Configuration Testing to see if the Slave device responds to requests, a response similar to the image below should be shown.
  −
#Press Save & Apply
  −
''List of available Modbus parameters can be found [https://wiki.teltonika-networks.com/view/RUT955_Monitoring_via_Modbus#Get_Parameters here]''
  −
 
  −
[[File:Networking_MQTT_MODBUS_flespi_configuration_master_add_v1.png|alt=|border|class=tlt-border|1007x1007px]]
  −
 
  −
[[File:Networking MQTT MODBUS flespi configuration master afteradd step 234567 v2.png|border|class=tlt-border|1006x1006px]]
  −
 
  −
[[File:Networking MQTT MODBUS flespi configuration master req testing v3.png|border|class=tlt-border|1007x1007px]]
      
===Configuring Flespi.io MQTT Broker===
 
===Configuring Flespi.io MQTT Broker===
 
----
 
----
#Log in or create an account on https://flespi.io
     −
[[File:Networking MQTT Modbus flespiio login.png|border|class=tlt-border|842x842px]]
+
'''Log in''' or '''create an account''' on '''https://flespi.io''';
   −
Once logged in:
+
#Navigate to '''MQTT Board''' on the '''left side''' menu;                                       
 +
#On the right-hand panel, top right corner, next to the name of the MQTT board, press the cogwheel-looking icon to open ''Connection Settings'';
 +
#In the opened window, press "Get flespi token" to generate a username;
 +
#Enter the Client name;
 +
#Copy the Host address;
 +
#Copy Username;
 +
#Create a password.
   −
#Navigate to MQTT Board on the left side of the screen and press it.                                         
+
Once done, save all the changes
#On the right-hand panel, top right corner, next to the name of the MQTT board, press the cogwheel-looking icon to open ''Connection Settings''
+
[[File:Flespi board.png|border|center|class=tlt-border|1102x729px]]
#In the opened window, press "Get flespi token" to generate a username
  −
#Enter Client name
  −
#Copy Host address
  −
#Copy Username
  −
#Create a password
  −
#Press Save
  −
[[File:Networking MQTT modbus fespi Connection settings v1.png|border|class=tlt-border|544x544px]] [[File:Networking MQTT Modbus flespi board.png|border|class=tlt-border|544x544px]]  
     −
=== Configuring MQTT Gateway on RUT955 Modbus TCP Master===
  −
----
  −
Open routers WebUI and navigate to '''Services → Modbus → MQTT Gateway'''
  −
  −
#Select Enable
  −
#Enter Host (copied from flespi connection settings without 'wss://' and port)
  −
#Enter Username (Copied from flespi Connection settings generated token)
  −
#Enter Password
  −
  −
[[File:Networking MQTT Modbus Rut configuration Mqtt gateway v1.png|border|class=tlt-border|1058x1058px]]
  −
  −
''You can change Request and Response topics that you will have to publish and subscribe to get information from Modbus TCP Master through MQTT Gateway, but for this example, they are left on default topics''
      
===Message format for MQTT publisher===
 
===Message format for MQTT publisher===
 
----
 
----
 +
  <b>1 <COOKIE> <SERIAL_DEVICE_ID> <TIMEOUT> <SLAVE_ID> <MODBUS_FUNCTION> <FIRST_REGISTER> <REGISTER_COUNT/VALUES></b>
 +
 
The format is in the text - heavier and slower, but less difficult to edit.
 
The format is in the text - heavier and slower, but less difficult to edit.
 
{| class="wikitable"
 
{| class="wikitable"
 
|1.  Format version
 
|1.  Format version
|'''0'''
+
|'''1'''
 
|-
 
|-
 
|2. Cookie
 
|2. Cookie
 
|from '''0''' to '''2<sup>64</sup> -1'''
 
|from '''0''' to '''2<sup>64</sup> -1'''
 
|-
 
|-
|3. IP Type
+
|3. Serial device ID
|'''0''' - IPv4; '''1''' - IPv6; '''2''' - hostname
+
|a string used to identify a serial device. Must match with <u>Device ID</u> field in MQTT Gateway page Serial gateway configuration section
 
|-
 
|-
|4. IP
+
|4. Timeout
|IPv6 must be in full format (for example: '''2001:0db8:0000:0000:0000:8a2e:0370:7334''')
+
|timeout for Modbus connection, in seconds. Range [1..999].
 
|-
 
|-
|5. Port
+
|5. Slave ID
|Port number (for example: '''502''')
+
|Indicates to which slave request is sent
 
|-
 
|-
|6. Timeout in seconds (time to wait for response)
+
|6. Modbus function
|from '''1''' to '''999'''
+
|Modbus task type that will be executed. Possible values are:
 +
        <ul>
 +
            <li><b>1</b> - read coils;</li>
 +
            <li><b>2</b> - read input coils;</li>
 +
            <li><b>3</b> - read holding registers;</li>
 +
            <li><b>4</b> - read input registers;</li>
 +
            <li><b>5</b> - set single coil;</li>
 +
            <li><b>6</b> - write to a single holding register;</li>
 +
            <li><b>15</b> - set multiple coils;</li>
 +
            <li><b>16</b> - write to multiple holding registers.</li>
 +
        </ul>
 
|-
 
|-
|7. Slave ID - Indicates to which slave request is sent
+
|7. First register
|from '''1''' to '''255'''
+
|number (not address) of the first register/coil/input (in range [1..65536]) from which the registers/coils/inputs will be read/written to.
 
|-
 
|-
|8. Function
+
|8. Registry count
|'''3''' - read registers; '''6''' - write single register; '''16''' - write multiple registers
+
| <li><b>1</b> - <u>coil count</u> (in range [1..2000]); must not exceed the boundary (first coil number + coil count <= 65537);</li>
 +
            <li><b>2</b> - <u>input count</u> (in range [1..2000]); must not exceed the boundary (first input number + input count <= 65537);</li>
 +
            <li><b>3</b> - <u>holding register count</u> (in range [0..125]); must not exceed the boundary (first register number + holding register count <= 65537);</li>
 +
            <li><b>4</b> - <u>input register count</u> (in range [0..125]); must not exceed the boundary (first register number + input register count <= 65537);</li>
 +
            <li><b>5</b> - <u>coil value</u> (in range [0..1]);</li>
 +
            <li><b>6</b> - <u>holding register value</u> (in range [0..65535]);</li>
 +
            <li><b>15</b> - <u>coil count</u> (in range [1..1968]); must not exceed the boundary (first coil number + coil count <= 65537); and <u>coil values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with coil count); each value must be in the range of [0..1].
 
|-
 
|-
|9. Number of the first register from which information will be read or written
+
|9.register count
|from '''1''' to '''65535'''
+
|register count</u> (in range [1..123]); must not exceed the boundary (first register number + register count <= 65537); and <u>register values</u> separated with commas, without spaces (e.g., <i>1,2,3,654,21,789</i>); there must be exactly as many values as specified (with register count); each value must be in the range of [0..65535].
|-
+
|}
|10. Registry value
+
 
|If function is 3 - from '''1''' to '''123''' (first register + registry value can not go out of range);
+
 
If function is 6 - from '''0''' to '''65535'''
+
 
 +
 
   −
If function is 16 - from '''1''' to '''123''' (first register + registry value can not go out of range), Registry values separated by commas without spaces. Example.: '''1,2,3,654,21,789'''. There has to be as many values, as specified number of registers, and each value must be between '''0''' and '''65535'''. If number of registries is 0, there should be '''no registry values'''
  −
|}
  −
[[File:Networking MQTT modbus message format publisher v1.png|border|class=tlt-border]]
      
====Examples====
 
====Examples====

Navigation menu