# LoRa Enabled Smart Inverters for Microgrid Scenarios with Widespread Elements
## 3 LoRaWAN Specifications and Applications
### 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]:  
\[CW(t)=a(t)\cdot cos[\theta(t)] \tag{1}\]  
where _a(t)_ defines the power of _CW(t)_ and is zero when \(t\) value is outside of the chirp duration boundary. \(\Theta\)_(t)_ represents the phase. The first and second derivatives of \(\Theta\)_(t)_ provide the instantaneous frequency and chirp rate, respectively:  
\[f(t)=\frac{1}{2\pi}\frac{d\theta(t)}{dt} \tag{2}\]  
\[\mu(t)=\frac{1}{2\pi}\frac{d^{2}\theta(t)}{dt^{2}} \tag{3}\]  
If the chirp rate, \(\mu(t)\), is a constant, which means \(\Theta\)_(t)_ is a second order polynomial, the chirp waveform is linear. The polarity of \(\mu(t)\) defines if the signal is an upchirp (\(\mu(t)>0\)) or a downchirp (\(\mu(t)<0\)). LoRa modulation carrier signals are linear chirps, so based on Equations (1)-(3) it can be formulated as:  
\[CW(t)=\sqrt{2}P\cdot cos[2\pi f_{0}t+\mu\pi t^{2}+\varphi] \tag{4}\]  
where \(P\) is the average power, \(f_{0}\) is the center frequency, \(\mu\) is the chirp rate, and \(\varphi\) 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 coveragesince it increases the receiver sensitivity. Knowing that, the chip rate equals to the channel bandwidth [50]:  
\[SymbolRate=\frac{BW}{2^{SF}}\quad(symbol/sec) \tag{5}\]  
SF also indicates the number of bits that are modulated into a symbol, therefore, the data rate is:  
\[DataRate=SF\cdot\frac{BW}{2^{SF}}\quad(bit/sec) \tag{6}\]  
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.