# Design of a Partially Grid-Connected Photovoltaic Microgrid Using IoT Technology
## 4 Design of the IoT Communication Network
After an uplink transmission, the device opens two receive windows at predetermined periods. If the gateway server does not answer in any of these receive windows, the device's next opportunity will be after the next uplink transmission. In Class B devices, additional receive windows are open at predetermined time intervals. The end-device gets a time-synchronized signal from the gateway in order to open its receive window at the predetermined time. This informs the server about the end-listening device status. Class C devices always have open receive windows and only close when they are in the data sending mode. Figure 13 shows the architecture of the LoRaWAN network. \begin{table}
\begin{tabular}{c c} \hline \hline
**Modulation** & **Spread Spectrum** \\ \hline Transmission mode & Half-duplex \\ Frequency band & ISM \\ Maximum data rate & 50 Kbps \\ Payload length & 243 bytes \\ Transmission range & Up to 20 Km \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Summary of LoRa features. The smart meters in our proposed microgrid architecture can be implemented using LoRa end-node class B or class C devices. Figure 14 illustrates a representation of IoT LoRa-based communication network within the proposed microgrid design. In this context, low-cost microcomputers, such as the Raspberry Pi devices, can be used to implement the end-nodes, gateways, and the centralized controller. The smart meter features continuous monitoring to load power in addition to microgrid bus voltage. Management of the battery bank and its _SOC_ can be also taken into consideration. A Raspberry Pi-compatible LoRa shield is used to construct the LoRaWAN-based fog computing, while the gateways can be designed using LoRa GPS HAT along with Raspberry Pi devices. The gateways directly communicate to the network server using TCP/IP protocol. The microcontroller LoRaWAN gateway collects the incoming data from smart meters and sends it to the TCP/IP server for further processing. The load power is calculated based on collected data from accurate voltage and current sensors. At the same time, the SSTS transfer signals are generated by the end-node devices based on event-based control signal directed from the network server. The smart meter operates as a LoRaWAN node, collecting data from smart controllers and charge controller agents and sending it through LoRaWAN. Using the LoRaWAN class B node and LoRaWAN gateway, the results showed that a latency of within 1 s is attainable. The power meter at the load side (prosumer) of the microgrid, sends the microgrid voltage and load power data every second. The required latency is then below 1 s and the payload is 1000 bytes. \begin{table}
\begin{tabular}{c c c c} \hline \hline
**Class** & **A** & **B** & **C** \\ \hline Energy consumption & Low & Moderate & High \\ Down link latency & High & Low & No latency \\ Mode of operation & Bi-directional with the gateway & Bidirectional with & Bidirectional \\ Source of energy & Battery & scheduled receive slots & communication \\ \hline \hline \end{tabular}
\end{table} 
Table 6: LoRa device classes. Figure 13: Schematic representation of LoRaWAN network architecture. The physical layer of LoRa network mainly depends on the chirp spread spectrum (CSS) transmission technique, which can achieve both low power and long-range communication. In addition, the modulation in LoRa devices is highly adaptable and can be configured to provide data at speeds of up to 50 kbps. On the other hand, the un-optimized settings of operation can lead the data transmission rate to be extremely low. Therefore, customizable settings define the LoRaWAN characteristics and performance. The key parameters that greatly affect LoRa network performance, especially the data transmission rate are: operating frequency, bandwidth, spreading factor, and correction rate. Regarding the modulation frequencies, LoRa communicates over license-free radio frequency bands that differ from one region to another.