Evaluation of a LoRa Mesh Network for Smart Metering in Rural Locations

Accompanying the advancement on the Internet of Things (IoT), the concept of remote monitoring and control using IoT devices is becoming popular. Digital smart meters hold many advantages over traditional analog meters, and smart metering is one of application of IoT technology. It supports the conventional power system in adopting modern concepts like smart grids, block-chains, automation, etc. due to their remote load monitoring and control capabilities. However, in many applications, the traditional analog meters still are preferred over digital smart meters due to the high deployment and operating costs, and the unreliability of the smart meters. The primary reasons behind these issues are a lack of a reliable and affordable communication system, which can be addressed by the deployment of a dedicated network formed with a Low Power Wide Area (LPWA) platform like wireless radio standards (i.e., LoRa devices). This paper discusses LoRa technology and its implementation to solve the problems associated with smart metering, especially considering the rural energy system. A simulation-based study has been done to analyse the LoRa technology’s applicability in different architecture for smart metering purposes and to identify a cost-effective and reliable way to implement smart metering, especially in a rural microgrid (MG).


Introduction
The traditional electro-mechanical energy meters have to be read manually by visiting the individual meters, which require separate time and labour to collect data from each consumer. Accompanying the advancement of digital technologies, digital energy meters are taking over the traditional electro-mechanical ones and provide significant advantages over traditional meters. They enable remote, real-time monitoring, for example, and also assist in more accurate reading than in traditional meters [1]. However, there are not any global standards defined yet for smart meter functionality. According to the European Smart Meters Industry Group (ESMIG), the modern digital meters should have remote metering, bidirectional communication, support of advanced tariff and billing applications, and remote energy supply control [2]. Smartly enabling the concept of the smart grid by implementing real-time monitoring is one of the best examples and applications in the current scenario. The main advantage of a smart grid is that it enables the bidirectional flow of energy between the customer and the grid utility [3]. It also enables the consumers to track and/or control their energy usage more effectively [4]. To enable the concept of the smart grid in rural microgrids there is a need for a robust communication system

