How to Set the Topic of MQTT on the LoRaWAN Indoor Gateway
When we set the LoRaWAN indoor gateway to NS mode, we can operate on the web page of the LoRaWAN indoor gateway to set the topic of the gateway's MQTT subscription, so as to establish the basis for obtaining LoRa node data using MQTT subscription.
This article describes how to set the topic parameters of MQTT on the webpage of RAK's LoRa indoor gateway to obtain information about a LoRa node or all LoRa nodes under an application.
1. Add Application and LoRa nodes to the commercial LoRaWAN indoor gateway
After the business gateway mode is successfully switched, we need to add applications and nodes to the business gateway.
After obtaining the IP address of the gateway, enter the IP address of the commercial gateway in the browser and press Enter to open the web interface of the commercial gateway. On the web interface, you can refer to the menu options to simply complete the application and LoRa nodes. create.
2. In the web interface of the commercial LoRaWAN indoor gateway, set the MQTT related parameters to obtain the subscribed topic.
On the webpage of the commercial LoRa indoor gateway, on the menu, select LoRa Network -> Global IntegraTIon, there is an option of MQTT Topic template Setup on this page, users can set the source of different types of topics on this page.
The types of topics available for selection include five options: Join Topic, Uplink Topic, Downlink Topic, Ack Topic, and Status Topic.
Under each option, the applicable Topic type for the option is indicated, and the fill-in place for each option also displays the format of the information that needs to be filled in for each option in a preset gray font.
It should be noted that the format must be exactly the same as the format of the preset gray font. For example, when we need a Join Topic, the format is: application/application_ID/device/device_EUI/join, where application_ID and device_EUI are the information that needs to be filled in according to the actual situation, respectively representing the ID of the application to be used. And the device_EUI of the LoRa node.
On the webpage of the LoRa indoor gateway, set the relevant parameter information of the topic of MQTT, and then you can use the information of the topic to correspond to the information you need to obtain. In order to make it easier to understand, we can make some analogies. For example, we can understand the MQTT server as a news website, then Topic can be understood as different sections of the news website, such as social news, sports forums, etc., filling in the Topic parameter information is quite As for the information of which section is selected on the news website, successful subscription is equivalent to selecting the content of the section, and you can obtain the information of the section for reading.
If we need to subscribe to the data reported by the LoRa node, set the parameters in the Uplink Topic. The parameter setting format of Uplink Topic is:
Among them, application_ID needs to be replaced with our actual application ID, and device_EUI needs to be replaced with device_EUI of our LoRa node.
After obtaining our actual application ID and the device_EUI of the LoRa node, according to the parameter setting format of Uplink Topic, fill in the blank:
Among them, the blue font is the actual application ID we filled in and the device_EUI of the LoRa node.
If we want to subscribe to all LoRa node data under an application, such as all node data under application 2, we can use the following topic:
Among them, "+" represents all LoRa nodes.
If we want to subscribe to all LoRa node data under all applications, we can use the following topic: application/+/device/+/rx
As mentioned above, after setting the topic information of MQTT on the webpage of the LoRa indoor gateway, we can set it up on the mqtt.fx client to subscribe to the data of the LoRa node.
3. How many nodes can a LoRaWAN indoor gateway support
Perhaps the most important question for anyone looking to buy a LoRaWAN indoor gateway is: How many nodes can a gateway hold? I have N nodes, how many LoRaWAN indoor gateways are needed? Sadly, there is no easy answer to this question.
3.1 The number of nodes that a single LoRaWAN indoor gateway can accommodate
3.1.1 Theoretical value
Assuming that a single gateway can receive at most a data packets per day, and the application packet sending frequency of each node is b data packets per hour, then the theoretical value of the maximum number of nodes that a single gateway can accommodate is as follows:
For example, if a single LoRaWAN indoor gateway is equipped with an SX1301 chip, it can receive up to 1.5 million data packets per day. If the application packet sending frequency is 1 packet per hour, then theoretically the number of nodes that the LoRaWAN indoor gateway can access S = 1500000 /(24*1) = 62500.
3.1.2 Actual value
The actual value of the number of nodes that a single gateway can accommodate is more complicated than the theoretical value. For a certain gateway, the maximum number of data packets it can receive per day is also determined, and the difficulty lies in how many packets each node sends every day.
In the same application scenario, the total length of data that we need to send by the node every day is determined, but it is uncertain what packet length and transmission rate the data of the determined length should be sent at. If the packet length is different, the number of packets to be sent is bound to be different.
For example, under different signal strengths, the used spreading factor SF is also different, then the length of the data that can be sent is also different, and the length of the data that can be sent each time is different, which leads to the number of packets that need to be divided. are different, so that even if the same gateway and the same node are used, the maximum number of nodes accommodated by a single gateway may be different under different service modes of the nodes.
For a gateway with 8 channels, without LBT (monitoring channels before sending packets), the specific calculation formula is:
Channel capacity (that is, the number of nodes) S=8T/2et0.
Among them, 8 represents 8 channels, T represents the transmission interval, which is related to the packet length and rate, 1/2e is the maximum throughput of the basic Aloha algorithm, e is a constant, equal to 2.718, t0 represents a single packet ToA (TIme on Air) .
For example, if the SX1301 chip is used, in the absence of LBT (monitoring the channel before sending packets), and the average air flight time of each packet is t0=100ms (so t0=0.1s), and each packet is sent once a minute on average ( So T=60s), how many such average nodes can be accommodated? S=8*60/(2*2.718*0.1)=883 , therefore, 883 nodes can be accommodated.
Moreover, the use of different algorithms will also lead to changes in the maximum throughput, thereby causing changes in theoretical capacity.
For example, if the precondition is modified so that each node has the LBT function, and the slotted Aloha algorithm is used instead of the previous basic Aloha algorithm to evaluate, the maximum throughput will be different due to the different algorithms, and the maximum throughput at this time is 1/ e, so the channel capacity (that is, the number of nodes) S=8T/et0, thus, the theoretical capacity is doubled, that is, 883*2=1766 nodes.
3.2 Rough estimate
If you don't want to calculate, then we can make a rough estimate through the following simple reference example.
In the case of gateway signal coverage, 90% of the signal strength meets the rate of SF9 or higher, if 50 bytes are sent at a frequency of 5s, an 8-channel gateway can correspond to almost 40 terminals/nodes.
There is a linear relationship between frequency and capacity. Therefore, if the actual required frequency is changed to, for example, the sending frequency of 10s, it can be inferred that the 8-channel gateway can access almost 80 terminals/nodes.
In the scenario where ADR is turned on and 90% of the terminal rates are greater than DR3 (SF9), there is almost a linear relationship between bytes and capacity. Therefore, an estimated value can also be obtained by simply substituting the bytes of the actual scene into the above example.
(1) Number of gateways
Since it is best that one node can ensure that 2~3 gateways can receive data, if it is calculated according to the above method that a total of N gateways are needed to correspond to all nodes, then, in practical applications, it is recommended to use 2N~ 3N gateways, instead of N gateways, correspond to all nodes to ensure that data can be received.
(2) Sending interval
Unless there are very special applications, it is not recommended that the sending interval be less than 5s. Generally speaking, it is better to send the interval at least at the minute level.
For the standard LoRaWAN protocol, sending a packet requires at least a 2s interval.
SF sends 64 bytes, and the air interface time is close to 3s. If you do not comply with LoRaWAN's air interface time requirements, although the gateway is only responsible for transparent transmission, even if the LoRaWAN protocol is not complied with, the physical layer can still receive data, but at this time, users need to verify and test the packet loss rate by themselves .
4. The number of nodes that the LoRaWAN indoor gateway multi-gateway can accommodate
In practical application scenarios, a single gateway cannot meet the coverage and capacity requirements.
In the case of satisfying a certain signal ratio, the gateway can receive the signal data of SF7~SF12 at the same time. The demodulation and coverage capabilities of a single gateway are limited. Theoretically, this capacity can be achieved, but in practice, it is difficult. However, by deploying multiple gateways, the network capacity can be maximized. Therefore, in practice, multiple gateways are often used.
4.1 Fixed rate
When the rate is fixed, if there are N gateways, then the capacity of multiple gateways = the capacity of a single gateway * N.
Wherein, the capacity of a single gateway can be calculated or estimated according to the first part.
4.2 Enable ADR
When ADR is turned on, the capacity of multiple gateways will not change linearly.
According to the actual measurement results published by Smetech, when ADR is used, the capacity of multiple gateways > the capacity of single gateway * N.^2.
Small TIp: Moreover, in addition to increasing the capacity of the gateway, turning on ADR also helps to reduce power consumption, because ADR technology can automatically adjust the transmission power of data according to the quality of the LoRa signal. Both RAK7249/RAK7258 series products support enabling the ADR function, which can effectively reduce the emission current of the LoRa terminal in conjunction with the RAK node. For details, please refer to the article "LoRa Terminal Low Power Consumption Development Strategy".
4.3 Recommendations for Multi-Gateway Deployment
(1) Turn on ADR
Turning on ADR can expand the overall capacity of existing gateways as much as possible on the premise of the same number of gateways.
(2) Select co-frequency deployment
Co-frequency deployment enables nodes to connect to the nearest gateway, maximizing the ADR effect of the network. The improvement of the ADR effect is the optimization of the speed of the node. An increase in rate means a decrease in TOA, which in turn means an increase in capacity and a decrease in power consumption.
Therefore, when using multiple gateways, it is recommended to use the same frequency deployment, which can accommodate more nodes than the different frequency deployment. The addition of inter-frequency gateways is only considered when co-frequency deployment cannot meet the capacity requirements.
(3) The scope of deployment is such that one node can be received by 2~3 gateways.
It can be seen that for the same number of LoRaWAN indoor gateways, if you want to accommodate a larger number of nodes, you need to improve from the following aspects: select the appropriate length of the data sent, select the gateway with LBT function and use more Optimized algorithms, enable ADR, and choose co-frequency deployment.
The above is the calculation method of how to calculate the gateway capacity of the LoRaWAN indoor gateway, which involves the calculation of the number of nodes that can be accommodated by a single gateway and multiple gateways.