LoRa Enabled Smart Inverters for Microgrid Scenarios with Widespread Elements

: The introduction of low-power wide-area networks (LPWANs) has changed the image of smart systems, due to their wide coverage and low-power characteristics. This category of communication technologies is the perfect candidate to be integrated into smart inverter control architectures for remote microgrid (MG) applications. LoRaWAN is one of the leading LPWAN technologies, with some appealing features such as ease of implementation and the possibility of creating private networks. This study is devoted to analyze and evaluate the aforementioned integration. Initially, the characteristics of different LPWAN technologies are introduced, followed by an in-depth analysis of LoRa and LoRaWAN. Next, the role of communication in MGs with widespread elements is explained. A point-by-point LoRa architecture is proposed to be implemented in the grid-feeding control structure of smart inverters. This architecture is experimentally evaluated in terms of latency analysis and externally generated power setpoint, following smart inverters in different LoRa settings. The results demonstrate the effectiveness of the proposed LoRa architecture, while the settings are optimally conﬁgured. Finally, a hybrid communication system is proposed that can be effectively implemented for remote residential MG management.


Introduction
The concept of localizing energy production, in order to minimize the additional and unnecessary transmission and distribution costs and complexities, has gained a lot of attention recently. Distributed generation, based on renewable energies, is the cornerstone of microgrid (MG) technology. In general, a microgrid is a small-scale grid consisting of distributed generators and loads, which are electrically connected and hierarchically controlled. An MG must be able to operate in isolation and, in some cases, in interaction with other grids [1]. The idea of decentralization in MG ideology is not limited to the power lines, but also includes the information exchange networks. Arguably, one of the top priorities of MG research is to limit communication as much as possible.
This work proposes a long-range and low-power communication system for smart inverters to be used for MG control and management applications [2]. It should be noted that the type of communication system selected for any application depends on the unique requirements and restrictions of the specific scenario. For instance, the proximity of the communication nodes is one of the factors. The latency tolerance of the application is another consideration. Communication technologies based on the internet of things (IoT) can be effectively used for the application of this study according to their low power and ease of implementation characteristics [3]. There are various types of this machine-tomachine (M2M) communication technology that offer different characteristics [4]. However, as a rough classification, they can be either short-range or long-range [2]. Short-range physical layer protocols, such as IEEE 802.11 (WiFi) or IEEE 802. 15

