Changes

m
test50
Line 2: Line 2:  
In this guide Modbus TCP master MQTT Gateway function will be configured with two different types of MQTT Brokers. First using third party MQTT Broker services (in this example ''Flespi.io''). Second using RUT240 router as MQTT Broker. Two RUT955 routers will be used as Modbus TCP Master and Slave, and PC acts as MQTT Publisher and Subscriber.
 
In this guide Modbus TCP master MQTT Gateway function will be configured with two different types of MQTT Brokers. First using third party MQTT Broker services (in this example ''Flespi.io''). Second using RUT240 router as MQTT Broker. Two RUT955 routers will be used as Modbus TCP Master and Slave, and PC acts as MQTT Publisher and Subscriber.
    +
==Using flespi.io as Broker==
 
[[File:Networking Topology MQTT MODBUS flespi configuration v1.png|center|frameless|800x800px]]
 
[[File:Networking Topology MQTT MODBUS flespi configuration v1.png|center|frameless|800x800px]]
   −
==Configuring RUT955 Modbus TCP Slave==
+
===Configuring RUT955 Modbus TCP Slave ===
 
Go to '''Services > Modbus > Modbus TCP Slave''':
 
Go to '''Services > Modbus > Modbus TCP Slave''':
   −
# Check '''Enable'''
+
#Check '''Enable'''
 
# Enter port that will be used, in this example 502 will be used
 
# Enter port that will be used, in this example 502 will be used
 
# Enter device ID
 
# Enter device ID
# Press '''Save & Apply'''
+
#Press '''Save & Apply'''
 
[[File:Networking_MQTT_MODBUS_flespi_configuration_slave1_v1.png|alt=|border|1120x1120px]]
 
[[File:Networking_MQTT_MODBUS_flespi_configuration_slave1_v1.png|alt=|border|1120x1120px]]
   Line 17: Line 18:  
''Modbus TCP Slave RUT955 is now configured''.
 
''Modbus TCP Slave RUT955 is now configured''.
   −
==Configuring RUT955 Modbus TCP Master==
+
===Configuring RUT955 Modbus TCP Master ===
 
Go to '''Services > Modbus > Modbus TCP Master'''
 
Go to '''Services > Modbus > Modbus TCP Master'''
    
#Press '''Add'''
 
#Press '''Add'''
 
#Check '''Enable'''
 
#Check '''Enable'''
#Enter name for slave device
+
# Enter name for slave device
#Slave ID must match with previously configured Slave device ID
+
# Slave ID must match with previously configured Slave device ID
# Enter IP address of Modbus TCP Slave device
+
#Enter IP address of Modbus TCP Slave device
# Chose same Port as in Slave device - 502
+
#Chose same Port as in Slave device - 502
 
#Enter Period in seconds, how often requests will be sent to Slave device
 
#Enter Period in seconds, how often requests will be sent to Slave device
 
#Enter new request name and press '''Add''' in Requests configurations
 
#Enter new request name and press '''Add''' in Requests configurations
Line 33: Line 34:  
[[File:Networking_MQTT_MODBUS_flespi_configuration_master_add_v1.png|alt=|border|1136x1136px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_afteradd_step_234567_v1.png|alt=|border|736x736px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_req_config8up_v1.png|alt=|border|1111x1111px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_req_testing_v1.png|alt=|border|1109x1109px]]
 
[[File:Networking_MQTT_MODBUS_flespi_configuration_master_add_v1.png|alt=|border|1136x1136px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_afteradd_step_234567_v1.png|alt=|border|736x736px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_req_config8up_v1.png|alt=|border|1111x1111px]][[File:Networking_MQTT_MODBUS_flespi_configuration_master_req_testing_v1.png|alt=|border|1109x1109px]]
   −
==Configuring Flespi.io MQTT Broker==
+
===Configuring Flespi.io MQTT Broker===
 
Login or create an account on https://flespi.io
 
Login or create an account on https://flespi.io
   Line 40: Line 41:  
Once logged in:
 
Once logged in:
   −
# Navigate to MQTT Board on the left side of the screen and press it.                                              [[File:Networking MQTT Modbus flespi board.png|301x301px]]
+
#Navigate to MQTT Board on the left side of the screen and press it.                                              [[File:Networking MQTT Modbus flespi board.png|301x301px]]
 
#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''
 
#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 an username
 
#In the opened window, press "Get flespi token" to generate an username
Line 50: Line 51:  
[[File:Networking MQTT modbus fespi Connection settings v1.png|544x544px]]
 
[[File:Networking MQTT modbus fespi Connection settings v1.png|544x544px]]
   −
== Configuring MQTT Gateway on RUT955 Modbus TCP Master ==
+
===Configuring MQTT Gateway on RUT955 Modbus TCP Master===
 
Open routers WebUI and navigate to Services > Modbus > MQTT Gateway
 
Open routers WebUI and navigate to Services > Modbus > MQTT Gateway
    
# Select Enable
 
# Select Enable
# Enter Host (copied from flespi connection settings without 'wss://' and port)
+
#Enter Host (copied from flespi connection settings without 'wss://' and port)
# Enter Username (Copied from flespi Connection settings generated token)
+
#Enter Username (Copied from flespi Connection settings generated token)
# Enter Password
+
#Enter Password
    
