Mqtt modbus gateway

Hello
I Can read status from modbus TCP device but when i send request

  • 0 65432 0 192.168.1.163 502 5 2 5 302 1
    it cannot on DO On modbus TCP device. it show
  • 65432 ERROR: First register + register count go out of bounds

and mqtt modbus gateway can use only TCP not Serial 485/232 ?

Thank you

Hello,

The Modbus Master with MQTT gateway can be utilized with both Modbus TCP and Modbus RTU. The syntax and other information is available on our wiki page here. However, it’s important to note that the format for Modbus RTU, which can be used with serial, differs slightly. Here’s an example of a Modbus RTU request:

Modbus RTU read request:

1 65432 1 5 1 3 1 1 , where:

  • 1 - Message for Modbus RTU device (1 - RTU; 0 - TCP);
  • 65432 - Cookie for device separation (64-bit unsigned integer);
  • 1 - RS device ID, specified in the Serial Gateway Configuration;
  • 5 - timeout in seconds;
  • 1 - Modbus Slave ID;
  • 3 - Function (Read Holding Registers);
  • 2 - Register number (not register address );
  • 2 - Number of registers to read.

Modbus RTU write request:

1 65432 1 5 1 6 203 1 , where:

  • 1 - Message for Modbus RTU device (1 - RTU; 0 - TCP);
  • 65432 - Cookie for device separation (64-bit unsigned integer);
  • 1 - Serial device ID, specified in the Serial Gateway Configuration;
  • 5 - timeout in seconds;
  • 1 - Modbus Slave ID;
  • 6 - Function (write to a single holding register;);
  • 203 - Register number (not register address );
  • 2 - Data to write.

When it comes to function codes, the supported functions are:

  • 3 - Read holding registers;
  • 6 - Write to a single holding register;
  • 16 - Write to multiple holding registers.

Based on the error you are encountering, which states that the register count is out of bounds, it is likely that the Modbus slave does not support this particular address. If you are using a Teltonika device as a Modbus slave, you can find available register numbers on our wiki page here. Keep in mind that you need to use Modbus Register Numbers, and not addresses.

It’s worth noting the distinction between a Modbus Register Address and a Modbus Register Number. Register addresses start from 0, while register numbers start at 1. Therefore, if you need to read register address 200, you should specify register number 201.

If the Slave Device is not a Teltonika Networks device, you will need to check the available Modbus addresses specific to that particular device.

Kind Regards,