LoRa Technology
LoRa is a wireless communication technology that uses frequency-shift-basedmodulation called LoRa modulation to transmit signals. It is designed to provide longrange communication with low power and a slow data rate. It uses the free ISM band (the Industrial, Scientific, and Medical radio band) to communicate, and uses the sub-gigahertz radio frequency bands like 433 MHz, 868 MHz, and 915 MHz. The communication range of LoRa can reach up to 10 km in line of sight, depending upon the Spreading Factor (SF) used. Due to its unique modulation technique, it allows users to negotiate between data rate and range by varying the SF. The relation between data rate and SF is given by Equation (1) [18].
where, BW is the bandwidth, R b is the data rate, and SF is the Spreading Factor. When the range increases, then the data rate has to be decreased and vice versa. The LoRa devices also can be changed to gaussian frequency shift keying (GFSK) mode to get a higher data rate. However, GFSK cannot provide the long-range capabilities of LoRa modulation. Accompanying the change in SF, the time on-air (TOA) also changes. Considering different SFs with LoRa modulation and GFSK modulation, the TOA can be calculated using Equations (4) and (5) Where NP number of permeable symbols, SW is length of synchronization word, CR is coding rate, DE is data rate optimization, CRC is cyclic redundancy check, IH is operation mode and PL is length of the physical layer payload [19]. The  Table 1. TOA = T preamble + T Packet (2) TOA = T symb L preamble + L PHDR + L PHDR CRC + L PHY payload + L PHY CRC (3) TOA = 2 SF BW (NP + 4.25) + SW + max ceil 8PL − 4SF + 28 + 16CRC − 20IH 4(SF − 2DE) (CR + 4), 0 (4) Regarding GFSK: Concerning the LoRa modulation technique, changing the SF changes the data rate capacity as well as the range of the network. The data rate and the range of the network are inversely proportional to each other, which can be seen in Figure 1. The maximum size of a packet that can be successfully transmitted by a node to another node depends upon the distance between the two nodes. The distance that a user is going to put between two nodes depends upon the range supported by them. Therefore, for different SFs, the maximum supported packet sizes are also different; the maximum packet size supported by different SFs can be seen in Figure 2 [20].
LoRa devices for different modulation techniques, SFs, and bandwidth are tabul Concerning the LoRa modulation technique, changing the SF changes the da capacity as well as the range of the network. The data rate and the range of the n are inversely proportional to each other, which can be seen in Figure 1. The maximu of a packet that can be successfully transmitted by a node to another node depend the distance between the two nodes. The distance that a user is going to put betwe nodes depends upon the range supported by them. Therefore, for different SFs, th imum supported packet sizes are also different; the maximum packet size suppor different SFs can be seen in Figure 2 [20].   The smart meters require a long-range and low communication rate, making perfect choice for this application. There are some communication modules, like L SX1272, which uses LoRa modulation and provides optional frequency bands, rates, and transmission rates [19,22]. Nowadays, LoRa technology is widely used ternet of Things (IoT) purposes [23]. The IoT devices represent a network of in nected devices. It is estimated that, by the next decade, the number of these devi reach about 125 billion. Currently, IoT devices use LoRa technology widely, espec sectors like electricity and agriculture, and in automation purposes, due to the range communication capabilities [1,24]. Due to its numerous features like low usage, long-range, and adaptive data rate capability, LoRa has a wide range of a tions. Figure 3 shows the different areas of application of LoRa with specific appl [25,26].  The smart meters require a long-range and low communication rate, making LoRa a perfect choice for this application. There are some communication modules, like Libelium SX1272, which uses LoRa modulation and provides optional frequency bands, coding rates, and transmission rates [19,22]. Nowadays, LoRa technology is widely used for Internet of Things (IoT) purposes [23]. The IoT devices represent a network of interconnected devices. It is estimated that, by the next decade, the number of these devices will reach about 125 billion. Currently, IoT devices use LoRa technology widely, especially in sectors like electricity and agriculture, and in automation purposes, due to their long-range communication capabilities [1,24]. Due to its numerous features like low power-usage, long-range, and adaptive data rate capability, LoRa has a wide range of applications. Figure 3 shows the different areas of application of LoRa with specific applications [25,26]. The smart meters require a long-range and low communication rate, making LoR perfect choice for this application. There are some communication modules, like Libeliu SX1272, which uses LoRa modulation and provides optional frequency bands, cod rates, and transmission rates [19,22]. Nowadays, LoRa technology is widely used for ternet of Things (IoT) purposes [23]. The IoT devices represent a network of interco nected devices. It is estimated that, by the next decade, the number of these devices w reach about 125 billion. Currently, IoT devices use LoRa technology widely, especially sectors like electricity and agriculture, and in automation purposes, due to their lon range communication capabilities [1,24]. Due to its numerous features like low pow usage, long-range, and adaptive data rate capability, LoRa has a wide range of appli tions. Figure 3 shows the different areas of application of LoRa with specific applicatio [25,26]. Regarding these applications, a LoRa end device directly communicates with gateway to transfer the data to the cloud. Each end device should be placed within range of the gateway for a successful transfer of data. Taking a higher layer perspecti the current application of LoRa uses stars-of-stars topology that permits the end nodes connect to the gateways through direct links, as shown in Figure 4 [27,28]. The most co Regarding these applications, a LoRa end device directly communicates with the gateway to transfer the data to the cloud. Each end device should be placed within the range of the gateway for a successful transfer of data. Taking a higher layer perspective, the current application of LoRa uses stars-of-stars topology that permits the end nodes to connect to the gateways through direct links, as shown in Figure 4 [27,28]. The most common architecture of the LoRaWAN used nowadays can be seen in Figure 4.  A LoRa network is typically setup in a stars-of-stars topology where gateways pick up the message broadcasted by the end-devices or nodes and forward them over an internet protocol-based network to a network server. A network server is a software application running over one or more servers. The network servers have the knowledge of nodes and their owners. The messages are encrypted and can only be decrypted by the destination node or the network server [7]. LoRaWAN devices are mainly used in three operation modes depending upon the energy consumption and download speed. The Class A devices offer greater energy saving, since they stay in sleep mode most of the time and are just able to receive transmissions after each uplink connection by opening a listening window. Class B devices have default reception windows within the gateway, and the Class C devices are continuously listening to the channel so they can receive a downlink connection at any time [25,27,28].
LoRaWAN is one of the examples of a Low Power Wide Area Network (LPWAN) technology that appears to be very suitable for smart metering thus, the LoRaWAN can be used to create a mesh network for smart metering. It is a novel modulation technique that enables it to communicate over long distances and it has over 50 communication channels. The LoRa architecture consists of LoRa devices, gateways, and an application server, as shown in Figure 5 [29]. The function of a LoRa device is to read the sensor data and transmit it to the gateway for further operation. The LoRa device also is able to read the commands from the gateway and respond accordingly. A gateway is connected to multiple devices, whose function is to establish the communication between the LoRa devices and the application server. The application server manages the collected data from all the devices [13,29]. Figure 6 shows the star topology of the LoRaWAN, in which each node is connected to the network with the help of gateways. A gateway is placed at an appropriate location where all of the required nodes can connect to it. All the nodes send their data to the gateway, and the gateway uploads the data to the cloud [7]. The star topology is useful when it is feasible to place multiple gateways at required locations. Concerning the case of rural areas where the internet is not available, the proposed sys- A LoRa network is typically setup in a stars-of-stars topology where gateways pick up the message broadcasted by the end-devices or nodes and forward them over an internet protocol-based network to a network server. A network server is a software application running over one or more servers. The network servers have the knowledge of nodes and their owners. The messages are encrypted and can only be decrypted by the destination node or the network server [7]. LoRaWAN devices are mainly used in three operation modes depending upon the energy consumption and download speed. The Class A devices offer greater energy saving, since they stay in sleep mode most of the time and are just able to receive transmissions after each uplink connection by opening a listening window. Class B devices have default reception windows within the gateway, and the Class C devices are continuously listening to the channel so they can receive a downlink connection at any time [25,27,28].
LoRaWAN is one of the examples of a Low Power Wide Area Network (LPWAN) technology that appears to be very suitable for smart metering thus, the LoRaWAN can be used to create a mesh network for smart metering. It is a novel modulation technique that enables it to communicate over long distances and it has over 50 communication channels. The LoRa architecture consists of LoRa devices, gateways, and an application server, as shown in Figure 5 [29]. The function of a LoRa device is to read the sensor data and transmit it to the gateway for further operation. The LoRa device also is able to read the commands from the gateway and respond accordingly. A gateway is connected to multiple devices, whose function is to establish the communication between the LoRa devices and the application server. The application server manages the collected data from all the devices [13,29]. Figure 6 shows the star topology of the LoRaWAN, in which each node is connected to the network with the help of gateways. A gateway is placed at an appropriate location where all of the required nodes can connect to it. All the nodes send their data to the gateway, and the gateway uploads the data to the cloud [7]. The star topology is useful when it is feasible to place multiple gateways at required locations. Concerning the case of rural areas where the internet is not available, the proposed systems may fail to operate successfully. Hence, to solve this problem, the LoRa-based mesh network is suitable for the case of remote areas. Regarding a mesh network, each node can act as a repeater to relay information to the neighboring node, so in the case of the meters where gateway signals cannot reach, the meters in between them act as a bridge to fill the communication gap [5,24].
Electronics 2021, 10, x FOR PEER REVIEW 7 of 16 network is suitable for the case of remote areas. Regarding a mesh network, each node can act as a repeater to relay information to the neighboring node, so in the case of the meters where gateway signals cannot reach, the meters in between them act as a bridge to fill the communication gap [5,24].

