- Step 1: Provision the gateway
- Step 2: Install the gateway
- Step 3: Gateway configuration
- Step 4: Restart gateway to accept new configuration
- Step 5: Review gateway statistics
- Step 6: Add connectors to the main configuration file
- Step 7: Configure connectors
This guide covers initial IoT Gateway installation and configuration. We will connect IoT Gateway to ThingsBoard server and visualize some basic gateway statistics: the amount of devices connected and messages processed. We will also configure MQTT and OPC-UA extension in order to subscribe to device data feed from external devices or applications.
Step 1: Provision the gateway
In order to connect your IoT gateway to ThingsBoard server, you need to provision gateway credentials first. We will use access token credentials as the most simple one. See device authentication options for more details.
Login as tenant administrator. Use default credentials in case of local ThingsBoard server. Open Devices and click on “+” button in the top right corner.
Populate your gateway name and select “Is gateway” checkbox. Click “Add”.
NOTE: Gateway and device names should be unique in the scope of a tenant.
Open your new device card and click on “Copy Access Token” button. Paste the token to a safe place. We will use it for ThingsBoard configuration in the next steps.
Step 2: Install the gateway
Browse available gateway installation options and choose the most suitable installation guide. Follow steps in chosen gateway installation guide. The Gateway configuration steps are covered below.
Step 3: Gateway configuration
Navigate to the gateway configuration folder and edit tb-gateway.yaml file.
Change host and port properties in the section “thingsboard” to your ThingsBoard host.
Change accessToken property in the section “security” to your access token that was copied during step 3.
Your gateway configuration should look similar to this file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 thingsboard: host: thingsboard.cloud port: 1883 remoteShell: false remoteConfiguration: false statistics: enable: true statsSendPeriodInSeconds: 3600 minPackSendDelayMS: 0 checkConnectorsConfigurationInSeconds: 60 handleDeviceRenaming: true checkingDeviceActivity: checkDeviceInactivity: false inactivityTimeoutSeconds: 120 inactivityCheckPeriodSeconds: 10 security: accessToken: PUT_YOUR_GW_ACCESS_TOKEN_HERE storage: type: memory read_records_count: 10 max_records_count: 1000 grpc: enabled: false serverPort: 9595 keepaliveTimeMs: 10000 keepaliveTimeoutMs: 5000 keepalivePermitWithoutCalls: true maxPingsWithoutData: 0 minTimeBetweenPingsMs: 10000 minPingIntervalWithoutDataMs: 5000 connectors: - name: MQTT Broker Connector type: mqtt configuration: mqtt.json
You can read more in this article about configuration files and their properties.
Step 4: Restart gateway to accept new configuration
This step depends on chosen type of installation. If you install thingsboard-gateway as daemon - you should use following command:
1 systemctl restart thingsboard-gateway.service
In other case, if you have installed the gateway as python module - you should just rerun gateway process.
Step 5: Review gateway statistics
Open the web UI of your ThingsBoard server and review statistics that is uploaded from your thingsboard gateway.
Login as Tenant Administrator and open Devices page. Click on the gateway device card.
Open “Latest Telemetry” tab and review following statistics: “eventsProduced”, “eventsSent” and parameters that provide information about every connector.
All values should be set to “0”.
Step 6: Add connectors to the main configuration file
For connection to some devices we use connectors, they are connect to different devices and servers to collect data.
To provide for gateway information about connectors that you need - you should write a configuration to section “connectors” in tb_gateway.yaml (At least one connector needed for correct work).
For correct configuration please use this article.
Step 7: Configure connectors
After successful installation you should configure the connectors to connect to different devices, please use one (or more) following articles to configure connector files: