Periodic MQTT message with I/O status

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?

Hello,

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.

Kind Regards,

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:

{
    "mqtt_test": {
        "time": 1700131712,
        "local_time": "2023-11-16 11:48:32",
        "fw": "RUT9M_R_00.07.05.4",
        "name": "monitoring",
        "id": "1"
    },
    "sim1_usage": {
        "tx": 5616536,
        "rx": 3719604
    }
}

So I’m not able to get the modbus data yet :frowning:

Hello,

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.

Kind Regards,

Ah, found it :slight_smile:

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 :partying_face:

Remarks
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…

1 Like

Hello,

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).
image

Kind Regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.