4553 questions

5591 answers

8821 comments

5474 members

0 votes
73 views 2 comments
by

Dear All,

I have a TRB145. I wish to send modbus write register commands to the device through MQTT to the device's Modbus Serial Master and Not Modbus TCP Master.
From local support I was told that in newer versions of firmware that should be possible, but I couldn't find specific guide.

I am currently on TRB1_R_00.02.05.1 Firmware.

Could anyone guide me further on this?


Thanks

1 Answer

0 votes
by

Hello,

The Modbus gateway Serial type allows redirecting TCP data coming to a specified port to RTU specified by the Slave ID. The Slave ID can be specified by the user or be obtained directly from the Modbus header In short them we provide internet access to the Modbus device for end client so he could get the data from the Modbus device.

I'd like to share configuration example:

Step1: Enable RS interface and set Modbus gateway type (Services > RS232/RS485). Listening IP - router's LAN IP address.

Step 2:  Enable Modbus TCP Master (Services > Modbus). IP address - router's LAN IP address.

Step 3: Enable MQTT gateway (Services > MQTT gateway). For example, we used flespi.io MQTT broker:

Step 4: Use flespi.io to send requests and get responses. Function format is:

• Cookie (number from 0 to 2^64-1

• IP type

o 0 means IPv4

o 1 means IPv6

o 2 means hostname

• Port

• Timeout (how long will be waiting for response). In seconds. from 1 to 999.

• Slave ID – indicates to which slave request is sent. From 1 to 255.

• Function.

o 3 means read registers

o 6 means write single register

o 16 means write multiple registers 6

• Number of first register - from 1 to 65536, from which will information will be read or written

• If function is 3

o Registry number (from 1 to 123, but number of first register. + number can’t go out of range)

• If function is 6

o Registry value (from 0 to 65535)

• If function is 16

o Registry number (from 0 to 123, but number of first register. + number can’t go out of range)

o Registry values separated by commas without spaces. Example.: 1,2,3,654,21,789. There has to be as many values, as specified number of registers, and each value must be between 0 and 65535.

▪ If number of registries is 0, there should be no registry values

For example, to read register 1 to 5 use this command:

0 65432 0 192.168.2.1 502 5 1 3 1 5

To set register 4 to value 1010 use this command format:

0 65432 0 192.168.2.1 502 5 1 6 4 1010

Kind regards.

by
Does the Modbus TCP Master exist on the TRB145 even though it has no LAN connection? Here, in the example, you use the IP 192.168.2.1: Port 502 to reach Slave ID 1 in the MQTT request.

Is it necessary to consider that the IP Gateway is 127.0.0.1 in a TRB145 ?
by

All TRB14X by default has a LAN IP address - 192.168.2.1. You can check it on the Web UI page Network > Interfaces:


But of course you can use local host IP address 127.0.0.1 instead of 192.168.2.1. Then, when configuring according to my example, you need to change the ubiquitous 192.168.2.1 to 127.0.0.1