An introduction to how Modbus can be used with the Teltonika routers in many ways and why it can be useful for some applications
Modbus TCP and RS485 (RUT955 only) direct connection
All our Teltonika routers (RUT240, RUT950 and RUT955) include a Modbus TCP Master driver. This means that any Modbus TCP Slave connected within the same IP network can communicate with Teltonika over Modbus TCP.
If you are using a RUT955, a RS485 and a separate RS232 port are also available to be used independently as Modbus RTU Master ports. In our examples we are going to use the RS485 serial port, as it is more commonly used in BMS.
At Innon we have identified 4 main use cases where you could benefit from a Modbus direct connection
See the full article on how to configure slave devices and data over Modbus TCP and RS485 direct HERE
Read data from a Modbus Slave device to trigger a write command to another Modbus Slave device based on specific conditions
In this scenario, a Modbus Slave device can be used to trigger an action on itself or another Slave device within the same network.
For example, you could read a temperature from a Slave device, and decide to send a command to drive an output or raise an alarm to another Slave device.
Note that when using the RUT955, commands are available only within the same Modbus network (TCP to TCP, RS485 to RS485). It is not possible to get a TCP Slave to trigger a command sent to a RS485 Slave, for example
Read data from a Modbus Slave device to trigger a Teltonika output ON/OFF based on specific conditions
In this scenario the physical outputs of the Teltonika are connected to a device and you are effectively setting a rule to control one of these outputs based on the value of a data point read from a Modbus Slave device
Read data from a Modbus Slave device to trigger an SMS send command based on specific conditions
In this scenario you are triggering an SMS send command within the router based on the value of a data point read from a Modbus Slave device
Read data from Modbus Slave devices and push it over MQTT (or HTTP)
In this scenario, Modbus Slave devices data is read by Teltonika and is pushed to an MQTT Broker.
An MQTT broker can be configured locally on the Teltonika, and the "MQTT client" function can relay information locally, in case the broker data needs to be accessible by other local MQTT clients for example, or to bridge all the local broker data to/from a remote broker
Alternatively, you can configure a remote MQTT broker on the "MQTT client" function, so the local broker is not required
Check out how you can push all your data over MQTT on the first part of the Modbus and MQTT article HERE
Within the same article you will be also directed back to setting up the local direct driver to get your data.
Note that to get RS485 slave devices working in this mode, the Gateway function (see chapter below) is essential and all data needs to go through the Modbus TCP driver (the Modbus RS485 driver needs to be disabled). The "MQTT client" will in fact allow the use only of data coming from the Modbus TCP Master driver.
RS485 gateway to TCP (RUT955 only)
You might not want to use the Teltonika direct Modbus, you might have a Modbus TCP Master device working already in your network.
The Teltonika offers a great feature: you can use it as a gateway to get access to Modbus RS485 Slave devices from your Modbus TCP Master
It is very important to DISABLE the Modbus RS485 Direct internal driver within the Teltonika when the gateway function is enabled, as it would interfere with the correct operation of the gateway function.
This RS485 to TCP gateway function can also be used to enable the push of RS485 slave devices data to MQTT (see chapter above) and for the Control over MQTT function (see chapter below), which are only working with IP enabled devices, but can make use of the Gateway internally.
See the full article about the Modbus RS485 to TCP gateway HERE
Modbus TCP control over MQTT
This is a particular scenario that might be useful when you want to have "direct access" to the Modbus Slave devices connected to the Teltonika router from a remote server that runs an MQTT client. The MQTT client can be configured to send specifically designed JSON payloads that are translated by the Teltonika into Modbus commands to run locally. Teltonika will then package the Modbus slave response into a JSON payload that will be published on the MQTT broker. You can use the local Teltonika broker or an external broker, depending on your preferred configuration.
Note that Modbus RS485 devices have been left on the schematic on purpose: they would be in fact accessible using the Gateway function within the Teltonika router (section above).
Note also that only some Modbus commands have been implemented at the time of writing this article, in specific:
- 3 - read holding registers
- 6 - write to a single holding register
- 16 - write to multiple holding registers
See the full article about exchanging data between Modbus and MQTT HERE