Stop the war

Stand with Ukraine flag

Support Ukraine

Try it now Pricing
Professional Edition
Community Edition Professional Edition Cloud Edge PE Edge IoT Gateway License Server Trendz Analytics Mobile Application PE Mobile Application MQTT Broker
How to connect UG67 LoRaWAN® Gateway to ThingsBoard?
Getting Started Documentation Devices Library Guides Installation Architecture API FAQ
On this page

How to connect UG67 LoRaWAN® Gateway to ThingsBoard?

Introduction

UG67 LoRaWAN® Gateway UG67 LoRaWAN® Gateway UG67 is a robust 8-channel outdoor LoRaWAN® gateway.
Adopting SX1302 LoRa chip and high-performance quad-core CPU, UG67 supports connection with more than 2000 nodes.
UG67 has line of sight up to 15 km and IP67 waterproof case, which is ideally suited to smart agriculture, smart metering and many other outdoor applications.
UG67 supports not only multiple back-haul backups with Ethernet, Wi-Fi and cellular.

IP67 Rating
64-bit Quad-Core Processor
New SX1302 LoRa Chip
Built-in Supercapacitor
Multiple Backhaul Connectivities
Internal Antenna Design
Embedded Network Server
Compatible with Multiple Network Servers
Global LoRaWAN® Frequency Plans (CN470/RU864/IN865/EU868/AU915/US915/KR920/AS923)

Doc info icon
ThingsBoard PE Feature

Only Professional Edition supports Platform Integrations feature.
Use ThingsBoard Cloud or install your own platform instance.

After doing steps described in this guide you will have a connected and configured gateway on a network server and integration on ThingsBoard, it will allow you to add devices, receive data from them and process a data.

Prerequisites

To continue with this guide we will need the following:

Gateway connection

According to the official user manual and this guide you can connect the gateway to the network and get access to the WebUI in two ways:

  • Wireless connection:
    1. Enable Wireless Network Connection on your computer and search for access point “Gateway_**” to connect it.
    2. Open a Web browser on your PC and type in the IP address 192.168.1.1 to access the web GUI.
    3. Enter the username(Default: admin) and password(Default: password), click Login.
  • Wired connection: Connect PC to UG67 Ethernet port directly or through PoE injector to access the web GUI of gateway. The following steps are based on Windows 10 system for your reference.

    1. Go to “Control Panel” → “Network and Internet” → “Network and Sharing Center”, then click “Ethernet” (May have different names).
    2. Go to “Properties” → “Internet Protocol Version 4(TCP/IPv4)” and select “Use the following IP address”, then assign a static IP manually within the same subnet of the gateway.
    3. Open a Web browser on your PC and type in the IP address 192.168.23.150 to access the web GUI.
    4. Enter the username and password, click “Login”.
  • Now you have ability to configure the gateway.

  • Open Packet Forwarder in the left menu and save Gateway EUI and Gateway ID, we will need them to create a gateway on network server.

By default, Gateway EUI and Gateway ID are the same.

Next steps will describe how to connect the gateway to network server.

Configuration

To create an integration with a network server please choose first one of the supported network servers:

Add a gateway on the Chirpstack

We need to add a gateway on the Chirpstack.
To add a gateway, you can follow next steps:

  • Login to Chirpstack server.

  • Go to Gateways and click on Add gateway.

  • Fill name, gateway EUI (It will be different, you can find it on the gateway control panel) with your data, scroll down and click on Submit button.

  • Scroll up and put information about the gateway MAC Address (Just remove FFFF or FFFE in the middle of gateway EUI) into eth0 MAC address and gateway EUI to Custom EUI field.

  • The gateway is added. In gateways tab you can see its status.

Configure the gateway to send data

To connect and send data to the Chirpstack we should configure the gateway.
To do this please follow next steps:

  • Open gateway control panel.

  • Click on plus button, to add a new forwarder.

  • Put into Server address your server address, in our case it is sample.network.server.com.

  • Press Save button.

  • Now you can check the status of the gateway on Chirpstack, it should be online.

Now, the gateway is able to send a data to the network server.

Configure application on the Chirpstack

Now we need to configure application on the Chirpstack. To do this please follow next steps:

  • Go to Applications in the left menu and click Add application.

  • Fill application name and click on Submit button.

  • Go to API keys in the left menu and click on the Add API key button.

  • Put some name for the API key and click on Submit button.

  • Copy the created API key and save it, we will need it for integration on ThingsBoard.

