Difference between revisions of "Modbus TCP Master MQTT Gateway"

From Teltonika Networks Wiki
m
m (test2 no borders)
Line 11: Line 11:
 
# 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|border|1120x1120px|*In this config LAN port is used so “Allow Remote Access” is not needed Modbus TCP Slave RUT955 is now configured.
 
|alt=|left]]
 
 
''*In this config LAN port is used so “Allow Remote Access” is not needed''
 
''*In this config LAN port is used so “Allow Remote Access” is not needed''
  
Line 25: Line 24:
 
#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 32: Line 31:
 
#Press Test button in Request Configuration Testing to see if Slave device respond to requests, response similar to image below should be shown.
 
#Press Test button in Request Configuration Testing to see if Slave device respond to requests, response similar to image below should be shown.
 
#Press Save & Apply
 
#Press Save & Apply
[[File:Networking MQTT MODBUS flespi configuration master add v1.png|border|1136x1136px|alt=|left]]
+
[[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 afteradd step 234567 v1.png|border|left|736x736px]]
+
 
[[File:Networking MQTT MODBUS flespi configuration master req config8up v1.png|border|1111x1111px|alt=|left]]
 
[[File:Networking MQTT MODBUS flespi configuration master req testing v1.png|1109x1109px|alt=|border|left]]
 
 
==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
 +
 +
[[File:Networking MQTT Modbus flespiio login.png|842x842px]]
 +
 +
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]]
 +
#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
 +
#Enter Client name
 +
#Copy Host address
 +
#Copy Username
 +
#Create a password
 +
#Press Save
 +
[[File:Networking MQTT modbus fespi Connection settings v1.png|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|1152x1152px]]
 +
 +
''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''

Revision as of 09:50, 12 July 2022

Summary

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.

Networking Topology MQTT MODBUS flespi configuration v1.png

Configuring RUT955 Modbus TCP Slave

Go to Services > Modbus > Modbus TCP Slave:

  1. Check Enable
  2. Enter port that will be used, in this example 502 will be used
  3. Enter device ID
  4. Press Save & Apply

*In this config LAN port is used so “Allow Remote Access” is not needed

Modbus TCP Slave RUT955 is now configured.

Configuring RUT955 Modbus TCP Master

Go to Services > Modbus > Modbus TCP Master

  1. Press Add
  2. Check Enable
  3. Enter name for slave device
  4. Slave ID must match with previously configured Slave device ID
  5. Enter IP address of Modbus TCP Slave device
  6. Chose same Port as in Slave device - 502
  7. Enter Period in seconds, how often requests will be sent to Slave device
  8. Enter new request name and press Add in Requests configurations
  9. 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 WAN IP address of the slave device is used.
  10. Press Test button in Request Configuration Testing to see if Slave device respond to requests, response similar to image below should be shown.
  11. Press Save & Apply

Configuring Flespi.io MQTT Broker

Login or create an account on https://flespi.io

Networking MQTT Modbus flespiio login.png

Once logged in:

  1. Navigate to MQTT Board on the left side of the screen and press it. Networking MQTT Modbus flespi board.png
  2. 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
  3. In the opened window, press "Get flespi token" to generate an username
  4. Enter Client name
  5. Copy Host address
  6. Copy Username
  7. Create a password
  8. Press Save

Networking MQTT modbus fespi Connection settings v1.png

Configuring MQTT Gateway on RUT955 Modbus TCP Master

Open routers WebUI and navigate to Services > Modbus > MQTT Gateway

  1. Select Enable
  2. Enter Host (copied from flespi connection settings without 'wss://' and port)
  3. Enter Username (Copied from flespi Connection settings generated token)
  4. Enter Password

Networking MQTT Modbus Rut configuration Mqtt gateway v1.png

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