Description

Milesight LoRaWAN gateways support sending data packets to third party MQTT/HTTP/HTTPS server. We can create a new application on gateway, which can define the method of decoding the data sent from LoRaWAN end-device and choosing MQTT data transport protocol to send data to MQTT server.


Requirement

  • Milesight LoRaWAN Gateway: UG6x,UG8x (Firmware version 80.0.0.64 or later)
  • MQTT Server/Broker
  • MQTT Explorer (or other MQTT client tool)


Configuration

Step1. Enable the gateway built-in network server.

Go to Packet Forwarder > Generalto enable the localhost server address.

Enable the Network server on Network Server > General page.


Step2. Add an Application and Profiles.

Go to Network Server>Applications, add a new application, click save.

Name: user-defined, arbitrary value

Description: user-defined, arbitrary value

Payload Codec: None or custom your decoder

Go to Network Server>Profiles to add a new profile, then click save.

Name: user-defined, arbitrary value

Max TXPower: default value

Other parameters can be checked from LoRaWAN nodes user guide or you can keep all settings by default.

Step3. Add LoRaWAN nodes to the gateway.

Go to Network Server>Device, add a new device, click save&apply.

Device Name: user-defined, arbitrary value

Description: user-defined, arbitrary value

Device-Profile: choose one of corresponding profiles added before.

Application: choose one of corresponding applications added before.

Other parameters can be confirmed with the LoRaWAN node manufacturers.

When the status shows as below, that’s mean above steps are done correctly.


Step4. Forward data to MQTT broker.

Go to Network Server>Applications to add a “data transmission” for the application.

Fill in the MQTT broker information and create topic to store different data type, click save.

Broker Address: IP address/domain of MQTT server

Broker Port: Broker port of MQTT server, default port 1883

Client ID: user-defined, a unique ID identity of the client to the server.

Note: if MQTT broker needs credentials, please enable User Credentials and fill in correct username and password.

After MQTT configuration complete, you can check connection status here:


Step5. Subscribe corresponding topic from MQTT client.

MQTT explorer is a comprehensive MQTT client and it can be replaced to other kinds of MQTT client tools(MQTT.fx, MQTT Box, etc.)

Open the MQTT Explorer, and fill in related MQTT server information in the popup window.

Name: user-defined

Protocol: mqtt://

Host: MQTT broker address

Port: broker port

User name/Password: if there is user credentials, please fill in it. If not, keep them blank.

Click ADVANCED,copy the Uplink data topic on the gateway, and paste it on the MQTT explorer, click +ADD.

Keep MQTT client ID by default,then click BACK and click CONNECT.

After while, we can receive the data from MQTT server.


Step6. Publish Topic on MQTT Explorer to send downlink data to sensor. There is two type downlink formats:

1. Downlink Data is blank on gateway.


Publish Topic Format :

application/[applicationID]/device/[devEUI]/tx

Example :

From the gateway, we can get the application ID and device EUI about the device we want to control:


So we can publish a topic on the MQTT Explorer like below:

Topic: application/1/device/ 24e124126a148401/tx

Format: json

Content: check with the sensor payload document (get from sensor manufacturers)


2. Downlink Data filled in on the gateway end with“/$deveui”

Example: /milesight/downlink/$deveui

Publish Topic Format :

/milesight/downlink/[devEUI]

Example :

From the gateway, we can get the device EUI about the device we want to control:

So we can publish a topic on the MQTT Explorer like below:

Topic: /milesight/downlink/24e124126a148401

Format: json

Content: check with the sensor payload document (get from sensor manufacturer)

After click Publish, we can go to Network Server>Packets to check. If the gateway have subscribe corresponding downlink topic data successfully, there will be at least one grayed message packet record.


FAQ

Q1.Why the status of MQTT server connection is “Disconnected”.

A1: Go to Maintenance > Tools >Ping , confirm the gateway can ping to the broker address successfully like below first, then check all of above values filled in are correct.


Q2. How to send decoded data packet to MQTT server?

A2: Refer to How to Use Payload Codec on Milesight Gateway.