Docs
Teltonika Gateways
Teltonika Networks gateways can be connected over Ethernet, 4G, LTE-M, or NB-IoT. They can directly connect Modbus devices to the Blockbax Platform (via Ethernet, RS232, RS485, or I/O interfaces). Blockbax can natively integrate with the Teltonika firmware to easily unlock the data and unleash its full potential.
Goal
The goal is to configure a Teltonika device to send data with Modbus or Bluetooth over the internet to Blockbax.
Prerequisites
Make sure you have the following configured on your router:
- Internet connection
- Access to the Teltonika WebUI
This tutorial is tested on the RUTX11, TRB140, and TRB255 (firmware version 00.07.07.1). However, the instructions on this page should work for other Teltonika devices and firmware as well.
Steps to setup the Modbus TCP Server
- Open the Teltonika WebUI.
- Go to: Services -> Modbus -> Modbus TCP Server.
- Toggle the “Enable” button.
- Configure a
Device ID
.
More information about the Modbus TCP Server can be found here.
Steps to set up the Modbus TCP Client
- Open the Teltonika WebUI.
- Go to Services -> Modbus -> Modbus TCP Client in the Teltonika WebUI.
- Press the “Add” button.
- On the next page, toggle the “Enable” button.
- Set the
Server ID
. For this example, we set it to our previously set Device ID, which was1
. - Set the “IP address” and the “Port” to the endpoint of your Modbus TCP/IP server. For this example, we use the “IP address”
127.0.0.1
and the “Port”502
, which is the default port to access the internal Modbus TCP server. - You can configure any “Period” you want in seconds and leave the “Timeout” for now.
More information about the Modbus TCP Client can be found here.
Steps to set up the Modbus Serial Client
- Open the Teltonika WebUI.
- Go to Services -> Modbus -> Modbus Serial Client in the Teltonika WebUI.
- Under the
Add new instance
choose and configure RS232 or RS485 as the device name depending on your connection. - In the Modbus client global setting that opens, toggle the “Enable” switch to “on”.
- Configure the Modbus Serial Client’s server device interface settings.
More information about the Modbus Serial Client can be found here.
Steps to read out registers
Reading out registers is the same for both TCP and Serial. As an example, we read out the RUTX11 internal temperature from the Modbus TCP server, which has register number 6
.
- On the same page where you just configured the Modbus Client, for example
Modebus TCP Client
, clik on the existing devices or add a new device. - Under “Requests Configuration,” a new instance will appear.
- Configure the following fields:
- Data Type: 32 bit integer, Byte order 1,2,3,4 (see Get Parameters)
- Function: Read holding registers (3)
- First Register: 6
- Register Count: 2
- Toggle the “Brackets” switch to “on”.
- Toggle the “Enable” switch to “on”.
After configuring the request, you can test it to ensure it works correctly:
- Go to the “Request Configuration Testing” section.
- In the “Requests” list, select the instance name you want to test.
- Press the “Test” button.
If all is set up correctly, a value should appear. Make sure this value is a valid number without brackets. Additional information to configure a request can be found here.
Setting up the Data to Server Service
Now that you have access to Modbus data, the Teltonika device can be configured to send data to Blockbax. For this, we are using the Data to Server service within the device. Before you create a “Data Sender,” make sure you have set up an MQTT or HTTPS inbound connector to push data to.
- Open the Teltonika WebUI.
- Go to Services -> Data To Server.
- Under “Add new instance”, type a collection name and click on “Add”.
- In the Data configuration tab, fill in a Name and select “Modbus” as the data type.
- For the format type, select JSON. You can choose a custom formatting as well, but use the default format if you want to use the inbound connector templates.
- Change the data filtering, if you want to override the server IP address or Id or the request name.
- Set the Segment count to
1
. - Turn on “Send as object”.
- In the collection configuration tab, choose the Period to send data to inbound connector (default 60)
Now you are redirected to the Server configuration
.
Here you can chose between the HTTP or MQTT communication type.
For HTTP integration:
Chose the Type as HTTP.
In the
Server address
paste the HTTPS endpoint from inbound connectors:https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>
Fill in the following URL:
https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements
.Add the following headers inside the “HTTP headers” section. Make sure you press the + icon after adding each individual header:
Authorization: ApiKey <API_key>
Content-Type: application/json
This will bring you back to the “Data Senders”; press “Save & Apply” when you are done.
Alternatively, you can chose an MQTT connection type in the server configuration.
For the MQTT integration:
- Choose the Type as MQTT.
- Use
mqtt.blockbax.com
as the server address. - Use port
8883
- In the topic section, paste the topic from inbound connectors:
v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>/measurements
- In the
Server address
paste the HTTPS endpoint from inbound connectors:https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>
- For the
Client ID
use an arbitrary id that is prefixed with the public ID of your access key. - Toggle on the
Use credentials
. - For the
Username
, use the public ID of your access key. - For the password, use the secret of your access key.
- For the
QoS
, use 1 (at least once) or 0 (at most once). - This will bring you back to the “Data Senders”. Press “Save & Apply” when you are done.
Great job! You can now go back to the inbound connectors overview and confirm the data is coming in. You can also write your custom parser to load your data in to the subjects composition in the Blockbax. A template for the Teltonika integration is on the road map and coming soon. Then you can use that without the need to write your own custom code. Stay tuned for that.