[[File:Networking MQTT Modbus Rut configuration Mqtt gateway v1.png|border|1152x1152px]]
 
[[File:Networking MQTT Modbus Rut configuration Mqtt gateway v1.png|border|1152x1152px]]
Line 62: Line 63:  
''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''
 
''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===
 
Format is in text - heavier and slower, but less difficult to edit.
 
Format is in text - heavier and slower, but less difficult to edit.
 
{| class="wikitable"
 
{| class="wikitable"
Line 69: Line 70:  
|-
 
|-
 
|2. Cookie
 
|2. Cookie
|from '''0''' to '''2<sup>64</sup> -1'''  
+
|from '''0''' to '''2<sup>64</sup> -1'''
 
|-
 
|-
 
|3. IP Type
 
|3. IP Type
Line 80: Line 81:  
|Port number (for example: '''502''')
 
|Port number (for example: '''502''')
 
|-
 
|-
|6. Timeout in seconds (time to wait for response)
+
| 6. Timeout in seconds (time to wait for response)
 
|from '''1''' to '''999'''
 
|from '''1''' to '''999'''
 
|-
 
|-
Line 100: Line 101:  
[[File:Networking MQTT modbus message format publisher v1.png|border]]
 
[[File:Networking MQTT modbus message format publisher v1.png|border]]
   −
===Examples===
+
====Examples====
 
{| class="wikitable"
 
{| class="wikitable"
|Setting relay (on) (Relay address is 202, which means 'Number of first register will be 203)
+
| Setting relay (on) (Relay address is 202, which means 'Number of first register will be 203)
 
|'''0 65432 0 192.168.1.1 502 5 1 6 203 1'''
 
|'''0 65432 0 192.168.1.1 502 5 1 6 203 1'''
 
|-
 
|-
Line 109: Line 110:  
|}
 
|}
   −
== Testing MQTT Publisher and Subscriber on flespi.io ==
+
===Testing MQTT Publisher and Subscriber on flespi.io===
 
Login and navigate to MQTT Board on https://flespi.io
 
Login and navigate to MQTT Board on https://flespi.io
    
Add a subscriber:
 
Add a subscriber:
   −
# Press '''''<nowiki/>'+'''''' button on the top right corner
+
#Press '''''<nowiki/>'+'''''' button on the top right corner
# Select '''''<nowiki/>'Subscriber''''''
+
#Select '''''<nowiki/>'Subscriber''''''
# In the topic field enter '''''<nowiki/>'response''''''
+
#In the topic field enter '''''<nowiki/>'response''''''
# Press '''''<nowiki/>'Subscribe'''''' button
+
#Press '''''<nowiki/>'Subscribe'''''' button
    
[[File:Networking MQTT Modbus flespi subscriber config1 v1.png]]            [[File:Networking MQTT Modbus flespi subscriber config2 v1.png]]
 
[[File:Networking MQTT Modbus flespi subscriber config1 v1.png]]            [[File:Networking MQTT Modbus flespi subscriber config2 v1.png]]
      
Add a Publisher:
 
Add a Publisher:
   −
# Press '''''<nowiki/>'+'''''' button on the top right corner
+
#Press '''''<nowiki/>'+'''''' button on the top right corner
# Select '''''<nowiki/>'Publisher''''''
+
#Select '''''<nowiki/>'Publisher''''''
# In the topic field enter '''''<nowiki/>'request''''''
+
#In the topic field enter '''''<nowiki/>'request''''''
# In the message field enter message, for this example 'Getting uptime' is used
+
#In the message field enter message, for this example 'Getting uptime' is used
# Press '''''<nowiki/>'Publish'''''' button
+
#Press '''''<nowiki/>'Publish'''''' button
    
[[File:Networking MQTT Modbus flespi publisher config1 v1.png|434x434px]]          [[File:Networking MQTT Modbus flespi publisher config2 v1.png|365x365px]]
 
[[File:Networking MQTT Modbus flespi publisher config1 v1.png|434x434px]]          [[File:Networking MQTT Modbus flespi publisher config2 v1.png|365x365px]]
 +
 +
 +
Check the response in the '''''<nowiki/>'Subscriber'''''' tab, you should receive a message similar to the one below.
 +
 +
[[File:Networking MQTT Modbus flespi Response v1.png]]
 +
 +
''This Means that MQTT Gateway on Modbus TCP Master router is working correctly and Modbus TCP Slave receives requests.''
 +
 +
==Using RUT240 router as broker==
 +
 +
[[File:Networking Topology MQTT MODBUS RUTbroker configuration v1.png|987x987px]]
 +
 +
=== Configuring Modbus TCP Master, MQTT Gateway MQTT Broker on RUT240 and MQTT Publisher/Subscriber on PC ===
 +
''Same configuration will be used for Modbus TCP Master and Slave RUT955 routers as in previous example, only settings in Modbus TCP Master router RUT955 will be changed to match MQTT Broker on RUT240 router''

Navigation menu