Method
LoRaWAN has been purposed in many previous research works to be implemented for smart metering in which a stars-of-stars topology was used [24,30,31]. Stars-of-stars topology can be implemented in urban areas where gateways can be placed in convenient places. However, in rural areas where gateways cannot be placed at required locations due to the unavailability of a reliable communication infrastructure using mesh topology in such situations allows for flexible placement locations for gateways, and also allows for a larger coverage area. Mesh architecture helps to increase the range of the LoRa network. LoRa based infrastructure can be deployed and operated at a lower cost than previously discussed technologies, which addresses the limitation of previously discussed communication methods regarding smart metering. Using mesh configuration, rather than installing additional nodes for hard-to-reach places, allows intermediate nodes to be used to relay information to the gateway. A LoRa mesh-based smart metering system will form an interconnected mesh of smart meters. When there is a connection between a smart meter and a gateway, it directly sends the data to the gateway, otherwise it uses intermediate nodes to connect to the gateway.
First, during the simulation, smart meters were installed in the respective locations and, if any smart meter was not able to connect itself to the network after the installation, a relay node was installed by manually selecting a suitable location. Regarding hard-to- network is suitable for the case of remote areas. Regarding a mesh network, each node can act as a repeater to relay information to the neighboring node, so in the case of the meters where gateway signals cannot reach, the meters in between them act as a bridge to fill the communication gap [5,24].

