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.