Now we can move to ThingsBoard to configure integration.

At first, copy the code for uplink converter, we will need it for integration:

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
var data = decodeToJson(payload);
var deviceName = data.deviceInfo.deviceName;
var deviceType = data.deviceInfo.deviceProfileName;

// If you want to parse incoming data somehow, you can add your code to this function.
// input: bytes 
// expected output: 
//  {
//    "attributes": {"attributeKey": "attributeValue"},
//    "telemetry": {"telemetryKey": "telemetryValue"}
//  }
// default functionality - convert bytes to HEX string with telemetry key "HEX_bytes"

function decodePayload(input) {
    var output = { attributes:{}, telemetry: {} };
    // --- Decoding code --- //
    
    output.telemetry.HEX_bytes = bytesToHex(input);
    
    // --- Decoding code --- //
    return output;
}

// --- attributes and telemetry objects ---
var telemetry = {};
var attributes = {};
// --- attributes and telemetry objects ---

// --- Timestamp parsing
var dateString = data.time.substring(0, data.time.lastIndexOf('+')-3) + "Z";
var timestamp = new Date(dateString).getTime();
// --- Timestamp parsing

// You can add some keys manually to attributes or telemetry
attributes.fPort = data.port;
attributes.encodedData = data.data;

// You can exclude some keys from the result
var excludeFromAttributesList = ["deviceName", "rxInfo", "txInfo", "deduplicationId", "time", "dr", "fCnt", "fPort"];
var excludeFromTelemetryList = ["data", "deviceInfo", "devAddr", "adr"];

// Message parsing
// To avoid paths in the decoded objects we passing false value to function as "pathInKey" argument.
// Warning: pathInKey can cause already found fields to be overwritten with the last value found.

var telemetryData = toFlatMap(data, excludeFromTelemetryList, false);
var attributesData = toFlatMap(data, excludeFromAttributesList, false);

var uplinkDataList = [];

// Passing incoming bytes to decodePayload function, to get custom decoding
var customDecoding = decodePayload(hexToBytes(data.data));

// Collecting data to result
if (customDecoding.?telemetry.size() > 0) {
    telemetry.putAll(customDecoding.telemetry);
}

if (customDecoding.?attributes.size() > 0) {
    attributes.putAll(customDecoding.attributes);
}

telemetry.putAll(telemetryData);
attributes.putAll(attributesData);

var deviceInfo = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: {
        ts: timestamp, 
        values: telemetry
    },
    attributes: attributes
};

uplinkDataList.add(deviceInfo);

if (data.cmd == "gw") {
    foreach( gatewayInfo : data.gws ) {
        var gatewayInfoMsg = {
            deviceName: gatewayInfo.gweui,
            deviceType: "LoraGateway",
            attributes: {},
            telemetry: {
                "ts": gatewayInfo.ts,
                "values": toFlatMap(gatewayInfo, ["ts", "time", "gweui"], false)
            }
        };
        uplinkDataList.add(gatewayInfoMsg);
    }
}

return uplinkDataList;

Create integration

Next we will create an integration with Chirpstack inside the ThingsBoard and configure the integration on Chirpstack.

To add integration click on ‘+’ button and follow the next steps:

  • Go to Integrations, press plus button and choose Chirpstack as a type, put some name.

  • Check Create new uplink data converter and replace a code or create the existing one.

  • Put your Application server URL and API Key from Chirpstack and copy HTTP endpoint URL, Click on Add button.

  • Open your Chirpstack, go to Applications -> Your application -> Integrations tab.

  • Scroll down and click on + under HTTP tile. Put HTTP URL endpoint into Event Endpoint URL(s) field and click on Submit button.

Integrations are created.

Add a gateway on The Things Stack Community Edition

We need to add a gateway on The Things Stack Community Edition.
To add a gateway, you can follow next steps:

  • Login to the cloud and open your console.

  • Choose Register a gateway.

  • Press Add gateway button.

  • Put information about the gateway (gateway EUI).

  • The gateway is added.

Configure the gateway to send data

To connect and send data to The Things Stack Community Edition we should configure the gateway.
To do this please follow next steps:

  • Open gateway control panel.

  • Click on plus button, to add a new forwarder.

  • Put into Server address your server address, in our case it is eu1.cloud.thethings.network

  • Press Save button.

Now, the gateway is able to send a data to the network server.