Method
LoRaWAN has been purposed in many previous research works to be implemented for smart metering in which a stars-of-stars topology was used [24,30,31]. Stars-of-stars topology can be implemented in urban areas where gateways can be placed in convenient places. However, in rural areas where gateways cannot be placed at required locations due to the unavailability of a reliable communication infrastructure using mesh topology in such situations allows for flexible placement locations for gateways, and also allows for a larger coverage area. Mesh architecture helps to increase the range of the LoRa network. LoRa based infrastructure can be deployed and operated at a lower cost than previously discussed technologies, which addresses the limitation of previously discussed communication methods regarding smart metering. Using mesh configuration, rather than installing additional nodes for hard-to-reach places, allows intermediate nodes to be used to relay information to the gateway. A LoRa mesh-based smart metering system will form an interconnected mesh of smart meters. When there is a connection between a smart meter and a gateway, it directly sends the data to the gateway, otherwise it uses intermediate nodes to connect to the gateway.
First, during the simulation, smart meters were installed in the respective locations and, if any smart meter was not able to connect itself to the network after the installation, a relay node was installed by manually selecting a suitable location. Regarding hard-to-

Method
LoRaWAN has been purposed in many previous research works to be implemented for smart metering in which a stars-of-stars topology was used [24,30,31]. Stars-of-stars topology can be implemented in urban areas where gateways can be placed in convenient places. However, in rural areas where gateways cannot be placed at required locations due to the unavailability of a reliable communication infrastructure using mesh topology in such situations allows for flexible placement locations for gateways, and also allows for a larger coverage area. Mesh architecture helps to increase the range of the LoRa network. LoRa based infrastructure can be deployed and operated at a lower cost than previously discussed technologies, which addresses the limitation of previously discussed communication methods regarding smart metering. Using mesh configuration, rather than installing additional nodes for hard-to-reach places, allows intermediate nodes to be used to relay information to the gateway. A LoRa mesh-based smart metering system will form an interconnected mesh of smart meters. When there is a connection between a smart meter and a gateway, it directly sends the data to the gateway, otherwise it uses intermediate nodes to connect to the gateway. First, during the simulation, smart meters were installed in the respective locations and, if any smart meter was not able to connect itself to the network after the installation, a relay node was installed by manually selecting a suitable location. Regarding hard-to-reach meters, the intermediate nodes were placed to connect the gateways. Figure 7 shows the purposed architecture for smart metering, Figure 8 shows how the networks can be formed depending upon the node density to reduce interference between the neighboring networks, and Figure 9 shows the simulated sample network of 20 nodes. To verify the required specifications of the LoRa mesh network for smart metering purposes, the simulationbased analysis of LoRa mesh topology was performed in the network simulation 2 (NS2) simulator. A simulation to determine the response of the network regarding the packet delivery ratio (PDR) and the end-end delay with an increase in the number of nodes was performed, and how the PDR was affected by the packet size was determined. The area of the simulation environment was considered to be 20 × 20 km 2 . The LoRa has a data transfer speed from 146.1 bps to 45,660 bps, depending upon the spreading factor (SF) and modulation technique [18]. According to a study, it was found that an average smart meter generates and receives traffic of 3185 and 272 bytes per day [32], respectively. Simulations were done to determine whether the network could satisfy these conditions. Figures 10-13 show the flowcharts of the programs that were implemented in the nodes and gateways.  Figure 7 shows the purposed architecture for smart metering, Figure 8 shows how the networks can be formed depending upon the node density to reduce interference between the neighboring networks, and Figure 9 shows the simulated sample network of 20 nodes. To verify the required specifications of the LoRa mesh network for smart metering purposes, the simulation-based analysis of LoRa mesh topology was performed in the network simulation 2 (NS2) simulator. A simulation to determine the response of the network regarding the packet delivery ratio (PDR) and the end-end delay with an increase in the number of nodes was performed, and how the PDR was affected by the packet size was determined.
The area of the simulation environment was considered to be 20 × 20 km 2 . The LoRa has a data transfer speed from 146.1 bps to 45,660 bps, depending upon the spreading factor (SF) and modulation technique [18]. According to a study, it was found that an average smart meter generates and receives traffic of 3185 and 272 bytes per day [32], respectively. Simulations were done to determine whether the network could satisfy these conditions. Figures 10-13 show the flowcharts of the programs that were implemented in the nodes and gateways. Depending upon the location of the application, the node density and number of nodes in the network are going to be different. When the application area is rural, the density of houses is going to be low, so the distance between nodes will be large and a higher SF needs to be used. Similarly, for an urban area, a lower SF needs to be used. When a network size becomes too large, the network will not be able to meet the number of data packets to be extracted per day. Considering such a case, the network either has to decrease the SF to increase the network speed or split the network in two. When a network needs to be split in two, the two neighboring networks will have to use different channels and SFs, depending upon the size and density of the network, to avoid interference, as shown in Figure 8. Regarding Figure 8, three networks with a different number of nodes are shown where A1, A2, and A3 are the areas of the nodes and D1, D2 and D3 are the average distance between the nodes in respective networks. (A1 < A2 < A3 and D1 < D1 < D3). It shows that the network in which nodes were closely packed could support a large number of nodes because they used a low SF, which allowed them to use a higher speed. Concerning a network in which nodes were far apart, they had to use a higher SF, which could support fewer nodes. The simulation was done for an area of 20 × 20 km 2 for different SFs in different node density conditions. The geographic nature of the application area was considered flat while performing the simulation. Environmental conditions like clouds, mist, and humidity were not taken into account due to their everchanging nature. The range and data rate  The simulation was done for an area of 20 × 20 km 2 for different SFs in different node density conditions. The geographic nature of the application area was considered flat while performing the simulation. Environmental conditions like clouds, mist, and humidity were not taken into account due to their everchanging nature. The range and data rate of each node in the simulation were defined according to the data in Figure 1. Figure 9 shows the instance of simulation of 20 nodes in a mesh configuration in the NS2 network simulator. The mesh network considered for the simulation contained a central gateway and nodes. The function of the central gateway was to generate invitation beacons to register new nodes to the network. The gateway used an algorithm to generate the beacon signals periodically, as shown in Figure 10. Once it generated an invitation beacon, it waited and listened to join the requests from the nodes. When it received join requests, it added the node to the network and sent the confirmation signal to the corresponding node. It also sent query requests to nodes for data packets. Then, the gateway was used to connect the network to the internet. Shown in Figure  10, the function of the gateway was to periodically broadcast invitation beacons that registered the new nodes to the network and execute the data query function to extract data from the respective nodes as required. Similarly, the query function sent query requests to the target nodes turn-by-turn to extract data from the respective nodes, as shown in Figure 11. When the target node did not respond to the query request within a time limit, then the target node was considered offline and the algorithm moved on to the other nodes for data extraction. Then, the gateway was used to connect the network to the internet. Shown in Figure  10, the function of the gateway was to periodically broadcast invitation beacons that registered the new nodes to the network and execute the data query function to extract data from the respective nodes as required. Similarly, the query function sent query requests to the target nodes turn-by-turn to extract data from the respective nodes, as shown in Figure 11. When the target node did not respond to the query request within a time limit, then the target node was considered offline and the algorithm moved on to the other nodes for data extraction.  Conversely, the nodes were always listening to the beacons, data packets, and/or join requests, as shown in Figure 12. When a node received a beacon: (a) if it was already connected to the network, it executed the packet processing function; (b) if not, it connected itself to the network by sending join requests to the gateway. The nodes were programmed in such a way that, while retransmitting a beacon, they updated and included the path through which the beacon arrived at that particular node. Therefore, when sending the join request, it used the path included in the beacon to define the path of the join request signal. Then it waited for the confirmation from the gateway, got the confirmation that it was registered to the network and retransmitted the invitation beacon signal. While retransmitting the beacon, it also included the path from which the beacon was received so the receiving nodes knew the path through which to respond to the gateway. When the node was already registered to the network, it executed the packet process function. Shown in Figure 13, the task of the packet process function was to determine what type of data packet was the received signal. When it was a beacon, it waited for the random delay, included the updated path of the arrival of the beacon, waited for a random time, and retransmitted the signal along with the updated path. When it was a join request from a node then it read the path to the gateway from the received signal and relayed the signal according to the path. Similarly, if it was a data request signal from the gateway then it determined the target node; if it was the target node then it sent the requested data packet to the gateway. When it was not the target node, then it retransmitted the signal accordingly.

