Documentation

Integrations / Connection guides / Teltonika Gateways

Teltonika Gateways

Teltonika Networks gateways can be connected over Ethernet, 4G, LTE-M or NB-IoT. It 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 the full potential with Blockbax.

Goal

The goal is to configure a Teltonika device to send data with Modbus or Bluethooth 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.00). However, the instruction of this page should work for other Teltonika devices and firmware as well.

Steps to setup the Modbus TCP Slave.
  1. Open the Teltonika WebUI
  2. Go to: Serivces -> Modbus -> Modbus TCP Slave
  3. Toggle the “Enable” button
  4. Configure a Device ID

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

Steps to set up the Modbus TCP Master.
  1. Open the Teltonika WebUI
  2. Go to Serivces -> Modbus -> Modbus TCP Master in the Teltoniks WebUI
  3. Press on the “ADD” button
  4. On the next page toggle the “Enable” button
  5. Set the Slave 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 slave.
  7. You can configure any “Period” you want in seconds and leave the “Timeout” for now

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

Steps to set up the Modbus Serial master
  1. Open the Teltonika WebUI
  2. Go to Services -> Modbus -> Modbus Serial Master in the Teltoniks WebUI
  3. Choose and Configure RS232 or RS485 depending on your connection
  4. Under “RS323/RS485 Slave Device List” click on “ADD”
  5. A new device will show in the list, click on the Edit button.
  6. Inside the Slave device configuration toggle the “Enable” switch to “on”
  7. Configure the Slave ID and “Period”

More information about the Modbus Serial Master can be found here.

Steps to read out registers

Reading out registers is for TCP and Serial the same. As an example we read out the RUTX11 internal temperature from the Modbus TCP slave which has register number 6.

  1. On the same page where you just configured the Modbus Master goto “Add New Instance” and under “Name” configure what you want your instance to be called
  2. Click on “ADD”
  3. Under “REQUESTS CONFIGURATION” a new instance will appear
  4. Configure the Data Type, Function, First Register and Register Count, for our exmaple we use a 32 bit integer data type and 2 register counts and set the Function to “Read holding register (3)”
  5. Toggle the “NO BRACKETS” switch to “on”
  6. Toggle the “ENABLED” switch to “on”

When done correctly we can test our configuration

  1. Go to “REQUEST CONFIGURATION TESTING”
  2. In the “Requests” list select the instance name you want to test
  3. Press the “TEST” button

If all is setup 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 setup a Subject and know its SUBJECT_EXTERNAL_ID and have created an access key.

  1. Open the Teltonika WebUI

  2. Go to Services -> Data To Server

  3. Under “Data Senders” click on “ADD”

  4. On the next page called “Advanced Sender Settings” fill in a Name and select “Modbus Data” as our Data source.

  5. Select the HTTP(S) protocol and fill in the following JSON format:

    {
      "series": [
        {
          "ingestionId": "<SUBJECT_EXTERNAL_ID>$%i.%s",
          "measurements": [{ "date": %t000, "number": %a }]
        }
      ]
    }
    

    The %i,%s,%t and %a are special characters which get replaced by Teltonika based on the read out data. In this case we use %i.%s as external metric ID suffix of the ingestion ID which translates to <Modbus slave ID>.<Start register>. It is important you also configure your external metric IDs as such in the Blockbax Platform.

    The Data to Server service can only be configured with HTTP(s). There is a possibility to configure it with MQTT, this is not possible as long as an MQTT client ID can not be configured in Teltonika.

  6. Set the Segment count to 1.

  7. Turn on “Send as object”.

  8. For “URL / Host / Connection string” fill in the following url: https://api.blockbax.com/v1/projects/<PROJECT_ID>/measurements.

  9. Choose a period for how frequent data has to be send.

  10. Add the following headers inside the “Custom Header” section. Make sure you press the + icon after adding each individual header:

    Authorization: <ACCESS_TOKEN>
    
    Content-Type: application/json
    
  11. Toggle the “Enable” button and press “Save & Apply”.

  12. This will bring you back to the “Data Senders”, press “Save & Apply” when you are done.

Great job! You can test the built-in integration by opening Blockbax and see if the data is coming in.