Help with JSON Format for MQTT Modbus Gateway on RUT956 (ThingsBoard Integration)

Hello,

Hardware: RUT956
Firmware version: RUT9M_R_00.07.14.3

I’m trying to integrate a Teltonika RUT956 with ThingsBoard using Modbus TCP and MQTT for bidirectional communication.

What I’ve tried:

I found the following JSON example in the community, now i’ m intended to switch a relay (integrated in router) ON/OFF via MQTT (tested with MQTT Explorer):

{
  "cookie": 65432,
  "type": 0,
  "host": "192.168.1.1",
  "port": 502,
  "timeout": 5,
  "server_id": 1,
  "function": 6,
  "register_number": 203,
  "value": 1
}

However, I get the following error response from the router:

{
  "cookie": 65432,
  "success": false,
  "error": "Missing field 'type'"
}

My scope:
Integration with Thingsboard:
The “Gateway” implementation in ThingsBoard doesn’t work, as Docker Compose is not supported on this device.
The “Integration” option is only available in the PE, which is not suitable in my case.
The only viable solution I found is to add the RUT956 as a “Device” in ThingsBoard and use Rule Chains to handle communication.

Problem:
Using internal MQTT on ThingsBoard, I can only send messages in JSON format, not ASCII. Unfortunately, I couldn’t find clear documentation or working examples on how to correctly structure the JSON payload to interact with the Modbus MQTT Gateway on the RUT956.

Could anyone help me with a working JSON example or suggest how to resolve this issue with MQTT and Modbus JSON formatting?

Any help or direction would be greatly appreciated.
Thanks in advance!

Hello,

Could you please confirm who is acting as the MQTT broker in your current configuration? I assume it’s the RUT956 itself, but it would be great to have that confirmed so we can be sure we’re aligned on the messaging flow.

If RUT acts as a broker, could you also double-check whether the MQTT broker service is enabled and properly configured on the RUT956 as outlined in a similar example on our wiki here:

Additionally, for reference, I’ve tested a similar setup for toggling a relay using MQTTX as the MQTT client, and it worked as expected. Below are the relevant configurations and JSON structure that worked on my end:

Configuration example






I hope this would help or bring any useful insights for your desired setup.

Best regards,

1 Like

The MQTT broker is in the cloud and works fine. It is properly configured. I tested it the same way using ASCII and it works. I will also test it the way you specified to see. Could it be an issue with MQTT Explorer?
192.168.1.1 is the ip of router or modbus tcp.
I’ve read the link you sent, and I don’t understand where the problem could be.

Thank you for help!

I restarted it and it started working. It also works from MQTT Explorer now. In the log, I noticed I was continuously receiving this message:

{
  "cookie": 65432,
  "success": false,
  "error": "Missing field 'type'"
}

Then I noticed in the screenshots you sent that the request and response topics were different, and that’s when I realized I had set them to be the same.
Basically, the message I sent on the request topic had its response on the same topic, and it treated it as a new request, causing a loop.
I think the interface should give an error if the topics are the same.

Thanks man,
Have a nice day

Thank you for the update. I’m really glad to hear it’s working now and that the issue was pinpointed. If you need any further assistance, feel free to reach out and open a new thread. We are all happy to help.

Best regards,

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.