.4 (ZigBee-Physical
To cut a long story short, in this study the authors investigated the feasibility and benefits of utilizing LPWAN communication systems in MG management. The problem has been analyzed from both control systems engineering and communication science viewpoints, therefore, various aspects from different technology branches were investigated and considered. In the author's humble opinion, based on the aforementioned points, this paper can empower the existing literature and assist other researchers in the field. The remainder of the paper is organized as follows. Section 2 gives a brief overview of some selected LPWAN technologies. A more detailed summary of LoRa and LoRaWAN characteristics and specifications is provided in Section 3. The fundamentals of communication dependency of MG systems are explained in Section 4. The arguments of this section aim to rationalize and justify the implementation of LoRaWAN in an MG control structure. Section 5 presents the implementation of LoRaWAN for smart inverters and the description is accompanied by experimental results. A LoRaWAN/MQTT hybrid communication structure for a specific case study of residential MGs in remote areas is proposed and explained in Section 6. Final remarks and conclusions are presented in Section 7.

LPWAN Overview
LPWAN is largely linked with IoT [9]. By paying attention to the definition of IoT, it can be understood that most of the modern smart systems, if not all, fit into this category. Smartcities, smart-agriculture, smart-grids, MGs, and many more are examples of smart systems that can be considered as IoT structures [10]. Among different classes of communication systems, LPWANs are more suited to deal with the widespread and low-power nature of devices that are used in an IoT structure because of their unique characteristics. Generally, these are some key features shared among different LPWANs: • Long-range, on a scale of several kilometers or more depending on the operating environment. • Suitable for none-latency-sensitive applications, since throughput is normally sacrificed to gain larger coverage in LPWAN methodologies [11,12]. • Large scale deployment that is the essence of IoT ideology. • Operation inside unlicensed frequency bands so there are no additional costs to pay for a licensed band registration. • Mostly used for asymmetrical communication scenarios (such as monitoring), which means the nodes can hibernate (not listening) for long intervals and just become alive and transmit when required. This contributes to the conservation of battery energy.
LPWANs provide a similar range with wide area networks (WAN), based on cellular technologies, while consuming lower energy and providing less throughput. Other classes of wireless networks such as local area networks (LAN), personal area networks (PAN), and low-power local-area networks (LPLAN) are utilized for different applications. LANs normally run on different versions of WiFi which are high-power and high-throughput technologies, their applications are mostly in accordance with human-user-interfaces which require high data-rate features. LPLAN protocols are mainly used for short to mediumrange M2M communication scenarios where the throughput can be sacrificed to achieve higher battery lives. PAN is based on very short range protocols that were specifically designed with strict power and security considerations in mind, Figure 1.  The leading LPWAN technologies are Sigfox, LoRaWAN, Dash7, and Ingenu, which are more recognized among others [13]. All of these LPWAN technologies are basically short-range protocols that achieve cellular-like coverage by manipulating physical layer characteristics. For example, in LoRa, changing the SF leads to sacrifice range for throughput and the other way around [14].

SigFox
SigFox is the pioneering technology in the LPWAN category, as it was introduced in 2009 [13]. SigFox provides a full and end-to-end communication structure. This technology is proprietary and the specifications of the network and transport layer protocols are kept secret from the public. Generally speaking, SigFox just allows you to create some end nodes for sensing and monitoring, and after that, there is no real control since it is required to use SigFox base stations and, finally, the SigFox cloud-based platform [15]. In other words, it is not possible to create private networks, which is a downside for this application.
The SigFox long-range capability is achieved by using an ultra narrowband (UNB) radio transmission technology in the industrial, scientific, and medical (ISM) sub-GHz territory. The bandwidth for the uplink (from end-nodes to base station) is 100 Hz in Europe and 600 Hz in the US, while the downlink bandwidth is 1.5 kHz worldwide. The uplink uses differential binary phase-shift keying (DBPSK), and the downlink modulation is Gaussian frequency-shift keying (GFSK). Regarding the narrow-band used for this technology, naturally, the data rates are very or ultra-low, 100 bit/sec for uplink and 600 bit/sec for the downlink. One limiting issue with SigFox is the fact that downlink transmission is only possible after an uplink has taken place and the end device is mostly hibernated. Furthermore, the number of uplink and downlink messages are limited per day by the operator [16][17][18].

LoRaWAN
LoRaWAN is another example of a LPWAN for which specifications were provided by Lora Alliance in 2015 [14]. The physical layer modulation technology of LoRaWAN is called LoRa, which is proprietary and introduced by Semtech. LoRa-PHY transmits over sub-GHz ISM bands and modulates the messages using the chirp spread spectrum (CSS). Different sets of throughput/coverage levels can be achieved by using various SF for the CSS modulation [7,19]. The other important characteristic of LoRaWAN is the possibility of creating private networks that are not offered by SigFox. Since the backbone of this study is LoRa, the characteristics and features are discussed in detail in a separate section.

Dash7
First of all, it is important to mention that Dash7 does not offer long-range capabilities like other LPWANs. It is a middle-range communication system, on a scale of 1 or 2 km, to fit the gap between short and long-range communication systems. However, the other specifications of Dash7 such as low-power, ISM unlicensed frequency bands, and its application areas are similar to other LPWANs.
Dash7 represents a seven-layer full-open system interconnection (OSI) stack based on ISO/IEC 18000-7. Dash7 Alliance Protocol (D7AP) can use either tree or star topology, which specifies another distinction from other LPWANs that mostly only operate in a star configuration. Furthermore, D7AP offers better latency characteristics of downlink transmissions, since the protocol dictates the end-nodes to be awake and listen for a longer period than other LPWAN technologies [5,16,20]. The physical layer of D7AP supports three levels of sub GHz bands: 433 MHz, 868 MHz, and 915 MHz [21,22].

Ingenu
The proprietary Ingenu communication system operates in the 2.4 GHz band. This is in contradiction with other LPWANs that operate in sub-GHz ISM bands. This fundamental difference affects the coverage, power consumption, and throughput of this technology. Furthermore, Ingenu proposed and patented random phase multiple access (RPMA), which is based on direct-sequence-spread-spectrum (DSSS) modulation.
In comparison to LoRaWAN and SigFox, RPMA has wider coverage (especially in rural areas) and higher throughput, since it uses a much broader 1 MHz bandwidth. However, the end devices consume more energy to operate. RPMA-PHY specifications have been standardized under IEEE 802.15.4k standard [13,16,23,24]. Table 1 summarizes the important technical specifications of the aforementioned LPWAN technologies. Paying attention to the table, entries show some similarities and also major differences among the different technologies. However, the selection of one of them over the others strongly depends on the application. For the application of interest of this study, LoRaWAN is considered as the selected LPWAN technology due to some key features: • Open-source medium access control (MAC) protocol. • Low-cost and easy to implement end-devices. • Non-limited daily messaging. • The possibility of creating private networks.
From this point forward, the communication part of this paper is focused on Lo-RaWAN and LoRa from both theoretical and experimental viewpoints.

LoRaWAN Specifications and Applications
Considering The OSI stack, LoRAWAN and LoRa are referring to the physical, and a part of the data link layers, where LoRaWAN operates on top of LoRa. In other words, LoRa physically transmits the data by using its proprietary modulation, while LoRaWAN is a scheme to make the connection of several end-devices to gateways possible and practical, therefore, the network architecture is called LoRaWAN [7,8,25]. In this system when the messages leave the gateways towards the network server, the communication is no longer based on LoRaWAN, but high-throughput backhauling such as Ethernet [26]. In other words:

•
LoRa is a proprietary, physical layer (PHY) modulation technique and it uses chirp spread spectrum (CSS).

•
LoRaWAN is an open-source protocol for medium access control (MAC).

Review of LoRaWAN and LoRa Applications in Smart Systems
The most notable characteristic of LoRaWAN is the long-range capability of its physical layer proprietary technology, LoRa. Low-power consumption and low implementation and operational expenses are the other advantages that LoRaWAN may offer. On the other hand, LoRaWAN can be considered as an asymmetrical communication system. In other words, the uplink transmission numbers are far greater than the downlink traffic so the end-nodes can be very simple and low power. All the medium access complications are structured on the gateways [27]. Furthermore, the channel bandwidths are mostly only 125 kHz. Comparing with the channel capacities in the range of several MHz for short-range protocols, such as different versions of IEEE 802.11 standard and about tens of MHz for long-term evaluation (LTE) cellular protocol, the narrowband characteristic of LoRa can be observed. This fact contributes directly to lower throughput of LoRa [28].
Considering the specifications of LoRaWAN, one can conclude that this type of communication structure is suitable for wireless sensor networks (WSN), with a scale of a maximum of several kilometers, where cellular networks are either not available or not justifiable to use. In [29], LoRaWAN was used to create a sailing monitoring system that transmits the real-time wind and current measurements from a sailing boat to the control station. In this research, the usage of LoRaWAN was justified because the cellular coverage may weaken when a boat distances from the shore. A health monitoring system, which transmits blood pressure and glucose level of patients to a medical center was proposed in [30]. In this case, the possibility of cellular signal degradation or unavailability was mentioned to justify the utilization of LoRaWAN. Another study [31], proposed a communication structure for the remote screening of urinary infections by using LoRaWAN for areas that cellular signal qualities may not suffice the application requirements. Smart city applications such as smart parking, smart waste management, air quality improvement, and smart traffic-lights control are some scenarios, among many more, which open other potential scopes to employ LoRaWAN communication systems [25,32]. As another example, a vehicle identifier system based on LoRaWAN was proposed in [33]. LoRaWAN can also be used for monitoring and data acquiring in smart agriculture applications [34,35].
Apart from long-range and low-power scenarios, LoRaWAN has also been tested for indoor applications. For example, in [27], a system for monitoring the well-being of personnel in a workplace by using an SX1272 LoRa transceiver was proposed.
Several studies can be found in the existing literature that tackle the problem of LoRa/LoRaWAN implementation in smart grid applications. In [36], a LoRaWAN-based communication infrastructure for monitoring and coordination of smart grid elements, such as distributed generators (DGs) and energy storage systems (ESSs), was proposed. This study implements a class B LoRaWAN system, and its performance was evaluated in terms of latency, coverage, and scalability. Following this interesting study, another publication proposed a similar communication system for implementing interface protection systems (IPSs) in MG or smart grid architectures. IPSs tend to detect any intentional or accidental unscheduled islanding situations of distributed energy resources (DERs). Such unintended islandings, if they are not detected in time and safety measures are properly implemented, can be very hazardous to equipment and also are human-life-threatening [37]. In the same line, a LoRaWAN architecture was proposed for monitoring wind turbine performances [38]. In this study, the communication system was designed and implemented from the sensor level up to the final web-based user interface, so it can be considered useful for other developers and researchers.
As another smart grid application, but from a different viewpoint, a LoRaWAN communication system was evaluated for monitoring residential consumption, billing, and scheduling purposes. In this case, an advanced metering infrastructure (AMI) was proposed based on using LoRaWAN protocol and performance aspects, such as packet deliver ratio (PDR), packet collisions, throughput, and transmission power consumption were evaluated by simulations [39].
It should be noted that the utilization of LoRaWAN or other LPWAN technologies for smart grid applications is justifiable if the applications require long-range communications. Otherwise, higher-throughput and more robust communication protocols can be utilized to improve the PDR and increase the allowable payload size [40].
The scope of the current study also falls into the application of LoRa and LoRaWAN in smart grid systems. However, it is distinguishable from the other works of the existing literature, since the problem has been investigated from both control systems and communication engineering viewpoints. Up to the knowledge of the authors, there are not many alike available studies that provide the details for both the communication system and the control structures. This point can be considered as the novelty of this research study.
As final remarks of this section, it could be stated that LoRaWAN may find applications where neither the well-established and high-throughput short-range technologies, such as WiFi or ZigBee, can be utilized due to coverage considerations, nor the robust and reliable cellular solutions because of network availability and power consumption considerations. This rule of thumb is also valid for other LPWAN systems since: • LPWANs either use ultra-narrow bands (UNB) or spread spectrum (SS) techniques which contain large latencies. • Star topology is utilized to create ultra low power end-nodes. • Packet loss and duplication may frequently occur due to the use of very simple MAC protocols. • Real-time data transfer may not be possible due to the random access nature of LPWANs MAC protocols.

Spread Spectrum Technologies
LoRa-PHY is based on the chirp spread spectrum (CSS) modulation method [41]. CSS provides a possibility to sacrifice throughput to achieve higher sensitivity for the reception, which directly contributes to wider coverage. In other words, LoRa is capable of creating a long-range physical link by reducing the speed.
Spread spectrum technologies were initially developed for classified and interferencesensitive applications. Later on, this quality of jamming and interference immunity made them perfect candidates for many-end-users (congested) networks. In general, the spread spectrum uses a much wider band that is required for the transmission [42,43]. Apart from CSS, there are two other spread spectrum methods. The first is frequency hopping spread spectrum (FHSS), which is immune to detection, and jamming due to the very rapid changing (hopping) of the carrier signal frequency [44]. As the second technique, direct sequence spread spectrum (DSSS), alongside code division multiple access (CDMA), offer similar qualities and concentrate more on allowing multiple transmitters to share a single time slot in the same band [16].

LoRa Modulation
The use of chirps, as carrier signals, is the fundamental aspect of LoRa modulation. In general, a chirp is a type of signal whose frequency varies linearly or non-linearly over a specific period. In CSS modulation techniques, the chirps frequency sweep covers the whole communication channel bandwidth, which can be 125, 250, and 500 kHz for LoRa [45,46]. A typical chirp signal is mathematically represented as, [47]: where a(t) defines the power of CW(t) and is zero when t value is outside of the chirp duration boundary. Θ (t) represents the phase. The first and second derivatives of Θ (t) provide the instantaneous frequency and chirp rate, respectively: If the chirp rate, µ(t), is a constant, which means Θ (t) is a second order polynomial, the chirp waveform is linear. The polarity of µ(t) defines if the signal is an upchirp (µ(t) > 0) or a downchirp (µ(t)< 0). LoRa modulation carrier signals are linear chirps, so based on Equations (1)-(3) it can be formulated as: where P is the average power, f 0 is the center frequency, µ is the chirp rate, and ϕ is a phase constant [47]. A LoRa frame starts with a preamble to indicate a new message is transmitted. This is necessary, since the communication is asynchronous. These preambles are formed by a number of base chirps, which their frequency sweep initiates from the lower cutoff frequency and ends at the upper cutoff frequency. After that, the modulated chirps represent the coded data.
The SF is the other key characteristic in the LoRa communication system [48]. SF represents the number of chips that are spread through a symbol. Therefore, depending on the SF, a LoRa symbol consists of 2 SF chips [49]. There are six different SFs levels for LoRa ranging from 7 to 12. SF can be contextualized as the time of a symbol, and the larger the value the slower the transmission. However, increasing the SF results in wider coverage since it increases the receiver sensitivity. Knowing that, the chip rate equals to the channel bandwidth [50]: SF also indicates the number of bits that are modulated into a symbol, therefore, the data rate is: As an example, for a 250 kHz channel with two different SFs of 7 and 12, which are the upper and lower limits, data rate values are 13.67 (kbps) and 732 (bps), respectively. In Figure 2, the effect of different SFs on the time on-air (ToA) of LoRa frames is visually presented. Two LoRa frames containing an identical payload, but with different SFs, were transmitted using a Pycom/Lopy4 device coded to perform as a LoRa transceiver. The LoRa frequency was set to 868 MHz with 125 kHz bandwidth and the Tx power was 14 dBm. These frames were captured by an ADALM-PLUTO software-defined radio (SDR), which is compatible with Matlab/Simulink programming software. Spectrogram representations, as expected, show that a unit increase of SF value results in a doubling of the ToA. In addition, the preamble and the modulated section of LoRa frames are distinguishable in Figure 2. It can be observed that ten upchirps, followed by two and a quarter of downchirps, form the preamble. (a)SF10. (b)SF12.

LoRaWAN MAC Protocol
LoRa modulation, which represents the physical layer of LoRaWAN infrastructure, is a proprietary technology. Although it is patented, its theoretical and mathematical definitions have not been made available to the public in detail. By contrast, LoRaWAN, which defines the network architecture as a MAC layer protocol, is open-source [51].
A LoRaWAN system consists of three major players. End-nodes which are the lowpower transceivers, gateways, and network servers [7]. Since LoRa end-nodes are connected to gateways in a star configuration, similarly for the gateway-server connections, LoRa topology is sometimes called star-of-stars [13]. In this network arrangement, only the wireless bidirectional node-gateway links are of LoRa/LoRaWAN type and the gateway-server connections are created by utilizing other (higher bandwidth) communication solutions, Figure 3. Furthermore, in some configurations, an end node may be placed in a position that is in the range of more than one gateway. In such cases, it is the networkserver's duty to detect and mitigate the problem to avoid packet duplication.
LoRaWAN MAC protocol is based on pure ALOHA, which means the nodes start transmitting whenever they have a message ready [52].

LPWAN Systems and MG Control
The fundamental idea of MG is to localize energy production based on consumption distribution while aiming to use as many sustainable energy technologies as possible. A standard definition for MG can be found in [53]. MGs may consist of several DGs and ESSs that inter-operate to create a stable electrical grid capable of fulfilling the demand. These small-scale grids may operate as isolated (islanded) or in interaction with other grids. The details and analysis of MG control structures are well covered in the literature, and out of the scope of this paper [1,2,[54][55][56]. In this work, we are interested in the point of convergence of communication with MG control.
In general, MGs are controlled by a multi-level hierarchical scheme [57,58]. In this configuration, the fast primary level does not require information exchange with other units to operate. On the other hand, the secondary and the tertiary level systems include device-to-device communication links. The role of communication in MG control has been explained in detail by several researches conducted on MG secondary control [59][60][61]. However, most of the communication-related MG studies mainly focus on the topology of the network and issues, such as limiting the communication between neighboring devices or detecting faults on communication links by analyzing the dynamic performance of the control system and looking for communication failure indicators [59]. To cut a long story short, in the majority of MG studies, the communication system is normally considered as an auxiliary service that either is properly operating or is down. By contrast, in this work, the contribution is on the design and modeling of a LPWAN-based communication system and its integration in MG control structure.
In order to propose a LoRaWAN communication framework for MG control system, the first step is to explain the feasibility and benefits of using LPWANs for this application in particular.

MG Communication System Design Considerations
In MGs, a communication (cyber) system must be operating in parallel with the electrical structure [62]. This concept is illustrated in Figure 4, and similarities can be observed with the smart grid architecture model (SGAM) which provides a five-layer interoperability architecture for smart grids [63,64]. Local MG control and management only occupies the first two layers of the SGAM framework.
In order to design a proper communication system for an MG, some key factors are to be considered carefully: • The physical scale of the MG: By this, we are referring to how widespread the DGs are in the system. For example, a short-range communication system may be applicable for a residential MG (smart house) architecture, whereas it might not be suitable for a small solar generation plant. • The location of the MG: As discussed before, the lack of access to popular cellular networks is a deciding factor in considering the utilization of LPWANs. • The level of sensitivity to latency and reliability: In LPWANs, in order to achieve lowpower and long-range characteristics, throughput and robustness are being sacrificed. This should be considered when the application requires a very reliable and high throughput communication.

Communication Layer
Information Flow

Residential MGs Communication Considerations
Residential MG systems require an M2M communication structure to create a platform for smart devices to communicate and coordinate. WiFi and ZigBee are the leading communication technologies for smart homes. They both use the 2.4 GHz band, and their physical and data link layer protocols are IEEE 802.11 and IEEE 802.15.4, respectively. Although both of these technologies can be used for home automation, their characteristics are quite different. WiFi is a high-power and high-throughput communication system, while ZigBee is the opposite [65][66][67]. The coverage of the aforementioned networks is less than 100 m, at best, and that is why they are called short-range technologies. Therefore, if in the MG of interest the separation between communication nodes (DGs) are in terms of hundreds of meters or more, WiFi and ZigBee cannot be used to establish a proper communication framework. In this case, other solutions are required to be considered.

Widespread DGs, LPWANs or Cellular Networks?
In the case of widely spread devices, the first solution is to use cellular networks. The idea of improving the efficiency and robustness of data transmissions through the existing cellular links started with the introduction of general packet radio service (GPRS), which was an extensive upgrade for the global system of mobile communication (GSM) [68]. GPRS idea is based on packetizing the data for transmission. Although GPRS can be used for IoT applications, there are more recent lightweight and low-power M2M protocols designed specifically for M2M over cellular networks. For example, narrowband internet of things (NB-IoT) is a very popular protocol whose operation is based on existing LTE cellular networks [69]. The performance of cellular-based long-range and low-power protocols have been compared to LPWANs before, and the general findings state that cellular protocols offer a better quality of service and resiliency while their power consumption and operational expenses are higher [70,71]. Apart from the additional expenses and complications regarding the usage of licensed frequencies by cellular-based protocols, there is another important consideration: network availability and signal quality. In remote and rural areas, depending on the region and the operators, weak network coverage is a popular problem for cellular networks which may cause cellular-based IoT protocols to down perform. This factor helps to justify the use of LPWANs, which operate in unlicensed sub GHz frequencies.
LoRaWAN and NB-IoT are implemented for smart system communication infrastructures when long-range capabilities are required. As a matter of fact, they are considered rivals since both provide essential features. In addition, both LoRaWAN and NB-IoT are leading technologies in their own categories. However, due to their structural differences, their benefits and drawback are almost in contradiction with each other. A comparison between LoRaWAN and NB-IoT characteristics is illustrated in a Venn chart, Figure 5 [72][73][74]. As previously explained, for this application the utilization of LoRaWAN is more favorable than NB-IoT due to its private network creation feature and unlicensed allocated spectrum.

LoRa Enabled Smart Inverters
In the previous section, the role of communication in MG control and management has been briefly explained. Besides, utilizing LoRaWAN for this specific application has been justified due to its long-range and low-power characteristics.
In this section, the implementation of LoRaWAN in MG control is explained and discussions are empowered by experimental tests.

LoRa Latency Test
To demonstrate the latency charactristics of LoRa, a test has been performed by using two Pycom/Lopy4 transceivers (one transmitter and one receiver, Figure 6) described as the following:

1.
The devices' real-time clocks (RTC) are synchronized by obtaining the time from the same network time protocol (NTP) server. (Denmark-dk.pool.ntp.org, accessed on 3 September 2021).

2.
A timestamp is created on the transmitter just before the transmission is initiated. Therefore, the ToA, which is basically the transmission time, is included in the latency computation. This timestamp is sent as the actual payload of the Tx frames.

3.
The receiver is coded in a way that another timestamp is created immediately after the transmitted frame is received. In this way, on the receiver side, both transmission and reception timestamps are available and have been stored for post-processing.
The experiment is repeated for all the SFs. At each step, 500 frames are sent every 4 s with the payload size of 20 bytes, and the results are presented in detail as boxplots in Figure 7. In addition, a comparative illustration is provided in Figure 8 that demonstrates the effect of adding SFs on LoRa transmission latencies.   It should be noted that, since only two devices have been implemented and no other activities were identified in the local 868 MHz bands at the time of the experiment, these recorded latency values are relatively idealistic estimations. In other words, apart from small computation and processing delays, the recorded latency values represent the LoRa frames ToA for different spreading factors.
It is useful to compare the latency results with theoretical packets ToA. According to references [75,76] a LoRa frame ToA consists of two elements, preamble ToA and payload ToA, which are calculated as follows: (sec) (8) where PRS defines the number of preamble symbols that is 8 in this case, PLB is the number of payload bytes which is fixed on 20, SF is the spreading factor, and CRC is the cyclic redundancy check indicator and set to zero, The configured coding rate is set to 4:8. By using Equations (7) and (8) and also Equation (5), the theoretical LoRa frames ToA values are calculated and compared with the latency results in Table 2. Same as before, the LoRa configured bandwidth is 125 kHz. As can be observed, the theoretical ToA values are less than the recorded latency for all SFs. This is due to computation delays at both microprocessor transmitters. However, further analysis is required to investigate this phenomenon that will be conducted in a future study by the authors. In addition, the ToA and overall latency strongly depend on the bandwidth that the LoRa channel is using. As mentioned before, there are three standard possibilities of 125 kHz, 250 kHz, or 500 kHz.
As final latency remarks, it should be noted that in large-scale deployments communication nodes compete to access the wireless medium by the use of their MAC protocols. This medium (band) can not necessarily accommodate all awaiting transmissions in every instant, which is one of the major causes of delays in wireless communication systems and is called medium access delays. Furthermore, low-power devices are designed to be in hibernation mode most of the time, which is another potential cause for delays. Investigating and analyzing the aforementioned latency causing aspects are out of the scope of this study, and require further research. It is safe to state that the observations of Figures 7 and 8 provides a sensible estimation of LoRa latency measures, and a good understanding of the effect of SF selection on the overall delay.

Experimental Testbed
To experimentally evaluate the aforementioned implementation, a Danfoss 2.2 kW inverter was utilized. This inverter was included in a four inverter setup in which all of them are controlled by a dSPACE (DS1006) real-time platform. On the DC side, the inverter was connected to a programmable/bidirectional DC source (REGATRON) and on the AC side it was connected to the stiff-grid through a safety transformer. A photo of the power system part of the experimental setup highlighting the different elements is provided in Figure 9. The experiments were conducted in CROM AC-MG laboratory in Aalborg university [77].  The inverter type is grid-feeding [78], and the control algorithm has been uploaded to the dSPACE platform. The details of the control structure is illustrated in Figure 10. The aim is to prove the inverter is able to receive remotely generated power references and regulate its power levels accordingly. In this sense, power references were transmitted to the inverter by a personal computer, and subsequently, measurements were sent back and recorded. By comparing these two trends, the capability of the inverters to follow the power references that are relayed through the communication system was presented. An illustration of the LoRa based communication system that is designed to fulfill the aforementioned goal has been prepared in Figure 11. Here, the role and specifications of the devices are listed as follows: a. Inverter and controller, which consisted of a Danfoss 2.2 kW bidirectional power converter and a dSPACE (DS1006) real-time control platform. A grid-feeding algorithm, prepared in Matlab/Simulink, was uploaded to the dSPACE unit to control the inverter. This class of inverters can regulate their output active and reactive power measurements by receiving external references, and an in-detail explanation of the control schema is out of the scope of this research [78]. This configuration can emulate a DG, load, or an ESS. b.
LoRa Node A. This node that was created by coding a Pycom/Lopy4 micropython enabled microcontroller was connected to the dSPACE unit by serial communication. This was achieved by using a MAX3232 adapter to convert the microcontroller UART logical signals to RS232 protocol levels. The details of this integration are illustrated in Figure 12. The duty of this device was to receive power references, remotely generated, by LoRa and transmit them to the inverter. Besides, it was responsible for transmitting the inverters power measurements by LoRa to the other receiving end. In order to establish meaningful interconnection between this microcontroller and the aforementioned dSPACE unit, data conversion is required. In this case, the inverter power measurements were converted from their 32-bit float representations to an array of four Hex bytes to be able to be transmitted through the serial channel.
These converted bytes are arranged and transmitted using the little-endian ordering. Needless to say, opposite conversions are required when references are relayed from the microcontroller to the dSPACE unit and subsequently the inverter control structure. Examples of the explained data conversion scheme are presented in Figure 13. Based on the explanations provided above, the microcontroller is acting as both a LoRa transceiver and a UART device. The configurations are listed in Table 3.
It should be noted that, since several tests are conducted for different SFs and transmission powers, their values are not included in Table 3. c.
LoRa Node B. This node was also created on a Pycom/Lopy device. It was coded to receive power references from a Matlab based profile generator by message queuing telemetry transport (MQTT) protocol, extract the payload, perform data conversion as illustrated in Figure 13, create LoRa frames, and transmit them to node A by LoRa. Node B is also responsible to receive power measurements from Node A by LoRa, convert four-byte representation to float, extract the payload, create MQTT messages, and publish over certain topics. These MQTT messages can be intercepted by other devices such as human-machine interfaces (HMIs) that are subscribing to the same MQTT topics. As a result, Node B, rather than just being a LoRa node, like Node A, was also an MQTT client therefore was WiFi-enabled. Based on this description, Node B can be regarded as a LoRaWAN/MQTT gateway that can be in connection with several Node A-class devices. 109.878 0x89 0xc1 0xdb 0x42   Two more devices contributed to this experimental test, a profile generator and a data logger. However, since they were just utilized to perform the simulation and do not have a real-world application, they were not included in the list of devices and Figure 11. In addition, although the test has been conducted for only one inverter as a proof of concept, more inverters can be included to form an actual MG.
As can be observed from Figure 11, in this experiment several physical layer communication protocols are utilized to fulfill the correct message exchanges between the smart inverter and the HMIs or the remote controllers, such as an energy management system (EMS).
The communication mechanism is illustrated in Figure 14 where the flowchart of uplink transmission, from Node A to Node B (LoRaWAN/MQTT gateway), is provided.

Experimental Results
These tests were performed to prove the inverters' active power levels can follow the remotely generated power references transmitted by a LoRa point-to-point communication architecture. These references were generated and transmitted once per minute. On the other hand, the transmissions of inverters power measurements took place every five seconds. Both the references and measurements, accompanied by their respected timestamps, were recorded on a local MQTT data logger subscribing to the relevant topics generated by previously introduced LoRa Node B. The tests were conducted for an indoor scenario (with obstacles) rather than a clear line-of-sight outdoor long-range situation. The two transceivers (Node A and Node B) were situated in two adjacent buildings with several concrete walls and doors in between. Their separation distance was approximately 100 m. This configuration demonstrated a typical LoRaWAN application, since it was well out of the range of conventional WiFi.
As comprehensively explained in Section 3, the effect of utilizing different SFs is to sacrifice throughput for coverage and vice versa. In other words, by increasing the Time-on-Air, the probability of intercepting the message is increased, especially in messy environments. To visualize this effect, two tests have been conducted for SF 12 and SF 7, which are the upper and lower limits in the LoRa modulation. The results are illustrated in Figure 15.  As it can be observed in Figure 15a, in the case of SF 12, a stable communication link was established since the measurements always follow their respected references. On the other hand, utilizing SF 7 as illustrated in Figure 15b, resulted in an unreliable communication system. For example, in the interval between seconds 60-180, the recorded measurements remain at 160 even though a new power reference has been created. Furthermore, no measurements were recorded for about a minute in the middle of this time interval. This clearly means a link loss has occurred and, as it can be observed, a newly generated reference was lost since it was not received and recognized by the inverter (LoRa Node A). The same problem repeatedly happened in other instances of the experiment period. In total, four power references are not received by the inverter which are highlighted in the figure. The irregularity observed in this case is due to the arbitrary variation of the link budget due to the passing of people and opening/closing of doors, since LoRa Node A was situated in an operational and busy office. Other electrical and thermal interferences were also present. Therefore, this situation can very well emulate a real-world scenario.
Another set of tests were performed to illustrate the effect of transmission power on the stability and reliability of the LoRa communication link. The Tx power of the Pycom/Lopy4 devices is set to 14 dBm by default and this power level was used for the previous tests. At this point, the tests were conducted for two other power values of 15 dBm and 5 dBm (for both Node A and Node B), and the results are presented in Figure 16. It should be noted that in both of these tests SF 7 is used and both the transceivers are situated in the same laboratory in close proximity of about 10 m. The same as previous tests, ten power references are generated, one minute apart, and the inverters measurements sampling rates were set to every five seconds. Comparing Figure 16a with b visualizes the Tx power effect and as expected, in the case of lower transmission power, an unstable communication link is established where packet losses are observed in both measurements and references transmissions. More specifically, five power references fail to be received and recognized by the inverter, which are highlighted in the figure. On the other hand, Tx power of 15 dBm (approximately 30 milliwatts) guarantees a robust information exchange system. It should be noted that, since the application of this communication system is related to power systems, some extra consumed milliwatts to ensure the reliability of the communication can be tolerated. However, if the nodes are battery powered and need to remain operational for several years, then these power differences gain more importance.

LoRaWAN/MQTT for Residential MG in Rural Areas: A Futuristic Case Study
In Section 5, the feasibility of equipping smart inverters with LoRa communication technology has been discussed. This translates to enabling these devices to connect and communicate over longer ranges and harsher environments while maintaining a low implementation and operational cost. In this section, a prospective application has been introduced that can benefit from LoRaWAN enabled smart inverters to a large extent.
The implementation of MG philosophy for the residential sector gains a lot of interest recently. As explained in Section 4.3, if such a residential MG is situated in a rural or a remote area, it can benefit from smart inverters with long-range communication capabilities. Furthermore, based on the discussions provided in Section 3, for such a private communication network LoRaWAN is the preferred choice among the other LPWAN protocols. Therefore, it is used for the proposed communication framework in this case study. As illustrated in Figure 17, in this configuration there are two class of devices connecting through the communication architecture:

•
Outdoor nodes: DGs, ESSs, electrical car charging stations, and field sensors are examples, among many more for the first class of devices. In general, all the endnodes that are outdoors and are separated by distances more than tens of meters fit into this category. • Indoor nodes: LoRaWAN Gateways and application servers, EMS, MG supervisory control system, user interfaces, and other indoor applications.
According to this system configuration, all the outdoor communications are coordinated by LoRaWAN MAC over a LoRa physical link. LoRaWAN enabled smart inverters are used to interface the DGs, ESSs, and loads to the MG bus. Other nodes, mostly sensors, are also LoRaWAN enabled, although they do not use power-electronics interfaces. Once the transmissions and measurements are received by the LoRaWAN gateways (emulated by Node B in the previous section), the payloads are extracted from the LoRaWAN frames and converted to MQTT message format. From this point forward, the LoRaWAN gateway's role is changed to an MQTT client and publishes the messages to a local broker by a short-range physical layer communication technology such as IEEE 802.11, since the long-range capability is no longer required. The other indoor users can also connect to the same MQTT broker and subscribe to the topics that they are interested in or publish relevant messages.
One distinctive characteristic of this proposed structure, comparing with most other private LoRaWAN networks, is the localization of the communication servers. In Lo-RaWAN systems, normally a cloud-based network server is used to collect, manage, and store the data. For instance, the things network (TTN), which is a LoRa Alliance contributor, is a global internet-hosted server that can be used to create LoRaWAN networks [79][80][81].
In the TTN platform, each gateway should be registered and a user interface is provided to screen the received data. Furthermore, it is possible to use higher-level application layer protocols such as MQTT for better messaging services in coordination with TTN. This platform ensures reliable messaging by utilizing three security keys. Two of these keys are session keys that are automatically updated for each session and are unique for each device. The other security key, the application key, is used to coordinate the activation process and trigger the generation of session keys. The security methodology used here is generally similar to the algorithm utilized for the ZigBee communication system. In other words, TTN offers great security measures in terms of authentication and encryption [82]. From another viewpoint, the authors have two concerns as follows: 1.
TTN, like other available LoRaWAN network servers [83], are cloud-based. In other words, although the TTN is adequately secure, an internet connection is still required which may not be always favorable. This is due to possible weak network coverage, especially in remote areas that are the focus of this case study [84].

2.
It is more secure to maintain the local data locally. In other words, in this proposed architecture all the messages are local and bound to the limits of the MG. Therefore, if it is possible to avoid any unnecessary data interactions with cloud-based platforms, the overall security can be further improved. This means designing and utilizing local LoRaWAN servers.
By localizing the servers, the aforementioned problems can be mitigated. Besides, the end-to-end latencies will be minimized. In the proposed structure of this study, the LoRaWAN gateways, MQTT broker, and other indoor nodes form a local area network (LAN) over WiFi. Here, the gateways are not just packet-forwarders since they extract the modulated messages from LoRaWAN frames and create MQTT topics. Therefore, they can be called LoRaWAN/MQTT gateways. In other words, the duty of the network server, such as TTN, is dispersed through local gateways and the MQTT broker.

Conclusions
The main point of this study is to integrate LoRa communication architecture in smart inverters control structure to provide long-range communication capabilities. To conceptualize the research, first a brief overview of different LPWAN technologies was prepared. Based on the findings of this short survey, it was concluded that LoRaWAN is a better candidate for the communication system of the application of interest than MG structure communication layer when long-range capabilities are required. Then, the distinguishable parameters of the current study in comparison with the other related publications were described, after a review on LoRa/LoRaWAN application in smart systems. The key points are: • The problem has been investigated from both communication and control systems angles. This study can be useful for audiences from both aforementioned backgrounds.
In the humble opinion of the authors, it may be challenging to find a similarly structured work, and normally either one of the aspects is overlooked to some extent and the focus is either on control or communication. • Details on architecture and system design parameters for both viewpoints were described. The point-to-point LoRa communication architecture was developed by using off-the-shelf micropython enabled microprocessors, and the details are provided for other researchers that aim to replicate the system. We found out that the LoRa communication system design is logical and straightforward with ease of implementation, free spectrum, and cost-effectiveness of end-devices. On the other hand, the dSPACE hosted grid-feeding inverter control structure was also comprehensively explained. The designed control structure was performed in a stable a reliable manner, power references are followed, and no frequency synchronization problems were detected. • The interaction between both systems, communication and control, was described and experimentally validated. We demonstrated the power reference following capability of the grid-feeding smart inverter by utilizing LoRa to connect the transmitter and receiver nodes. It was proved that all the SFs are not capable of creating stable and reliable communication systems, even when the range is low. It is the same for the different transmission power levels that affect the link reliability considerably. In other words, the communication system should be optimally designed so that important aspects, such as coverage, throughput, and energy consumption characteristics, match the required application.
In order to wrap up the study, at the final part, a potential application for LoRa enabled smart inverters for control, management, and coordination of remote residential MGs when the components are spread over a wide area has been proposed and explained. Future works are required to experimentally implement and evaluate the described structure, which is planned to be conducted by the authors.