Results and Discussion
Here, a mesh network of LoRa devices was simulated using an NS2 network simulator, and the LoRa frequency used was 912 MHz at a 125 kHz bandwidth. The capacity of the network was analyzed for different Spreading Factors (SFs). The analysis was done to determine whether the network could be used for smart metering with standard smart metering requirements. A network was simulated for different speeds from 146 bps to 5469 bps for an area of 20 × 20 km 2 and a buffer size of 512 bytes for each node, where data extraction was done periodically. The range and speed of each node were defined according to Table 1, and the nodes were positioned randomly in the simulated area. Figure 14 presents the end-to-end delay of the transmitted signal for different SFs with a different number of nodes. It shows how the average end-to-end delay of signal transmission increased with an increase in several nodes in a network, and how the endto-end delay also varied with the different SFs. Each data in Figure 14 is an average of 25 transmissions while collecting data at a 20-s interval. Figure 15 shows how the package delivery ratio (PDR) changed and Figure 14 shows how the end-to-end delay changed Depending upon the location of the application, the node density and number of nodes in the network are going to be different. When the application area is rural, the density of houses is going to be low, so the distance between nodes will be large and a higher SF needs to be used. Similarly, for an urban area, a lower SF needs to be used. When a network size becomes too large, the network will not be able to meet the number of data packets to be extracted per day. Considering such a case, the network either has to decrease the SF to increase the network speed or split the network in two. When a network needs to be split in two, the two neighboring networks will have to use different channels and SFs, depending upon the size and density of the network, to avoid interference, as shown in Figure 8. Regarding Figure 8, three networks with a different number of nodes are shown where A1, A2, and A3 are the areas of the nodes and D1, D2 and D3 are the average distance between the nodes in respective networks. (A1 < A2 < A3 and D1 < D1 < D3). It shows that the network in which nodes were closely packed could support a large number of nodes because they used a low SF, which allowed them to use a higher speed. Concerning a network in which nodes were far apart, they had to use a higher SF, which could support fewer nodes.
The simulation was done for an area of 20 × 20 km 2 for different SFs in different node density conditions. The geographic nature of the application area was considered flat while performing the simulation. Environmental conditions like clouds, mist, and humidity were not taken into account due to their everchanging nature. The range and data rate of each node in the simulation were defined according to the data in Figure 1. Figure 9 shows the instance of simulation of 20 nodes in a mesh configuration in the NS2 network simulator.
The mesh network considered for the simulation contained a central gateway and nodes. The function of the central gateway was to generate invitation beacons to register new nodes to the network. The gateway used an algorithm to generate the beacon signals periodically, as shown in Figure 10. Once it generated an invitation beacon, it waited and listened to join the requests from the nodes. When it received join requests, it added the node to the network and sent the confirmation signal to the corresponding node. It also sent query requests to nodes for data packets.
Then, the gateway was used to connect the network to the internet. Shown in Figure 10, the function of the gateway was to periodically broadcast invitation beacons that registered the new nodes to the network and execute the data query function to extract data from the respective nodes as required. Similarly, the query function sent query requests to the target nodes turn-by-turn to extract data from the respective nodes, as shown in Figure 11. When the target node did not respond to the query request within a time limit, then the target node was considered offline and the algorithm moved on to the other nodes for data extraction.
Conversely, the nodes were always listening to the beacons, data packets, and/or join requests, as shown in Figure 12. When a node received a beacon: (a) if it was already connected to the network, it executed the packet processing function; (b) if not, it connected itself to the network by sending join requests to the gateway. The nodes were programmed in such a way that, while retransmitting a beacon, they updated and included the path through which the beacon arrived at that particular node. Therefore, when sending the join request, it used the path included in the beacon to define the path of the join request signal. Then it waited for the confirmation from the gateway, got the confirmation that it was registered to the network and retransmitted the invitation beacon signal. While retransmitting the beacon, it also included the path from which the beacon was received so the receiving nodes knew the path through which to respond to the gateway. When the node was already registered to the network, it executed the packet process function. Shown in Figure 13, the task of the packet process function was to determine what type of data packet was the received signal. When it was a beacon, it waited for the random delay, included the updated path of the arrival of the beacon, waited for a random time, and retransmitted the signal along with the updated path. When it was a join request from a node then it read the path to the gateway from the received signal and relayed the signal according to the path. Similarly, if it was a data request signal from the gateway then it determined the target node; if it was the target node then it sent the requested data packet to the gateway. When it was not the target node, then it retransmitted the signal accordingly.