Configure application on The Things Stack Community Edition

Now we need to configure application on The Things Stack. To do this please follow next steps:

  • Open your console and click on Create an application.

  • Create a new application.

  • Open Integrations -> MQTT in the menu.

  • Click on Generate new API key button.

  • Press on copy icon to copy a key and save it.

Now we can move to ThingsBoard to configure integration.

At first, copy the code for uplink converter, we will need it for integration:

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var data = decodeToJson(payload);

var deviceName = data.end_device_ids.device_id;
var deviceType = data.end_device_ids.application_ids.application_id;

// If you want to parse incoming data somehow, you can add your code to this function.
// input: bytes
// expected output:
//  {
//    "attributes": {"attributeKey": "attributeValue"},
//    "telemetry": {"telemetryKey": "telemetryValue"}
//  }
// default functionality - convert bytes to HEX string with telemetry key "HEX_bytes"

function decodeFrmPayload(input) {
    var output = { attributes:{}, telemetry: {} };
    // --- Decoding code --- //

    output.telemetry.HEX_bytes = bytesToHex(input);

    // --- Decoding code --- //
    return output;
}

// --- attributes and telemetry objects ---
var telemetry = {};
var attributes = {};
// --- attributes and telemetry objects ---

// --- Timestamp parsing
var incomingDateString = data.uplink_message.received_at;
var dateString = incomingDateString.substring(0, incomingDateString.lastIndexOf(".")+3) + "Z";
var timestamp = new Date(dateString).getTime();
// --- Timestamp parsing

// You can add some keys manually to attributes or telemetry
attributes.f_port = data.uplink_message.f_port;
attributes.settings = data.uplink_message.settings;
// We want to save correlation ids as single object, so we are excluding them from attributes parse and add manually
attributes.correlation_ids = data.correlation_ids;

// You can exclude some keys from the result
var excludeFromAttributesList = ["device_id", "application_id", "uplink_message", "correlation_ids"];
var excludeFromTelemetryList = ["uplink_token", "gateway_id", "settings"];

// Message parsing
// To avoid paths in the decoded objects we passing false value to function as "pathInKey" argument.
// Warning: pathInKey can cause already found fields to be overwritten with the last value found, e.g. receive_at from uplink_message will be written receive_at in the root.
var telemetryData = toFlatMap(data.uplink_message, excludeFromTelemetryList, false);
var attributesData = toFlatMap(data, excludeFromAttributesList, false);

// Passing incoming bytes to decodeFrmPayload function, to get custom decoding
var customDecoding = {};
if (data.uplink_message.get("frm_payload") != null) {
  customDecoding = decodeFrmPayload(base64ToBytes(data.uplink_message.frm_payload));
}

// Collecting data to result
if (customDecoding.?telemetry.size() > 0) {
    telemetry.putAll(customDecoding.telemetry);
}

if (customDecoding.?attributes.size() > 0) {
    attributes.putAll(customDecoding.attributes);
}

telemetry.putAll(telemetryData);
attributes.putAll(attributesData);

var result = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: {
        ts: timestamp,
        values: telemetry
    },
    attributes: attributes
};

return result;

Create integration

Next we will create an integration with The Things Stack (TTS) inside the ThingsBoard.

Open Integrations section and add new Integration with the following parameters:

  • Name: The Things Stack Application
  • Type: The Things Stack Community
  • Uplink data converter: The Things Stack Integration Uplink Converter
  • Region: eu1 (region where your application was registered inside The Things Stack Community)
  • Username: thingsboard-application@ttn (use Username from integration on TTS)
  • Password: use Password from integration on The Things Stack Community

To add integration click on ‘+’ button and follow the next steps:

  • Go to Integrations, press plus button and choose The Things Stack Community as a type, put some name.

  • Check Create new uplink data converter and replace a code or create the existing one.

  • Fill the field with your parameters,

Press Add button and integration will be added.

Add a gateway on The Things Industries

We need to add a gateway on The Things Industries cloud.
To add a gateway, you can follow next steps:

  • Login to the cloud and open your console.

  • Choose Gateways.

  • Press Add gateway button.

  • Put information about the gateway (gateway EUI).

  • The gateway is added, copy and save Gateway Server address, we will need it later.

Configure the gateway to send data

To connect and send data to The Things Industries cloud we should configure the gateway.
To do this please follow next steps:

  • Open gateway control panel

  • Click on plus button, to add a new forwarder

  • Put Gateway Server address from the network server

  • Press Save button

