Skip to content
Stand with Ukraine flag

UG56 LoRaWAN® Gateway

UG56 LoRaWAN® Gateway

UG56 LoRaWAN® Gateway

Milesight

Platform
ThingsBoard
Hardware Type
Gateways
Connectivity
LoRaWAN, HTTP, MQTT, LTE, 4G, NB-IoT, LTE-M, UDP
Industry
Smart Cities, Environmental Monitoring
Use Case
Smart energy, Environment Monitoring, Smart Office, Smart Retail, Smart Farming, Fleet Tracking, Health Care, Air Quality Monitoring, Waste Management, Tank Level Monitoring

Introduction

UG56 LoRaWAN® Gateway is a high-performance 8-channel LoRaWAN® gateway that offers reliable connectivity for industrial applications.

Industrial-Grade Design Listen Before Talk Gateway Fleet

Free Embedded Network Server Multiple Backhaul Connectivities Global LoRaWAN® Frequency Plans: RU864/IN865/EU868/AU915/US915/KR920/AS923

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 UG56 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 the “Control Panel” → “Network and Internet” → “Network and Sharing Center”, then click “Ethernet” (May have different names).
    2. Go to the “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.

Go to the “Packet Forwarder” page in the left menu and save ‘Gateway EUI’ and ‘Gateway ID’ values. By default, Gateway EUI and Gateway ID are the same. We will need them to create a gateway on network server.

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, follow next steps:

  1. Login to Chirpstack server. Go to the “Gateways” page and click on the “Add gateway” button.
  2. 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 the “Submit” button.
  3. 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:

  1. Open gateway control panel. Go to the “Packet Forwarder” page and click on “plus” button, to add a new forwarder.
  2. Put into “Server address” your server address, in our case it is sample.network.server.com. Click “Save” button.
  3. Click “Save & Apply” button.
  4. 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:

  1. Go to the “Applications” page in the left menu and click on the “Add application” button.
  2. Fill application name and click on the “Submit” button.
  3. Go to the API keys page in the left menu and click on the “Add API key” button.
  4. Put some name for the API key and click on the “Submit” button.
  5. 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.

Create integration in ThingsBoard

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

At first, copy the code, we will need it to create the uplink converter:

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;

To add integration follow the next steps:

  1. Go to the “Integration center” section, “Integrations” page and click “plus” button to add new integration. Select type “Chirpstack”. Then, click “Next”.
  2. Paste the previously copied script to the Decoder function section. Click “Next”.
  3. Leave the “Downlink data converter” field empty. Click on “Skip” button.
  4. Put your “Application server URL” and “API Key” from Chirpstack and copy “HTTP endpoint URL”, Click on “Add” button.
  5. Now, open your Chirpstack, go to the “Applications” page -> Your application -> “Integrations” tab, Find and click on the HTTP tile.
  6. Put “HTTP URL endpoint” into “Event Endpoint URL(s)” field and click on “Submit” button.

Integration is created.


To check integration connection you can do the following:

  1. Click on integration row in the list;
  2. Go to the “Events” tab;
  3. Select “Lifecycle events” from Event type dropdown list.

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

Check integration connection

Conclusion

With the knowledge in this guide, you can easily connect your UG56 LoRaWAN® Gateway and use the built-in integration to retrieve data from devices connected to UG56 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.