Documentation

Integrations / Connection guides / Teltonika Gateways

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:

  1. Internet connection
  2. 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
  1. Open the Teltonika WebUI.
  2. Go to: Services -> Modbus -> Modbus TCP Server.
  3. Toggle the “Enable” button.
  4. Configure a Device ID.

More information about the Modbus TCP Server can be found here.

Steps to set up the Modbus TCP Client
  1. Open the Teltonika WebUI.
  2. Go to Services -> Modbus -> Modbus TCP Client in the Teltonika WebUI.
  3. Press the “Add” button.
  4. On the next page, toggle the “Enable” button.
  5. Set the Server ID. For this example, we set it to our previously set Device ID, which was 1.
  6. 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.
  7. 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
  1. Open the Teltonika WebUI.
  2. Go to Services -> Modbus -> Modbus Serial Client in the Teltonika WebUI.
  3. Under the Add new instance choose and configure RS232 or RS485 as the device name depending on your connection.
  4. In the Modbus client global setting that opens, toggle the “Enable” switch to “on”.
  5. 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.

  1. 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.
  2. Under “Requests Configuration,” a new instance will appear.
  3. 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
  4. Toggle the “Brackets” switch to “on”.
  5. Toggle the “Enable” switch to “on”.

After configuring the request, you can test it to ensure it works correctly:

  1. Go to the “Request Configuration Testing” section.
  2. In the “Requests” list, select the instance name you want to test.
  3. 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.

  1. Open the Teltonika WebUI.
  2. Go to Services -> Data To Server.
  3. Under “Add new instance”, type a collection name and click on “Add”.
  4. In the Data configuration tab, fill in a Name and select “Modbus” as the data type.
  5. 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.
  6. Change the data filtering, if you want to override the server IP address or Id or the request name.
  7. Set the Segment count to 1.
  8. Turn on “Send as object”.
  9. 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:
  1. Chose the Type as HTTP.

  2. In the Server address paste the HTTPS endpoint from inbound connectors: https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>

  3. Fill in the following URL: https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements.

  4. 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
    
  5. 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:
  1. Choose the Type as MQTT.
  2. Use mqtt.blockbax.com as the server address.
  3. Use port 8883
  4. In the topic section, paste the topic from inbound connectors: v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>/measurements
  5. In the Server address paste the HTTPS endpoint from inbound connectors: https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements?inboundConnectorId=<INBOUND_CONNECTOR_ID>
  6. For the Client ID use an arbitrary id that is prefixed with the public ID of your access key.
  7. Toggle on the Use credentials.
  8. For the Username, use the public ID of your access key.
  9. For the password, use the secret of your access key.
  10. For the QoS, use 1 (at least once) or 0 (at most once).
  11. 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.