Now, the gateway is able to send a data to the network server.

Configure application on The Things Industries cloud

Now we need to configure integration on The Things Industries. to do this please follow next steps:

  • Open Integrations -> MQTT in the menu.

  • Click on Generate new API key button.

  • Press on copy icon to copy a key and save it (After leaving the page it won

At first, we will create an uplink converter to process the incoming data:

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
var data = decodeToJson(payload);

var deviceName = data.end_device_ids.device_id;
var deviceType = data.end_device_ids.application_ids.application_id;

// If you want to parse incoming data somehow, you can add your code to this function.
// input: bytes
// expected output:
//  {
//    "attributes": {"attributeKey": "attributeValue"},
//    "telemetry": {"telemetryKey": "telemetryValue"}
//  }
// default functionality - convert bytes to HEX string with telemetry key "HEX_bytes"

function decodeFrmPayload(input) {
    var output = { attributes:{}, telemetry: {} };
    // --- Decoding code --- //

    output.telemetry.HEX_bytes = bytesToHex(input);

    // --- Decoding code --- //
    return output;
}

// --- attributes and telemetry objects ---
var telemetry = {};
var attributes = {};
// --- attributes and telemetry objects ---

// --- Timestamp parsing
var incomingDateString = data.uplink_message.received_at;
var dateString = incomingDateString.substring(0, incomingDateString.lastIndexOf(".")+3) + "Z";
var timestamp = new Date(dateString).getTime();
// --- Timestamp parsing

// You can add some keys manually to attributes or telemetry
attributes.f_port = data.uplink_message.f_port;
attributes.settings = data.uplink_message.settings;
// We want to save correlation ids as single object, so we are excluding them from attributes parse and add manually
attributes.correlation_ids = data.correlation_ids;

// You can exclude some keys from the result
var excludeFromAttributesList = ["device_id", "application_id", "uplink_message", "correlation_ids"];
var excludeFromTelemetryList = ["uplink_token", "gateway_id", "settings"];

// Message parsing
// To avoid paths in the decoded objects we passing false value to function as "pathInKey" argument.
// Warning: pathInKey can cause already found fields to be overwritten with the last value found, e.g. receive_at from uplink_message will be written receive_at in the root.
var telemetryData = toFlatMap(data.uplink_message, excludeFromTelemetryList, false);
var attributesData = toFlatMap(data, excludeFromAttributesList, false);

// Passing incoming bytes to decodeFrmPayload function, to get custom decoding
var customDecoding = {};
if (data.uplink_message.get("frm_payload") != null) {
  customDecoding = decodeFrmPayload(base64ToBytes(data.uplink_message.frm_payload));
}

// Collecting data to result
if (customDecoding.?telemetry.size() > 0) {
    telemetry.putAll(customDecoding.telemetry);
}

if (customDecoding.?attributes.size() > 0) {
    attributes.putAll(customDecoding.attributes);
}

telemetry.putAll(telemetryData);
attributes.putAll(attributesData);

var result = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: {
        ts: timestamp,
        values: telemetry
    },
    attributes: attributes
};

return result;

Create integration

Next we will create an integration with The Things Industries inside the ThingsBoard.

Open Integrations section and add new Integration with the following parameters:

  • Region: eu1 (region where your application was registered inside The Things Industries Console)
  • Username: thingsboard-data-integration@thingsboard (use Username from integration on The Things Stack Industries)
  • Password: use Password from integration on The Things Industries

To add integration click on ‘+’ button and follow the next steps:

  • Go to Integrations, press plus button and choose The Things Industries Integration as a type, put some name.

  • Check Create new uplink data converter and replace a code or create the existing one.

  • Fill the field with your parameters,

Press Add button and integration will be added.

Add a gateway on the Loriot

We need to add a gateway on the Loriot.
To add a gateway, you can follow next steps:

  • Login to Loriot server. We use eu2.loriot.io, but it depends on chosen region during registration.

  • Go to Networks and open Sample network or create a new one.

  • Scroll down and choose Packet Forwarder Semtech option.

  • Scroll up and put information about the gateway MAC Address (Just remove FFFF or FFFE in the middle of gateway EUI) into eth0 MAC address and gateway EUI to Custom EUI field.

  • The gateway is added.

Configure the gateway to send data

