User Guide for ADVANTECH models including: Modbus To MQTT Router App, Modbus, To MQTT Router App, MQTT Router App, Router App

RouterApp User Manual

Modbus to MQTT

routerapp, manual, Modbus to MQTT

Advantech

Modbus-MQTT Application Note 20231013

Router Apps - Cellular Routers Engineering Portal


File Info : application/pdf, 15 Pages, 687.84KB

PDF preview unavailable. Download the PDF instead.

modbus-mqtt-application-note-20231013
Modbus to MQTT
Advantech Czech s.r.o., Sokolska 71, 562 04 Usti nad Orlici, Czech Republic Document No. APP-0087-EN, revision from 12th October, 2023.

© 2023 Advantech Czech s.r.o. No part of this publication may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photography, recording, or any information storage and retrieval system without written consent. Information in this manual is subject to change without notice, and it does not represent a commitment on the part of Advantech.
Advantech Czech s.r.o. shall not be liable for incidental or consequential damages resulting from the furnishing, performance, or use of this manual.
All brand names used in this manual are the registered trademarks of their respective owners. The use of trademarks or other
designations in this publication is for reference purposes only and does not constitute an endorsement by the trademark holder.

Used symbols
Danger ­ Information regarding user safety or potential damage to the router. Attention ­ Problems that can arise in specific situations. Information ­ Useful tips or information of special interest. Example ­ Example of function, command or script.

Contents

1. Changelog

1

1.1 Modbus to MQTT Changelog . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

2. Description of the module

3

3. Web Interface

4

3.1 Router . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.1 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3.1.2 Config file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 3.1.3 Mapping table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1.4 MQTT Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10

4. Related Documents

11

List of Figures

1 Menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 3 CSV file . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 4 CVS file import . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 5 Mapping table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
List of Tables

1 Settings Example Items Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2 Configuration items description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

1. Changelog
1.1 Modbus to MQTT Changelog
v2.0.5 · Change openssl (1.0.2u) to static library.
v2.0.6 · Add option of Azure SAS-token generation. · Need to install Python3 user module. · Add Data Type: Double World - Frame. · Add "Byte Swap" field in csv file. · Add supported Data type "String". · Add "Word Swap" and "Byte Swap" for String Data Type.
v2.0.7 · Add show mosquitto error code and error message in the connected/disconnected function.
v2.0.8 · Add upload local cert and local key features for AWS.
v2.0.9 · Change modbus command maximum from 100 to 500.
v2.0.10 · Add polling the user module processes for each 5 seconds, if the user module crashed, it will run again.
v2.0.11 · Add "Custom2 Field" field in csv file. · Add "Send Group" field in csv file, for MQTT send group feature. · Add "Send interval" field in csv file, for MQTT send group feature.
v2.0.12 · Add Azure SAS-token generation (without Python3 user module). When Python3 user module installed, it will to use SAS-token generation by python.
v2.0.13 · Added ability to edit CSV, CA certificate, Local certificate and Local Private Key from WebUI.
v2.0.14

Modbus to MQTT Manual

1

1.1 Modbus to MQTT Changelog
· Fixed issue when the Router App mb2mqtt is loading default configuration after Firmware update. v2.0.15
· Fixed an issue with displaying space values in the Mapping Table page. · Fixed an issue where the old value was displayed in the Mapping Table page when the configuration
value was empty. v2.0.16
· For WADMP: Fixed the issue that the default value has whitespaces. v2.0.17
· To support Integer with 2 bytes size (Example: convert 0xFFFF to -1). · Set permissions to 755 for all files in the User Module. v2.0.18 · Fixed an issue with integer-to-float conversion. · Add more log message for MQTT value. v2.0.19 · Increase Custom Fields to 10 (CSV configuration fields : Q, R, U AB) v2.0.20 · Fixed an issue where configuration comments were causing issues in the management system
WADMP.

Modbus to MQTT Manual

2

2. Description of the module
This Router app is not contained in the standard router firmware. Uploading of this router app is described in the Configuration manual (see Chapter Related Documents).
The router app is v2 router platform compatible.
Modbus to MQTT is an router app for providing seamless communication between Modbus/TCP devices and MQTT device. Modbus to MQTT works as Modbus/TCP master to communicate with Modbus/TCP devices, and works as MQTT publisher/subscriber to communicate with MQTT broker.

Modbus to MQTT Manual

3

3. Web Interface
Once the installation of the module is complete, the module's GUI can be invoked by clicking the module name on the Router Apps page of router's web interface.
Left part of this GUI contains menu with Router menu section. Return to Router menu section switches back from the module's web page to the router's web configuration pages. The main menu of module's GUI is shown on Figure 1.
Figure 1: Menu

Modbus to MQTT Manual

4

3.1 Router
3.1 Router
3.1.1 Settings
Configuration of this router app can be done on Settings page, under Router menu section. All configuration items for Settings configuration page are described in the table below.

Figure 2: Settings

Modbus to MQTT Manual

5

3.1 Router

