I’m using a RUT956 and I have configured the I/O Juggler to send a MQTT message to our MQTT Broker when the digital input pin changes.
Is it possible to send the message periodically (e.g. every 5 minutes) or should I use the QoS level > 0 for this?
If you want to send the I/O status to your MQTT broker periodically, you can configure Modbus TCP Server and Modbus TCP Client on RUT956 to get I/O information from itself periodically. Then, configure Data To Server to send this Modbus data to your MQTT broker.
You can find information about Modbus registers on RUT956 here.
I’ve enabled the Modbus TCP Server on my RUT956 and I’m able to read out modbus registers with my laptop using modbus-cli as described here.
I have configured Data to Server to send a MQTT package to our MQTT Broker. I have added 3 sections:
When I look at the MQTT Broker with MQTT Explorer I only see section 1 and 2:
"local_time": "2023-11-16 11:48:32",
So I’m not able to get the modbus data yet
You are almost there. You should also configure Modbus TCP Client on RUT that will request information from itself. In the Modbus TCP client configuration, put the LAN IP address of RUT (or 127.0.0.1 loopback) and configure the Modbus requests that you need. For example:
For the requests, make sure that you select the correct Data Type and function code (Read Holding Registers (3)). You can refer to the Modbus Monitoring wiki page that I have linked previously.
Ah, found it
Read Holding Registers (3) was the reason why it wasn’t working before.
Now I’m able to transmit the status of the digital input to our MQTT Broker
I have configured the Data to Server to have 3 sections in the MQTT topic (see screenshot above). I noticed that the MQTT message with the 3 sections is immediatly followed by another message with only 2 sections. The Modbus section is gone. Do you have an idea why?
I also noticed that I can specify multiple request configurations in the Modbus TCP Client configuration but only the last one is transmitted over MQTT. I’m using the JSON format type.
And what I receive on the MQTT Broker…
Apologies for a late reply.
Edit the configurations of your Modbus Data input in Data to Server and set the segment count to 4 (the number of Modbus Requests you have configured in Modbus client configurations).
This topic was automatically closed after 15 days. New replies are no longer allowed.