Hi everyone, I’m new to the RUT956 router and I’m trying to set up a system to read MODBUS devices and communicate via MQTT. I’ve found the ‘Data to Server’ feature that reads MODBUS devices and sends data to an MQTT broker, but I can’t find an option to subscribe to an MQTT topic and trigger a MODBUS WRITE command (like a coil or holding register write) when a message arrives.
For example:
- The router subscribes to topic
X
- If someone publishes
"1"
to topic X
, the router writes to a MODBUS coil/register
Is there a built-in way to do this, or do I need to set up a custom script?
Hello @Miguel1,
Welcome to our community, and thank you for your inquiry.
Just to clarify your intended setup, I assume you are looking to use the Modbus RTU client to periodically read data from Modbus devices and send it to an MQTT broker using the Data to Server functionality, while simultaneously using the MQTT Gateway to subscribe to a topic and write to Modbus registers (e.g., coils or holding registers) when a message is received?
Looking forward to your clarification.
Best regards,
Exactly what you described @Martynas. Though it could also be an Modbus TCP client.
Best Regards,
Miguel Chagas
Hello,
Apologies for the delay.
Regarding your use case, reading values from MQTT and triggering a Modbus Write action, the most optimal approach would indeed be through a custom script.
While creating such a script is beyond my scope here, I can suggest checking similar forum discussions where MQTT subscription handling and Modbus control have been combined that should be helpful and bring you some insights:
Best regards,