Hi all,
I’m trying to achieve the following:
a. monitor my modbus TCP PLC attached sensors and status by reading coils and registers.
b. send all the data to an MQTT broker running in the cloud. onto a sitename/telemetry MQTT topic
c. send commands to the MQTT broker onto a sitename/rx topic to stop or start the system
I currently have the following successful setup
- water treatment system with a PLC. This exposes Modbus over TCP on port 502 on IP 192.168.1.250
- RUT956 with IP 192.168.1.201 with a LAN connection to the PLC
- Modbus TCP Client setup on RUT956 with RUT9M_R_00.07.17.5 software to quert the PLC registers. Manual testing in Modbus TCP Client works correctly and all values return results.
- Data to server connection to publish the Modbus TCP Client values to MQTT telemetry topic
I have also turned on the MODBUS MQTT gateway connecting to the same MQTT broker but listening to the /rx topic and responding on the /response topic.
I have tried sending ASCI message commands as well as JSON message commands based on this guide:
I tried ASCII: 0 1234 0 192.168.1.250 502 10 2 1 9193 1
to request a coil value to a status lamp. But this fails.
I also tried setting a start or stop switch: 0 1235 0 192.168.1.250 502 10 2 5 8204 1
But this also fails.
Fails sometimes means no response, and sometimes a connection reset by peer response.
I tried the same with JSON and tried variations as the document linked above is unclear on which functions to use
{“cookie”:1,“type”:0,“host”:“192.168.1.250”,“port”:502,“timeout”:5,“server_id”:2,“function”:6,“register_number”:8204,“value”:1}
{“cookie”:2,“type”:0,“host”:“192.168.1.250”,“port”:502,“timeout”:5,“server_id”:2,“function”:5,“rcoil_number”:8204,“value”:1}
Same issues as with ASCII.
I then tried testing by enabling the Telonika router as MODBUS TCP Server with ServerID 3.
When I now try to query the router I sometimes get a reponse, sometimes not? Can I find logs of why somewhere?:
I can now query router internals like uptime
If I register a readable coil value from my Modbus TCP Client I seem to be able to query that too
But it fails when I want to set a value:






