Data transmission between the LoRa node and the built-in MQTT server of the gateway

Preface

In the previous article, how to subscribe to node data on the mqtt.fx client , we have introduced how to set the Topic parameters of MQTT on the web page of the LoRa gateway of RAK Huilian, and set it on the mqtt.fx client To subscribe to the data of the LoRa node.

This article describes how to test whether our previous settings are successful and whether the data transmission between the LoRa node and the MQTT server is normal.

If you want to learn about other ways to obtain data from the LoRa gateway, you can also refer to the article " How to obtain LoRaWAN terminal data locally without the Internet?" ", " Two steps to connect your own LoRaWAM gateway to Alibaba Cloud ", " Ultra-low cost get a new skill: IoT system development on Alibaba Cloud ", " How do LoRa nodes connect to the TTN server in OTAA? 》、《How does LoRa node access the TTN server in ABP mode?

 

1. The LoRa node sends data to the MQTT server built into the LoRaWAN gateway

After the LoRa node is successfully joined, we send a message on the LoRa node side, such as "Hello Rakwireless".

Since LoRa nodes need to receive hexadecimal data, we will convert "Hello Rakwireless" to hexadecimal, which is "48656c6c6f52616b776972656c657373". As shown in Figure 1, it is the LoRa node operation interface of RAK Huilian. The AT command at+send is used to send the information, and click to send.

 

RAK Rui Ke Hui Lian's LoRa node operation interface
Figure 1 LoRa node operation interface of RAK Huilian

 

After we send the information on the operation interface of the LoRa node, we can return to the interface of mqtt.fx to check to determine whether the MQTT server has received the data sent by the LoRa node we subscribed to.

 

RAK Rui Ke Hui Lian LoRaWAN gateway built-in MQTT server to receive data diagram
Figure 2 Schematic diagram of RAK Huilian LoRaWAN gateway built-in MQTT server to receive data

 

As shown in Figure 2, when we click to open the Subscribe interface, we can see that the data part is the data just sent by the LoRa node, but the format is different from the hexadecimal format just now. This is because the content of the Data part is sent to the LoRa node The data is base64 encoded, we only need to base64 decode the data part to see the original data.

Or, we can also view the web management page of the LoRaWAN commercial gateway provided by RAK Huilian. As shown in Figure 3, the management tool has already decoded the data by base64, so the data we see on the management page It is consistent with the hexadecimal data sent by the LoRa node just now.

The web management page of RAK's LoRaWAN commercial gateway
Figure 3 The web management page of RAK's LoRaWAN commercial gateway

 

 

2. The built-in MQTT server of the LoRaWAN gateway sends data to the LoRa node

We can also test whether the MQTT server built in the LoRaWAN gateway can successfully send information to the LoRa node.

If we want to send information to LoRa nodes through the mqtt.fx tool, we need to use Downlink Topic. Find and fill in the content of Downlink Topic as shown in Figure 4. For specific filling rules, please refer to our previous article, How to set up MQTT Topic on LoRaWAN gateway .

Topic fill-in interface for LoRaWAN gateway of RAK Huilian
Figure 4 Topic filling interface of LoRaWAN gateway of RAK Huilian

 

After filling in the Topic, you can click the Publish tab in the upper left corner of the mqtt.fx tool interface as shown in Figure 5, enter Downlink Topic in the input box 2, and enter {"confirmed" in the input box 3. : true,"data": "SGVsbG8=","fPort": 10}, click the Publish button of button 4 to send the data to the LoRa node.

It should be noted that whether the LoRa node can immediately receive the data sent by the MQTT server depends on the working mode of the LoRa node. When the working mode of the LoRa node is the Class c mode, the LoRa node will immediately receive the data issued by mqtt.fx; but if it is in the Class a mode, the LoRa node needs to upload the data next time before receiving the data Data issued by mqtt.fx).

MQTT tool release data interface
Figure 5 MQTT tool release data interface

 

 

Among them, we explain the format of {"confirmed": true,"data": "SGVsbG8=","fPort": 10}' :

    1. Confirmed optional value is true or false.
    2. The content of Data is the data we want to send, and the data needs to be base64 encoded.
    3. fPort is the port number to be sent, and the valid port number is 1-255.

 

We return to the LoRa node interface, as shown in Figure 6, you can see the received data on the LoRa node.

 

Schematic diagram of data received by LoRa node
Figure 6 Schematic diagram of LoRa node receiving data

 

Conclusion

This article describes how to test whether our previous settings are successful and whether the data transmission between the LoRa node and the MQTT server built into the LoRaWAN gateway is normal. If the LoRaWAN gateway does not have a built-in MQTT server, an external MQTT server is needed.

When using an external MQTT server, how to exchange data with nodes, please look forward to our next article.

 

Guess you like

Origin blog.csdn.net/RAKwireless/article/details/106689788