I’m working on a setup where I need to continuously collect data from Modbus slave devices and, approximately once per hour, send control commands to them.
I have configured the Modbus Serial Client along with the “Data to Server” function, using a cache on the microSD card to ensure data collection continues even when the network connection is unavailable. This configuration works correctly for data acquisition.
However, to send commands to the slave devices, it seems I need to use either the “Modbus TCP over Serial Gateway” or the “MQTT Modbus Gateway.” The issue is that neither gateway can operate while the Modbus Serial Client is active.
Currently, the only workaround I’ve found is to stop the Serial Client, start the Gateway, send the command, stop the Gateway, and then restart the Serial Client. This process is cumbersome and not ideal for automated operation.
Is there an alternative method or recommended approach to perform both data collection and control functions simultaneously?
If I understood your setup correctly, your goal is to have the Modbus Serial Client continuously running for Data to Server publishing, while also being able to write control commands to the same Modbus slave devices through the MQTT Modbus Gateway. Is that correct?
Could you please confirm whether you are using the same MQTT topics for both the Data to Server function and the MQTT Gateway?
This specific configuration, to both publish Modbus data and send write commands to Modbus serial servers, should be achievable by using only the Modbus RTU Client together with the MQTT Serial Gateway. You can find detailed instructions for setting up this type of communication in the relevant wiki configuration guide here:
If the setup described in the guide doesn’t fully match your intended workflow, please share a bit more detail about how your communication flow should work (e.g., which device initiates control commands, what kind of Modbus function codes are used, etc.).
Thank you for your response. You are correct in your assumption. I have read (mostly) the entire wiki about MQTT and Modbus, but I’m stuck at the step “Configuring the Serial Gateway.” I can configure it, but I can’t enable it — the error message says: “Device is already enabled in Modbus Serial Client service. Disable it there first.”
This is my first project with the Teltonika RUT956, so it’s possible that I’m missing some fundamental principle that everyone else already knows.
My setup is as follows: there is a PVE inverter connected via Modbus/RS485, and I collect data about current energy production, temperatures, and the overall health of the system. However, sometimes I need to switch the inverter off or limit its power output — this is done using the same RS485 connection. I already have a working prototype using ESPHome, but I need something more robust for real-world use.
On the RUT956 side, I have configured the following: Services → Modbus → Modbus Serial Client → Serial Device RS485
Then: Services → Modbus → Modbus Serial Client → Modbus Devices → all the required Modbus registers connected to the Serial Device from the previous step.
Under “Data to Server” → Connection, I set MQTT, Period: 30s, and under Data Input → Type, I selected Modbus.
With this setup, I’m successfully receiving Modbus registers values every 30 seconds — that part works fine.
However, I’m not able to send commands in the other direction.
Or maybe I just don’t know how to do it? When I look at Services → MQTT Gateway, it seems like it could work both ways, but that would require sending a request every 30 seconds to query the data, and it wouldn’t function if the network connection goes down. Meanwhile, the “Data to Server” feature seems to be more tolerant of network interruptions.
I’ve clarified the error message you’re encountering with our engineers, and unfortunately, only one serial device application, either Modbus Serial Client or Modbus MQTT Gateway, can be used at a time. This limitation exists because both services would otherwise attempt to access the same serial port simultaneously.
In short, these two services cannot operate at the same time, because if Modbus requests were sent through both at once, the router would not be able to determine which service the response belongs to. Therefore, you’ll need to choose which of the two services best fits your application.