To connect and send data to the Loriot we should configure the gateway.
To do this please follow next steps:

  • Open gateway control panel.

  • Click on plus button, to add a new forwarder.

  • Put into Server address your server address, in our case it is eu2.loriot.io. And set ports to 1780.

  • Press Save button.

  • Now you can check the status of the gateway on the Loriot, it should be connected.

Now, the gateway is able to send a data to the network server.

At first, copy the code for uplink converter, we will need it for integration:

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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var data = decodeToJson(payload);
var deviceName = data.EUI;
var deviceType = "LoraDevices";

// If you want to parse incoming data somehow, you can add your code to this function.
// input: bytes 
// expected output: 
//  {
//    "attributes": {"attributeKey": "attributeValue"},
//    "telemetry": {"telemetryKey": "telemetryValue"}
//  }
// default functionality - convert bytes to HEX string with telemetry key "HEX_bytes"

function decodePayload(input) {
    var output = { attributes:{}, telemetry: {} };
    // --- Decoding code --- //
    
    output.telemetry.HEX_bytes = bytesToHex(input);
    
    // --- Decoding code --- //
    return output;
}

// --- attributes and telemetry objects ---
var telemetry = {};
var attributes = {};
// --- attributes and telemetry objects ---

// --- Timestamp parsing
var timestamp = data.ts;
// --- Timestamp parsing

// You can add some keys manually to attributes or telemetry
attributes.fPort = data.port;
attributes.battery = data.bat;

// You can exclude some keys from the result
var excludeFromAttributesList = ["data", "gws", "EUI", "ts", "cmd", "port", "seqno", "fcnt", "toa", "ack", "bat", "snr", "rssi"];
var excludeFromTelemetryList = ["gws", "EUI", "ts", "freq", "port", "data", "cmd", "dr", "offline"];

// Message parsing
// To avoid paths in the decoded objects we passing false value to function as "pathInKey" argument.
// Warning: pathInKey can cause already found fields to be overwritten with the last value found.

var telemetryData = toFlatMap(data, excludeFromTelemetryList, false);
var attributesData = toFlatMap(data, excludeFromAttributesList, false);

var uplinkDataList = [];

// Passing incoming bytes to decodePayload function, to get custom decoding
var customDecoding = decodePayload(hexToBytes(data.data));

// Collecting data to result
if (customDecoding.?telemetry.size() > 0) {
    telemetry.putAll(customDecoding.telemetry);
}

if (customDecoding.?attributes.size() > 0) {
    attributes.putAll(customDecoding.attributes);
}

telemetry.putAll(telemetryData);
attributes.putAll(attributesData);

var deviceInfo = {
    deviceName: deviceName,
    deviceType: deviceType,
    telemetry: {
        ts: timestamp, 
        values: telemetry
    },
    attributes: attributes
};

uplinkDataList.add(deviceInfo);

if (data.cmd == "gw") {
    foreach( gatewayInfo : data.gws ) {
        var gatewayInfoMsg = {
            deviceName: gatewayInfo.gweui,
            deviceType: "LoraGateway",
            attributes: {},
            telemetry: {
                "ts": gatewayInfo.ts,
                "values": toFlatMap(gatewayInfo, ["ts", "time", "gweui"], false)
            }
        };
        uplinkDataList.add(gatewayInfoMsg);
    }
}

return uplinkDataList;

Create integration

Next we will create an integration with Loriot inside the ThingsBoard.

To add integration click on ‘+’ button and follow the next steps:

  • Go to Integrations, press plus button and choose Loriot as a type, put some name.

  • Check Create new uplink data converter and replace a code or create the existing one.

  • Go to Applications in the left menu and choose SampleApp or create a new one. Copy Application ID.

  • Fill the field with your parameters,

Press Add button and integration will be added.

To check integration connection you can do the following:

  • Click on integration row in the list
  • Go to Events tab
  • Select Lifecycle events from Event type dropdown list

Check integration connection

If you see event STARTED and status Success it means that integration is successfully started and ready to receive messages.

Conclusion

With the knowledge in this guide, you can easily connect your UG67 LoRaWAN® Gateway and use the built-in integration to retrieve data from devices connected to UG67 LoRaWAN® Gateway .

You can find some LoRaWAN devices in our device library and connect them or any other devices through a gateway on a network server.

After connecting the devices to the gateway, you will be able to see and process the data coming from the devices on the ThingsBoard.

Explore the platform documentation to learn more about key concepts and features.