(IA44B)Modbus to MQTT: Difference between revisions

From Silbo Networks
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 12: Line 12:
Login to router using default IP 192.168.10.1 and default credentials admin/admin.
Login to router using default IP 192.168.10.1 and default credentials admin/admin.


[[File:Log In.png|frameless|624x624px]]Once login we can see the FW version.
[[File:Log In.png|frameless|624x624px]]


[[File:Firmware Version Dashboard.png|frameless|624x624px]]To change the IP address of router, Navigate to Settings>>Network and change “SW_LAN DHCP Server IP” save and update.
 
Once login we can see the FW version.
 
 
[[File:Firmware Version Dashboard.png|frameless|624x624px]]
 
 
To change the IP address of router, Navigate to Settings>>Network and change “SW_LAN DHCP Server IP” save and update.


[[File:SW LAN DHCP Server IP.png|frameless|624x624px]]
[[File:SW LAN DHCP Server IP.png|frameless|624x624px]]
Line 80: Line 87:
'''Custom Mapping''' allows configurating Tag name and datatype for each register separately.
'''Custom Mapping''' allows configurating Tag name and datatype for each register separately.


[[File:Register mapping.png|frameless|624x624px]]To update the configuration click on “Update Device”
[[File:Register mapping.png|frameless|624x624px]]
 
 
To update the configuration click on “Update Device”
 
 
[[File:Update Device Register maping.png|frameless|624x624px]]
[[File:Update Device Register maping.png|frameless|624x624px]]
== '''Chapter 3: MQTT Broker configuration''' ==
'''Hosting hivemqtt broker.'''
'''Login to hivemq platform using below URL.'''
URL: <nowiki>https://www.hivemq.com/</nowiki>
Click on MQTT.
Select Public MQTT Broker
Click on MQTT browser client
[[File:HiveMQ.png|frameless|624x624px]]
'''Chapter 4: Modbus data Publisher Configuration'''
1. Cloud configuration.
2. Source configuration.
3. send configuration.
Cloud Configuration:
Login to router/gateway and navigate Configuration>>Cloud Configuration.
Configure the broker URL, Port, Topic etc as shown and save.
[[File:HiveMQ Cloud Configuration.png|frameless|624x624px]]
Source configuration
Source configuration allows configuring the polling frequency time.
How frequently the data should be collected by Router/gateway from Modbus slave devices.
Minimum polling freq. time is 60 seconds.
Note: this time remains same for both RTU and TCP slaves.
[[File:Source Configuration HiveMQ.png|frameless|624x624px]]
Send configuration:
Send configuration allows to choose type of string that should be sent to a cloud platform.
SILBO devices do offer 3 different options as shown below.
CSV
Fixed JSON
Editable JSON.
[[File:Send Configuration.png|frameless|624x624px]]
JSON option is the editable JSON option whereas CSV allows fixed CSV and JSON option.
[[File:Data sender Configuration.png|frameless|624x624px]]
Example of Fixed JSON. 
{"site_id":"Invendis","timestamp":"2024-05-16 15:55:51","rec_no":1,"request_id":1,"interface_id":1,"equiment_id":"1","equiment_model":"ABCD","slave_id":1,
"func_code":1,"commstatus":0,"startreg":1,"totalreg":10,"":"1-2-3-4-5-6-7-8-9-10"}
In this format we can change "site_id", "equipment_id", "equipment_model" information can be configured as per site requirement. Other parameter will remain same in the string values will keep on changing.
JSON option allows editable JSON in which we can change which parameters should be sent and also what name we should use to the tag.
[[File:Data sender configuration editing.png|frameless|624x624px]]
What changes we can do in JSON edit to the above list.
Lets change slave_id to some other name as “Slave number”
[[File:Slave Number.png|frameless|624x624px]]
Even custom fields can be added, for example if location name should be sent by router/gateway in JSON packet then it can be configured as shown.
[[File:Custom Configuration.png|frameless|624x624px]]
These all changes should be saved into backend and to do that navigate to Appmanager>> Application Start/Stop.
Click on update to save all the changes made in configuration section.
Once updated click on start.
[[File:Application Manager.png|frameless|624x624px]]
Make sure application is started, once started it can be seen start option is replaced by Stop as below.
[[File:Application Manager Dashboard.png|frameless|624x624px]]
Now the data should come on the broker that we hosted on hivemqtt.
[[File:HiveMQ Connection Setup.png|frameless|624x624px]]
The JSON Custom parameter can be seen as “Location” with the fixed value “Pune-Plant1” is also present in above image.  
Also “Slave_id” became “Slave Number” as per the changes were made in configuration.
Note: “commstatus” is an important parameter that talks about the communication between router/gateway and Modbus slave device as connected is “commstatus” is “0” Modbus slave is not connected or not responding to the request & if value is “255” then the communication is healthy.
“Commstatus” parameter can be used to accept or reject the data from cloud side.
Note: Screenshot showing Modbus data on JSON showing 100 registers data, that is old data sent first by the router as it keeps old data was present in the router flash.
The router keeps all the data not published to cloud due to no internet or broker is not working etc and once the reachability is back device starts publishing the old data first and then latest as it works in FIFO (First in and first out). The total record a device can store is 2000 records and if more records need to be stored then the router/gateway with wMMC can be used.

Latest revision as of 04:28, 30 July 2024

Prerequisite:

  • Modbus RTU Slave (Used ModSIM application as slave in this manual)
  • USB to RS485 converter.
  • SILBO gateway (IA44B is used in this manual)
  • MQTT Broker (Hivemqtt)
  • SIM card with active internet

Note: This document is prepared using SILBO 1.16_1.13_RC4 FW version & App manager FW as 1.06_RC3 build 1.02

Chapter 1: SILBO gateway Network configuration

Login to router using default IP 192.168.10.1 and default credentials admin/admin.


Once login we can see the FW version.



To change the IP address of router, Navigate to Settings>>Network and change “SW_LAN DHCP Server IP” save and update.


To change Cellular settings for special APN SIM or M2M SIM navigate to Settings>>Network>>Cellular settings.

Choose actual APN for SIM1 and SIM 2 in “SIM 1 Access Point Name” from “airtelgprs.com to an actual “APN name”.


For JIO SIM in case if it is 5G SIM where IPv6 is only supported make below changes.

APN name of JIO.

PDP type should be changed from IPv4V6 to IPv6 only and enable “Enable CLAT support for SIM1” for the SIM card as shown.

Save and update the settings once done.

Chapter 2: Modbus RTU Master Configuration

1. Prepare Modbus slave.

Install any Modbus slave simulator, here ModSim32 is used.

Link to download: https://www.win-tech.com/html/demos.htm

Install the ModSIm32 application and connect USB to RS485 to PC/System.

Check the com port in the system in device manager.


Configure ModSim32 as shown and remember the serial configuration and Modbus configuration.

the serial and Modbus configuration is useful during Modbus RTU master configuration.

2. Configure Modbus RTU master as per the slave configuration

Navigate to Configuration>>Modbus configuration to configure Modbus RTU Master.

Click on Add Device as shown.



Follow the configuration in the new pop-up window as shown below image.

Note the Modbus and serial configuration is taken from our modSIM32 configuration.



Edit the configuration to do the register mapping. There are 2 different configuration options. Both options do allow giving a Tag name, but Default mapping is good for data sending in CSV or in fixed JSON string format. For editable JSON format Custom mapping can be used.

Default Mapping allows giving name to the segment and allow choosing a datatype for all the Registers.

Custom Mapping allows configurating Tag name and datatype for each register separately.


To update the configuration click on “Update Device”


Chapter 3: MQTT Broker configuration

Hosting hivemqtt broker.

Login to hivemq platform using below URL.

URL: https://www.hivemq.com/

Click on MQTT.

Select Public MQTT Broker

Click on MQTT browser client


Chapter 4: Modbus data Publisher Configuration


1. Cloud configuration.

2. Source configuration.

3. send configuration.


Cloud Configuration:

Login to router/gateway and navigate Configuration>>Cloud Configuration.

Configure the broker URL, Port, Topic etc as shown and save.

Source configuration

Source configuration allows configuring the polling frequency time.

How frequently the data should be collected by Router/gateway from Modbus slave devices.

Minimum polling freq. time is 60 seconds.

Note: this time remains same for both RTU and TCP slaves.

Send configuration:

Send configuration allows to choose type of string that should be sent to a cloud platform.

SILBO devices do offer 3 different options as shown below.

CSV

Fixed JSON

Editable JSON.


JSON option is the editable JSON option whereas CSV allows fixed CSV and JSON option.



Example of Fixed JSON. 


{"site_id":"Invendis","timestamp":"2024-05-16 15:55:51","rec_no":1,"request_id":1,"interface_id":1,"equiment_id":"1","equiment_model":"ABCD","slave_id":1,

"func_code":1,"commstatus":0,"startreg":1,"totalreg":10,"":"1-2-3-4-5-6-7-8-9-10"}


In this format we can change "site_id", "equipment_id", "equipment_model" information can be configured as per site requirement. Other parameter will remain same in the string values will keep on changing.

JSON option allows editable JSON in which we can change which parameters should be sent and also what name we should use to the tag.


What changes we can do in JSON edit to the above list. Lets change slave_id to some other name as “Slave number”



Even custom fields can be added, for example if location name should be sent by router/gateway in JSON packet then it can be configured as shown.

These all changes should be saved into backend and to do that navigate to Appmanager>> Application Start/Stop.

Click on update to save all the changes made in configuration section.

Once updated click on start.


Make sure application is started, once started it can be seen start option is replaced by Stop as below.



Now the data should come on the broker that we hosted on hivemqtt.

The JSON Custom parameter can be seen as “Location” with the fixed value “Pune-Plant1” is also present in above image.  

Also “Slave_id” became “Slave Number” as per the changes were made in configuration.


Note: “commstatus” is an important parameter that talks about the communication between router/gateway and Modbus slave device as connected is “commstatus” is “0” Modbus slave is not connected or not responding to the request & if value is “255” then the communication is healthy.


“Commstatus” parameter can be used to accept or reject the data from cloud side.


Note: Screenshot showing Modbus data on JSON showing 100 registers data, that is old data sent first by the router as it keeps old data was present in the router flash.


The router keeps all the data not published to cloud due to no internet or broker is not working etc and once the reachability is back device starts publishing the old data first and then latest as it works in FIFO (First in and first out). The total record a device can store is 2000 records and if more records need to be stored then the router/gateway with wMMC can be used.