Modbus Comunication

Hello everybody.

I need some help with some questions that a client send me recently, here they go:

  1. We need to understand how the Modbus register query mechanism works, as we are currently experiencing many responses with time-outs.

  2. Are there recommended best practices for implementing Modbus on the TRB to optimize its performance?

  3. We have a critical issue: we send Modbus writes remotely through an MQTT Modbus Gateway, but the responses are inconsistent (sometimes they work, sometimes they don’t) and time-outs occur very frequently.

  4. Is there an optimal timeout or a recommended limit on the number of Modbus queries per second/minute to avoid overloading the device?

  5. Regarding the implementation of MQTT Modbus Gateway: o What format do you recommend using, JSON or ASCII?

  6. Finally, can you provide us with details on how Modbus queue management works on the TRB?

Super grateful that you can help me answer these queries since I can’t find this technical information on Teltonika’s wiki.

Best regards.

Hello,

Thank you for your questions. Here are the clarifications below:

  1. The Modbus client requests data from the Modbus server at the interval specified in the Period parameter and waits for a response within the Timeout value. If the request is successful, the parsed data is stored in the Modbus database and can then be transmitted to an HTTP(S) or MQTT server using the Data to Server service, or published to an MQTT broker where it can be parsed by an MQTT client (subscriber/publisher). More information and a detailed description of each Modbus device configuration parameter can be found on our Wiki page here.

  2. If Modbus data needs to be published to an MQTT broker instead of the MQTT gateway, the Data to Server service can be utilized for easier management and usage. Data to Server service documentation is available here:

  1. Could you please provide more details about your setup, specifically, how often the MQTT write requests are being sent, what data is being written, and to which Modbus registers?

  2. As a starting point, the default request period of 60 seconds and timeout of 5–10 seconds are generally sufficient in most applications. You can test and adjust these values depending on network latency and device response times.

  3. The choice between JSON and ASCII formats depends on your preference and integration environment. For simpler parsing and management, JSON is usually recommended. A detailed Modbus MQTT Gateway configuration example can be found on the wiki page here:

  1. The Modbus queue mechanism is as described in first question, each request is sent sequentially, and the next query is only initiated after the previous one has received a response or timed out.

Best regards,