Help with Sending Modbus Alarms to MQTT Broker Using RUT140

Hello Teltonika Community,

I’ve been using the RUT140 router to read data from the Modbus TCP Client and send it to my MQTT broker via the Data to Server feature, and it has been working well so far.

However, I now have a new requirement: I need to send numerous alarms to the MQTT broker, but only when their state changes (e.g., from inactive to active or vice versa).
I would also be really helpful if I could send many holding registers to MQTT when the state of 1 modbus device changes.

I tried configuring the Modbus Alarms feature, but I haven’t been able to make it work, it seems that it cannot send data at all.

Has anyone successfully set up something similar or can offer advice on the proper configuration to achieve this? Any help or suggestions would be greatly appreciated!

Thank you in advance.

Best regards,

Hello,

If you’re using the same broker address in both the Data to Server configuration and the Modbus Alarms settings, this could be why the alarm data isn’t reaching your MQTT broker. Setting both configurations to the same broker can sometimes cause conflicts that prevent data from being sent.

To test and troubleshoot this setup locally, I suggest the following:

  1. Enable MQTT Broker on the RUT140:
  • Go to ServicesMQTT (you’ll need to install MQTT package from System → Packages if it’s not installed yet) on your router, set up the broker on port 1883, and in Miscellaneous, set Allow anonymous to On for testing.
  1. Configure Modbus Alarms to Use Local Broker:
  • In the Modbus Alarms configuration, enter these settings:
    • Hostname: Your RUT140’s LAN IP address
    • Port: 1883
    • Keepalive: 60 seconds
    • Topic: The topic you want your subscriber to receive data from.
  1. Test with an MQTT Client:
  • Use an MQTT broker application, like MQTT.fx, to subscribe to your chosen topic and verify if the alarm data is now being sent correctly.

Best regards,

1 Like

Hello Martynas,

Thank you for your fast response and detailed guidance.

I tested your suggestion, and the Modbus Alarms work correctly when using a local broker via the router’s MQTT function. However, this isn’t a viable long-term solution for me, as I need to use the same MQTT broker for all functionalities, including the Modbus Alarm feature.

The conflict doesn’t seem logical to me, as I am already using different topics in the Data to Server and Modbus Alarms functions. Is there a workaround to resolve this conflict so that I can publish alarm data to the same broker whenever device states change?

Your further assistance would be greatly appreciated.

Best regards,

Thank you for testing the setup. I’ve replicated your configuration and can confirm that the Modbus Alarm messages work correctly with the same broker only if there are two separate topics (one for the Modbus Alarms and another for Data to Server).

However, a limitation exists: if only one Modbus Alarm is configured with the MQTT message action, it will not function as expected if the Data to Server collection includes any Modbus alarms data type.

To assist you further, I’ve included screenshots of my own working setup, where I’m using:

Data to Server configuration:


Modbus Alarms:

Brokers output:
When triggered, MQTT message alarm:

When triggered second alarm:

Let me know if you need further assistance or have additional questions.

Best regards,

Hello Martynas,

Thank you for your detailed response and for replicating the configuration. I’d like to share my current setup and the issue I’m encountering:

My Configuration:

  1. Modbus TCP Client:
  • I’ve added a Modbus alarm that sends data to my local MQTT broker (Router).
  1. Data to Server:
  • Configured to collect data from the local MQTT broker and forward it to the external MQTT broker.

Adding a second Modbus alarm, as you suggested, allowed the setup to work with the same MQTT broker. However, I’m encountering the following issue:

The Problem with Action Frequency Settings:

  • When I configure Action Frequency to Every Trigger, it publishes to my MQTT broker not by a change of state, but based on the publish time interval (period) configured in the Data to Server instance.
  • Since this behavior isn’t suitable for my use case, I tried setting Action Frequency to First Trigger with the condition Not Equal to 0.

Alarm Details:

  • My alarms are represented as bits within a Word, as shown in the example below:
    • Alarm 1 = ON → Word = 1
    • Alarm 1 + Alarm 2 = ON → Word = 3, and so on.
  • Each bit represents an individual alarm (16 alarms in total).

The Issue:

  • The first time an alarm triggers (Word ≠ 0), an MQTT message is sent as expected.
  • However, if the alarm state changes without resetting to 0 (e.g., from 1 to 3), no MQTT message is sent.
  • To get another MQTT message, the Word must first reset to 0 and then change to a new value (e.g., 3).

My Question:

Is there a way to configure the Modbus alarm to trigger an MQTT message every time its condition changes, regardless of whether it first resets to 0?

This functionality is critical for monitoring dynamic alarm states, especially since multiple alarms can be active simultaneously within the same Word.

I appreciate your insights and any further recommendations you can provide!

Best regards,

I just asked the same question in another post, and I think the answer is no. As you’ve found out, the “first trigger” sends the message when the condition is true, and the condition has to go false again, then true again to get another trigger.
If you find another solution, do tell, but the only ways around this I could find would be putting an “equal to” alarm for every single possible value, or using an external device to publish to your RUT, which would just be the broker.