Directory structure

Please see default directory structure below for daemon installation.

  1. /etc/thingsboard-gateway/config - Configuration folder.
  2. tb_gateway.yaml - Main configuration file for Gateway.
  3. logs.conf - Configuration file for logging.
  4. modbus.json - Modbus connector configuration.
  5. mqtt.json - MQTT connector configuration.
  6. ble.json - BLE connector configuration.
  7. opcua.json - OPC-UA connector configuration.
  8. request.json - Request connector configuration.
  9. can.json - CAN connector configuration.
  10. ...
  11. /var/lib/thingsboard_gateway/extensions - Folder for custom connectors/converters.
  12. modbus - Folder for Modbus custom connectors/converters.
  13. mqtt - Folder for MQTT custom connectors/converters.
  14. __init__.py - Default python package file, needed for correct imports.
  15. custom_uplink_mqtt_converter.py - Custom Mqtt converter example.
  16. ...
  17. opcua - Folder for OPC-UA custom connectors/converters.
  18. ble - Folder for BLE custom connectors/converters.
  19. request - Folder for Request custom connectors/converters.
  20. can - Folder for CAN custom connectors/converters.
  21. /var/log/thingsboard-gateway - Logs folder
  22. connector.log - Connector logs.
  23. service.log - Main gateway service logs.
  24. storage.log - Storage logs.
  25. tb_connection.log - Logs for connection to the ThingsBoard instance.

General configuration file

The main configuration file that is used for connection to ThingsBoard platform instance and enable/disable connectors. This configuration points to ThingsBoard instance demo.thingsboard.io and uses memory file storage configured to store maximum of 100,000 records. There are 4 different connectors active. If you like to use only one of them - just remove all other connectors.

Example of main configuration file. Press to show.

Sections in config file

  • thingsboard– Configuration for connecting to ThingsBoard platform.
    • security – Configuration for type of encryption and authorization.
  • storage – Configuration for local storage of incoming data from devices.
  • connectors – Array of Connectors and their configuration to use.

    Connection to ThingsBoard

    | Parameter | Default value | Description | | :—- | :—- | :—- | | thingsboard | | Configuration for connection to server. | | host | 127.0.0.1 | Hostname or ip address of ThingsBoard server. | | port | 1883 | Port of mqtt service on ThingsBoard server. |

Subsection “security”

There are 3 variants of security subsection:


Access TokenBasic security

TLS + Access TokenAdvanced security

TLS + Private KeyAdvanced security

One type of security configuration is accessToken, to get it you should login into your ThingsBoard platform instance, go to DEVICE tab, press the plus icon, fill the values and check the “Is gateway” option, open this device and press the “COPY ACCESS TOKEN” button and replace default with your value

Parameter Default value Description
accessToken PUT_YOUR_GW_ACCESS_TOKEN_HERE Access token for the gateway from ThingsBoard server.

Security subsection in configuration file will look like this:

  1. ...
  2. security:
  3. accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
  4. ...

In table below described parameters to configure authorization of IoT gateway on ThingsBoard platform.

Parameter Default value Description
accessToken PUT_YOUR_GW_ACCESS_TOKEN_HERE Access token for the gateway from ThingsBoard server.
caCert /etc/thingsboard-gateway/mqttserver.pub.pem Path to CA certificate file.

Security subsection in configuration file will look like this:

  1. security:
  2. accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE
  3. caCert: /etc/thingsboard-gateway/mqttserver.pub.pem

In table below described parameters to configure authorization of IoT gateway on ThingsBoard platform.

Parameter Default value Description
caCert /etc/thingsboard-gateway/ca.pem Path to CA file.
privateKey /etc/thingsboard-gateway/privateKey.pem Path to private key file.
cert /etc/thingsboard-gateway/certificate.pem Path to certificate file.

Security subsection in configuration file will look like this:

  1. security:
  2. privateKey: /etc/thingsboard-gateway/privateKey.pem
  3. caCert: /etc/thingsboard-gateway/ca.pem
  4. cert: /etc/thingsboard-gateway/certificate.pem

Storage configuration

Configs in storage subsection provides configuration for saving incoming data before it will be send to ThingsBoard platform.
There are 2 variants for this section: memory or file.

  1. Memory storage - Received data saving to the RAM memory.
  2. File storage - Received data saving to the hard drive. |
    Memory storage
    (recommended if there is not enough disk space)
    |
    File storage
    (recommended for more persistent)
    | | —- | —- |
Parameter Default value Description
type memory Storage type (Saving data to RAM, no save to hard drive).
read_records_count 10 Count of messages to get from storage and send to ThingsBoard.
max_records_count * 100 Maximum count of data in storage before send to ThingsBoard.

| * – If receive data when storage has already counted, described in this parameter, new data will lose.
Storage section of configuration file will look like:``` storage: type: memory read_records_count: 10 max_records_count: 1000

  1. |
  2. | :--- |
  3. | | **Parameter** | **Default value** | **Description** |
  4. | :--- | :--- | :--- |
  5. | type | **file** | Storage type (Saving data to hard drive) |
  6. | data_folder_path | **./data/** | Path to folder, that will contains data (Relative or Absolute). |
  7. | max_file_count | **5** | Maximum count of file that will be saved. |
  8. | max_read_records_count * | **6** | Count of messages to get from storage and send to ThingsBoard. |
  9. | max_records_per_file | **14** | Maximum count of records that will be stored in one file. |
  10. * – If receive data when storage has already counted, described in this parameter, new data will lose.<br />Storage section of configuration file will look like:

storage type: file data_folder_path: ./data/ max_file_count: 5 max_read_records_count: 6 max_records_per_file: 14

  1. |
  2. | :--- |
  3. <a name="connectors-configuration"></a>
  4. #### Connectors configuration
  5. Configs in connectors section configuration for connecting to devices by implemented protocols. Config for every connector in this section must have parameters as in table below:
  6. | **Parameter** | **Default value** | **Description** |
  7. | :--- | :--- | :--- |
  8. | name | **MQTT Broker Connector** | Name of connector to broker. |
  9. | type | **mqtt** | Type of connector, must be like a name of folder, contained configuration file. |
  10. | configuration | **mqtt.json** | Name of the file with configuration in config folder.* |
  11. * Folder with this configuration file.<br />Section connectors in your configuration file may differ from shown below, but they should have structure like this:
  12. ```yaml
  13. connectors:
  14. -
  15. name: MQTT Broker Connector
  16. type: mqtt
  17. configuration: mqtt.json
  18. -
  19. name: Modbus Connector
  20. type: modbus
  21. configuration: modbus.json
  22. -
  23. name: Modbus Connector
  24. type: modbus
  25. configuration: modbus_serial.json
  26. -
  27. name: OPC-UA Connector
  28. type: opcua
  29. configuration: opcua.json
  30. -
  31. name: BLE Connector
  32. type: ble
  33. configuration: ble.json
  34. -
  35. name: CAN Connector
  36. type: can
  37. configuration: can.json
  38. -
  39. name: Custom Serial Connector
  40. type: serial
  41. configuration: custom_serial.json
  42. class: CustomSerialConnector

Note: You can use several similar connectors at same time, but you should provide different names and configuration files to them.
If you need different type of connector, you can implement it using customization guide or email us: info@thingsboard.io.