Results and Discussion
Here, a mesh network of LoRa devices was simulated using an NS2 network simulator, and the LoRa frequency used was 912 MHz at a 125 kHz bandwidth. The capacity of the network was analyzed for different Spreading Factors (SFs). The analysis was done to determine whether the network could be used for smart metering with standard smart metering requirements. A network was simulated for different speeds from 146 bps to 5469 bps for an area of 20 × 20 km 2 and a buffer size of 512 bytes for each node, where data extraction was done periodically. The range and speed of each node were defined according to Table 1, and the nodes were positioned randomly in the simulated area. Figure 14 presents the end-to-end delay of the transmitted signal for different SFs with a different number of nodes. It shows how the average end-to-end delay of signal transmission increased with an increase in several nodes in a network, and how the endto-end delay also varied with the different SFs. Each data in Figure 14 is an average of 25 transmissions while collecting data at a 20-s interval. Figure 15 shows how the package delivery ratio (PDR) changed and Figure 14 shows how the end-to-end delay changed with the change in SF and the number of nodes. Considering Figure 15, it can be seen that, although at a lower SF and a low number of nodes, the PDR was high but, with the increase in SF and the number of nodes, the PDR decreased rapidly. Due to the decrease in the PDR with respect to the increase in SF and nodes in the network, the gateway had to send multiple data requests to the respective node to get a single packet extracted successfully. Even with the decrease in the PDR, regarding Figure 16 it can be seen that the minimum successful data extraction period for a SF of 12 and a network of 250 nodes was 750 s, which is more than enough for smart metering purposes [21,24]. Figure 16 shows how the minimum possible data extraction period varied for a node if the master node extracted the data from each node turn-by-turn. It can be seen in Figure 16 that, with the increase in the number of nodes and SF, the minimum successful data extraction period increased accordingly. Regarding a network consisting of 250 nodes and operating at a SF of seven, the minimum successful data extraction period will be 230 s.
Electronics 2021, 10, x FOR PEER REVIEW Similarly, for a SF of 11, the data extraction period will be 435 s. When a ne not meeting the minimum data extraction period requirement, then we either nee crease the SF or split the network into two separate networks. When there is a co where the network needs to be split into two, then it needs to be done in such a w the signals do not interfere with each other. Regarding signal interference reduct tween neighboring networks, they can be assigned different SFs, or they can be in terms of geographical terrain for minimum signal interference. Considering th lation, a minimum time interval at which nodes can communicate with the gat calculated and presented in Figure 16.   Similarly, for a SF of 11, the data extraction period will be 435 s. When a net not meeting the minimum data extraction period requirement, then we either nee crease the SF or split the network into two separate networks. When there is a co where the network needs to be split into two, then it needs to be done in such a w the signals do not interfere with each other. Regarding signal interference reduct tween neighboring networks, they can be assigned different SFs, or they can be in terms of geographical terrain for minimum signal interference. Considering th lation, a minimum time interval at which nodes can communicate with the gat calculated and presented in Figure 16.     An average meter generates traffic of 3185 bytes per day and receives 227 by day [21]. According to the studies [21,24], an average meter can generate 3.185 Kb data per day. It will take a different number of transmissions to satisfy 3.185 Kb Similarly, for a SF of 11, the data extraction period will be 435 s. When a network is not meeting the minimum data extraction period requirement, then we either need to decrease the SF or split the network into two separate networks. When there is a condition where the network needs to be split into two, then it needs to be done in such a way that the signals do not interfere with each other. Regarding signal interference reductions between neighboring networks, they can be assigned different SFs, or they can be divided in terms of geographical terrain for minimum signal interference. Considering the simulation, a minimum time interval at which nodes can communicate with the gateway is calculated and presented in Figure 16.
An average meter generates traffic of 3185 bytes per day and receives 227 bytes per day [21]. According to the studies [21,24], an average meter can generate 3.185 Kbytes of data per day. It will take a different number of transmissions to satisfy 3.185 Kbytes of data per day per node based upon the SF of the node due to different packet size capacities at different SFs, as shown in Figure 17. Taking these factors into consideration, a minimum number of transmissions required per day for networks consisting of different SFs is obtained and shown in Figure 18. It can be observed that the maximum number of packet transmissions required at the lowest data rate was 62 bps. This condition is met even by a network consisting of the lowest data rate. Regarding the simulated network size, the network easily meets the required conditions for smart metering. The above data suggests that the mesh network of LoRa devices can be used for smart metering purposes.
Electronics 2021, 10, x FOR PEER REVIEW data per day per node based upon the SF of the node due to different packet size ca at different SFs, as shown in Figure 17. Taking these factors into consideration, a mi number of transmissions required per day for networks consisting of different SF tained and shown in Figure 18. It can be observed that the maximum number of transmissions required at the lowest data rate was 62 bps. This condition is met ev network consisting of the lowest data rate. Regarding the simulated network size, work easily meets the required conditions for smart metering. The above data s that the mesh network of LoRa devices can be used for smart metering purposes.

