Description
When operating as an integrated network server, Milesight LoRaWAN gateways support sending data packets to a third-party MQTT/HTTP/HTTPS server. We can create a new application on the gateway, which can set the decoding method of the data sent from the LoRaWAN end device and choose the MQTT data transport protocol to send the data to the MQTT server.
Requirement
- Milesight LoRaWAN Gateway: UG8x (firmware version 80.0.0.64 or later), UG65, UG67, UG56, UG63 V1
- MQTT server/broker
- MQTT client tool: take MQTT Explorer as an example
Configuration
Step 1. Enable the network server built into the gateway.
Go to Packet Forwarder > General to enable the localhost server address.
Enable the network server on the Network Server > General page .
Step 2. Add an app
Go to Network Server>Applications to add a new application, click Save.
Name: user defined, arbitrary value
Description: User defined, arbitrary value
Step 3. Connect the gateway to the MQTT broker.
Go to Network Server > Applications to add " data transmission " for the application. An application can only add one MQTT integration.
Fill in the MQTT broker information and create a topic to store different types of data, click Save.
Broker Address: IP address/domain of the MQTT broker
Broker port: MQTT broker communication port
Client ID: User-defined, a unique identifying identity of the client on the server.
User credentials and TLS should be enabled and configured as needed.
Note: If the MQTT broker is HiveMQ, please enable TLS and set the option to C A Signed Server Certificate .
Once the MQTT configuration is complete, you can check the connection status here:
Step 4. Add LoRaWAN nodes to the gateway.
Go to Network Server > Profiles to add a new profile, then click Save. You can also use predefined profiles.
Name: user defined, arbitrary value
Max transmit power : default value
Other settings can be checked in the LoRaWAN Nodes User Guide or you can keep all settings as default.
Go to Network Server > Device to add a new device, click Save and Apply .
Device name: arbitrary user-defined value
Description: User defined, arbitrary value
Device Profile: Choose one of the matching profiles added before.
Application: Choose one of the matching applications added before.
Other parameters can be confirmed with LoRaWAN node manufacturers.
When the status appears as below, it means the above steps are performed correctly.
Step 5. Add an uplink data topic.
Customize the uplink data to publish to the MQTT broker and save the settings. If you add "$deveui" to your topic, you can replace it with an actual device EUI when subscribing to topics.
Example : /milesight/uplink/$deveui
Step 6. Subscribe to the MQTT client topic to get uplinks.
MQTT Explorer is a complete MQTT client and it can be replaced by other types of MQTT client tools (MQTT.fx, MQTT Box, etc.)
Open the MQTT Explorer and fill in the MQTT server information in the pop-up window.
Name: user defined
Protocol: mqtt://
Host: MQTT broker address
Port: broker port
Username/Password: If you have credentials, please provide them. Otherwise, leave them blank.
Click ADVANCED, copy the uplink data topic to the gateway and paste it into MQTT Explorer, click +ADD .
Leave the default MQTT client ID, then click BACK and click CONNECT .
After some time, the data will be transmitted to the MQTT broker and MQTT Exploerer will be able to receive the data from the MQTT server.
The uplink format is fixed in json and the content is as follows.
If you need to send downlink commands from the MQTT client, please refer to the article How to Remotely Control Devices via MQTT on Milesight Gateway .
FAQs
Q1 . How to send decoded or custom uplink content to the MQTT broker?
A1: Yes, this must use the Payload Codec functionality on the gateway. Reference articles:
UG56/UG65/UG67: How to use payload codec on Milesight Gateway
UG63 V1/UG8x: How to use payload codec on Milesight Gateway (legacy)
Q2 . What is the troubleshooting when MQTT server connection status is “Disconnected”.
A2:
1) Go to Maintenance > Tools > Ping , check if the gateway can ping the broker address successfully.
2) Check if your MQTT client tool can connect to the MQTT broker correctly, then follow the MQTT client tool settings to configure the gateway.
3) Check if the gateway's MQTT client ID conflicts with other MQTT clients.
4) Check if the CPU load is too high and there is little RAM and eMMC available.
5) Change the log severity to Debug and replicate the disconnect issue, then download all log files and send them to iot.support@milesight.com .
Q3 . Why does the connection status show "connected" but the MQTT client is not receiving any data?
A3:
1) Make sure the devices have been added to the gateway and go to Network Server > Packets to check if there are uplink packets coming from the devices regularly.
2) Make sure the devices have been added to the correct app.
3) Make sure the gateway firmware is upgraded to the latest version. Download the firmware here: https://www.milesight.com/iot/resources/download-center/
4) Change the log severity to Debug and replicate the disconnect issue, then download all log files and send them to iot.support@milesight.com .