Item Service Enable
Log Enable APN Broker Address Broker Server Port MQTT Keepalive MQTT QoS MQTT Retain Client ID MQTT Anonymous MQTT Username MQTT Password MQTT TLS Interval(ms) Timeout(ms) CSV Config CA Certificate Local Certificate Local Private Key

Description Enabled, Modbus to MQTT APN functionality of the module is turned on. Enable the Service Log. Enter the remote Broker Server Address. Enter Broker Server Port Number (1-65535). Enter MQTT keepalive interval (1-3600). Enter MQTT QoS value (0,1,2). Enable for message retaining. Enter Client ID. Enable MQTT Anonymous Enter MQTT Username. Enter MQTT Password. Enable MQTT TLS. Enter Modbus TCP Polling Interval. Enter Modbus TCP Timeout. Upload the file containing your CSV config here. Upload your CA Certificate here. Upload your Local Certificate here. Upload your Local Private Key here.
Table 1: Settings Example Items Description

Modbus to MQTT Manual

6

3.1 Router
3.1.2 Config file
In Modbus to MQTT, user configures the mapping between Modbus/TCP and MQTT through CSV file. In the csv file, the field separator (delimiter) is a comma.

Item Topic Name IP Port Device ID Function Code
Address Data length Modbus Data type

Figure 3: CSV file
Description MQTT topic The name to identify the mapping. The Modbus device IP address. The TCP port number of the remote Modbus slave device. The Modbus/TCP slave ID. Modbus Function Code (FC). In Modbus to MQTT, supported function codes are: 1, 2, 3, 4, 5, 6, 15, 16 01: Read coils; 02: Read discrete inputs; 03: Read holding registers; 04: Read input register; 05: Write single coil; 06: Write single register; 15: Write multiple coils; 16: Write multiple registers.
Designate the read from/write to starting address for the Modbus registry. When FC=1, 2, 5 or 15, the unit is bit(s) When FC=3, 4, 6 or 16, the unit is word(s) Modbus data type. Options: Boolean, Integer, Unsigned Integer, Float
Continued on the next page

Modbus to MQTT Manual

7

3.1 Router

Item Data Swap
Byte Swap
MQTT Data type Multiplier Offset Polling Interval (ms) Send When Change Custom Field Custom2 Field Send Group Send Interval

Continued from previous page
Description
The Data Swap field determines the order in which the particular bytes of the received/transmitted data are delivered. None: Do not swap; Word: 0x01, 0x02 becomes 0x02, 0x01; Double Word: 0x01, 0x02, 0x03, 0x04 becomes 0x04, 0x03, 0x02, 0x01. Double Word - Frame: 0x01, 0x02, 0x03, 0x04 becomes 0x04, 0x03, 0x02, 0x01. Quad Word: 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07980 becomes 0x07980, 0x05, 0x06, 0x03, 0x04, 0x01, 0x02.
Option: True, False When option is True: 0x01, 0x02 becomes 0x01, 0x02. 0x01, 0x02, 0x03, 0x04 becomes 0x01, 0x02, 0x03, 0x04.
MQTT data type. Options: Boolean, Integer, Unsigned Integer, Float, Long Integer, Unsigned
The value used to multiply the data value.
The value used to add/substract the data value.
Modbus Polling Interval, unit: milliseconds. The value range: 1 10000000
Select that the data is sent immediately when change happens on modbus slave. Options: Yes, No
Custom definition value
Custom definition value
Set group number for MQTT multiple messages to one message. The value range is from 0 to 500. When the value is 0, this feature is disabled.
Send MQTT message interval for the group in seconds. The value range is from 1 to 10000 seconds.
Table 2: Configuration items description

Modbus to MQTT Manual

8

3.1 Router
The CSV file can be imported into Advantech router in router app Setting WEB page. After import CSV file and click "Save" button, the new mapping configuration will take effect immediately.

Figure 4: CVS file import

Modbus to MQTT Manual

9

3.1 Router
3.1.3 Mapping table
The Modbus/TCP to MQTT mapping will be shown in Mapping Table WEB page.
Figure 5: Mapping table
3.1.4 MQTT Data Format
When Modbus/TCP FC is 1, 2, 3 or 4, Modbus to MQTT will work as MQTT publisher to post Modbus/TCP data in JSON format to MQTT broker. When Modbus/TCP FC is 5, 6, 15 or 16, Modbus to MQTT will work as MQTT subscriber to ask subscription information, and forward the data to Modbus/TCP device.
Here are the example of MQTT data that is published from Modbus to MQTT.
 t    t        tr    rt         rss   t t  

Note that Modbus to MQTT verify just topic, name and value fields of the received subscription information.
 t     


Modbus to MQTT Manual

10

4. Related Documents
You can obtain product-related documents on Engineering Portal at icr.advantech.cz address. To get your router's Quick Start Guide, User Manual, Configuration Manual, or Firmware go to the Router Models page, find the required model, and switch to the Manuals or Firmware tab, respectively. The Router Apps installation packages and manuals are available on the Router Apps page. For the Development Documents, go to the DevZone page.

Modbus to MQTT Manual

11



References

MiKTeX pdfTeX-1.40.24 LaTeX with hyperref