Conclusions
This paper discussed how LoRa devices can be used for smart metering. Th proposed a mesh configuration of LoRa devices be implemented in a smart meter tem. The study evaluated the algorithm to be used by gateways and nodes to ro manage data packets based on a simulation. The simulation results verified how tem will perform when implemented for smart metering purposes under various tions like different Spreading Factors (SFs) and nodes. Based on the results, we fou the LoRaWAN in a mesh configuration achieves the required specifications to be mented for smart metering in rural microgrids (MGs).
The simulation does not consider conditions like non-uniform geographical and external noise, however, so the system may behave a little differently in real mentation. During this analysis, the maximum number of devices simulated in were 250, for which the purposed system meets the required specifications from t ulation. Once the system reaches a critical number of smart meters in a network, tem will not be able to maintain the required specifications due to the limited ban of LoRa devices. Further studies need to be conducted to address these issues. Ho

Conclusions
This paper discussed how LoRa devices can be used for smart metering. The study proposed a mesh configuration of LoRa devices be implemented in a smart metering system. The study evaluated the algorithm to be used by gateways and nodes to rout and manage data packets based on a simulation. The simulation results verified how the system will perform when implemented for smart metering purposes under various conditions like different Spreading Factors (SFs) and nodes. Based on the results, we found that the LoRaWAN in a mesh configuration achieves the required specifications to be implemented for smart metering in rural microgrids (MGs).
The simulation does not consider conditions like non-uniform geographical terrain and external noise, however, so the system may behave a little differently in real implementation. During this analysis, the maximum number of devices simulated in a mesh were 250, for which the purposed system meets the required specifications from the simulation. Once the system reaches a critical number of smart meters in a network, the system will not be able to maintain the required specifications due to the limited bandwidth of LoRa devices. Further studies need to be conducted to address these issues. However, the proposed method can be implemented even in areas where no commercial communications systems are available. It requires less deployment cost as it minimizes the number of gateways by using mesh topology. Furthermore, the operational cost of the proposed concept is significantly less compared to the traditional approaches as the traditional approaches involve external communication service providers.  Data Availability Statement: Data related to this research is available on [33].