How to remotely issue polling commands to the data collector RAK7421 with the help of MQTT?

table of Contents

Preface

1. Types of polling commands issued remotely

2. Increase the timed polling task list message

3. Remove the timed polling task list

Fourth, read the timed polling task list

Conclusion


Preface

RS485 to LoRaWAN data collector, as the name suggests, is a bridge between sensors with RS485 interface commonly used in industry and LoRaWAN network. Limited by the location of industrial sensors, the installation location of the RS485 to LoRaWAN data collector may not be convenient for on-site debugging. Therefore, it is very important to issue commands remotely.

In addition, the function of setting polling instructions is that we can make the sensors poll regularly without issuing instructions from the server every time, which can greatly reduce the possibility of network congestion.

Based on the data collector RAK7421 of RAK Huilian, this article introduces how to remotely issue polling commands to RAK7421 through the MQTT tool.

If you want to know what an RS485 to LoRaWAN data collector is, please refer to the article " Why do you need an RS485 to LoRaWAN data collector ".

 

1. Types of polling commands issued remotely

Remotely issue polling instructions to RAK7421 through the MQTT tool, including a total of three polling instructions:

  1. Added timed polling task list message
  2. Remove timed polling task list
  3. Read timed polling task list

Next, we will introduce these three polling instructions in detail.

 

mqtt issues instructions to RAK7421, which need to be issued through the LoRaWAN gateway.

Therefore, in order to be able to use the MQTT tool to remotely issue polling commands to RAK7421, we need to log in to the user interface of the gateway provided by RAK RAK Huilian, as shown in Figure 1, and go through the following path: LoRa Network sever->Application ->Edit->Integrations, to modify the data encoding type to HEX String.

RAK Rui Ke Hui Lian's LoRaWAN gateway user interface
Figure 1 LoRaWAN gateway user interface of RAK Huilian

 

After the modification is completed, we can use the MQTT tool to issue instructions to RAK7421.

If you want to know more about the application of MQTT function on LoRaWAN gateway, you can also check the article " How to set up MQTT Topic on LoRaWAN gateway? 》、《Data transmission between LoRa node and MQTT server built in gateway

 

2. Increase the timed polling task list message

The format of the downstream command message is shown in Table 1.

Table 1 Add the downlink command message format of the timed polling task list message

DTU command word

Message sequence number

Message length

mission list

0x03

2Byte

2Byte

Task ID

Task list content

1Byte

nByte

Note: The message length does not include the message header

 

Figure 2 is an example diagram of adding a task sheet for polling temperature and humidity sensors on a RAK7421 node.

RAK7421 node adds timed polling temperature and humidity sensor task list example
Figure 2 An example of adding a task list to the RAK7421 node to poll the temperature and humidity sensor at a fixed time

 

As shown in Figure 2, publish the topic:

Application/1/device/60c5a8fffe76ddc1/tx

(Note: Application ID and Device EUI are consistent with the settings in the gateway)

content:

{

"comfirmed":true,

"fPort":129,

"data":"030001000901010300000002C40B"

}

Explanation of task list content:

 

03 0001 0009 01 010300000002C40B

 ②   ③ ④        ⑤

 

  1. DTU command word CMD
  2. Message sequence number
  3. Message length (without message header)
  4. Task ID
  5. Task list content

 

The format of the upstream message for successful execution is shown in Table 2.

Table 2 Increase the format of the uplink command message for the successful execution of the scheduled polling task list

DTU command word

Message sequence number

Message length

mission list

0x83

2Byte

2Byte

0Byte

 

As shown in Figure 3, in the MQTT subscription column, you can see the successful uplink message "8300010000", and then start polling and receive the sensor temperature and humidity information.

The schematic diagram of the MQTT subscription bar showing the successful execution of the upstream message
Figure 3 Schematic diagram of the MQTT subscription bar showing the successful execution of the upstream message

 

3. Remove the timed polling task list

The format of the downstream command message is shown in Table 3.

Table 3 The format of the downlink command message to remove the timed polling task list

DTU command word

Message sequence number

Message length

mission list

0x04

2Byte

2Byte

Task ID

1Byte

 

Figure 4 shows an example of the task list of RAK7421 node removing the timed polling temperature and humidity sensor.

RAK7421 node removes the task list example of timed polling temperature and humidity sensor
Figure 4 Example of removing the task list of the timed polling temperature and humidity sensor from the RAK7421 node

 

 

Publish topic:

Application/1/device/60c5a8fffe76ddc1/tx

content:

{

"comfirmed":true,

"fPort":129,

"data":"040001000101"

}

 

The format of the upstream message for successful execution is shown in Table 4.

Table 4 The message format of the uplink command that removes the successful execution of the timed polling task list

DTU command word

Message sequence number

Message length

mission list

0x84

2Byte

2Byte

0Byte

If you see the successfully executed uplink message "8400010000" in the MQTT subscription column, it means that the task is removed successfully.

 

Fourth, read the timed polling task list

The format of the downstream command message is shown in Table 5.

Table 5 Read the downlink command message format of the timed polling task list

DTU command word

Message sequence number

Message length

mission list

0x05

2Byte

2Byte

Task ID

1Byte

 

The example of RAK7421 node reading the task list of timed polling temperature and humidity sensor is shown in Figure 5.

Example of RAK7421 node reading the task list of timed polling temperature and humidity sensor
Figure 5 Example of RAK7421 node reading the task list of timed polling temperature and humidity sensor

 

 

Publish topic:

Application/1/device/60c5a8fffe76ddc1/tx

content:

{

"comfirmed":true,

"fPort":129,

"data":"050001000101"

}

 

The format of the upstream message for successful execution is shown in Table 6.

Table 6 Read the message format of the uplink command for the successful execution of the timed polling task list

DTU command word

Message sequence number

Message length

mission list

0x85

2Byte

2Byte

Task ID

Task list content

1Byte

nByte

Open the MQTT subscription bar to see the successful execution of the upstream message: "850001000901010300000002C40B",

That is, the task list ID that is queried is 1, and the task list content is 010300000002C40B (temperature and humidity sensor polling list).

 

Conclusion

Based on the data collector RAK7421 of RAK Huilian, this article introduces how to remotely issue polling commands to RAK7421 through the MQTT tool.

By setting the polling instruction, we can make the sensors poll regularly without issuing instructions from the server every time, which can greatly reduce the possibility of network congestion.

Guess you like

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