To improve the user experience on this site we use cookies. I agree | I disagree

How to convert Modbus-RTU into MQTT

In category Routers .


 For converting Modbus-RTU data into MQTT, the following Router-Apps are required:

 

• “MODBUS-RTUMAP: o https://icr.advantech.cz/products/software/user-modules#protocol-modbus-rtumap

• “Modbus to MQTT”: o https://icr.advantech.cz/products/software/user-modules#modbus-mqtt

• “MQTT Broker” - OPTIONAL: o https://icr.advantech.cz/products/software/user-modules#mqtt-broker

This setup is available for all v2 and v3 routers that are equipped with the serial port interface.

 

 

 

Reading Modbus serial data via Router-App “MODBUS-RTUMAP”

The Router-App “MODBUS-RTUMAP” converts serial protocol Modbus RTU from different Modbus slaves (up to 10) and is mapping their data to one Modbus TCP connection.

The serial data are being forwarded to the localhost IP address (127.0.0.1) on port 502 and internal register 40000 (this can be modified).

 Example configuration:

 

Reading Modbus-TCP data via Router-App “Modbus to MQTT”

The Router-App “Modbus to MQTT” is reading the register 40000 on IP-address 127.0.0.1 and forwarding it to the MQTT Broker, which can be external or internal on the device itself (see point 3).

Example configuration:

 

Example CSV configuration:

Topic,Name,IP,Port,Device ID,Function Code,Address,Data Length,Modbus Data type,Data Swap,Byte Swap,MQTT Data Type,Multiplier,Offset,Polling Interval,Send When Change,Custom Field

env2,DI2,127.0.0.1,502,1,3,40000,1,Integer,None,FALSE,Integer,1,0,1000,No,0

env2,DI2,127.0.0.1,502,1,3,40001,1,Integer,None,FALSE,Integer,1,0,1000,No,0

MQTT Broker (optional)

If there is no external/central MQTT-Broker available, it can also run on the device itself, by the use of the Router-App “MQTT Broker”.

Example configuration:

 

To the FAQ overview