# Energy Consumption Model for Sensor Nodes Based on LoRa and LoRaWAN
## 5 LoRa and LoRaWAN Technologies
### LoRa Modulation Technique
#### 5.2.2 LoRa Packet Structure  
This part presents the LoRa frame definition. This frame starts with a preamble which is used for the synchronization between the receiver and the transmitter [9; 10; 11]. After the preamble, an optional header carries the size of the payload and the information about the LoRa configuration. It is noted that the header is always encoded with a \(CR=\frac{4}{8}\). The payload is encoded with a variable _CR_.  
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Class** & **Brief Description** & **Power Consumption** \\ \hline Class A & Sensor initiate communication, downlink after transmission & Most energy efficient \\ Class B & Slotted communication synchronized with beacon frames & Efficient with controlled downlink \\ Class C & Devices listen continuously, downlink without latency. & high power consumption \\ \hline \hline \end{tabular}
\end{table}
Table 1: LoRaWAN class comparison.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Spreading Factor:** _SF_ & **Chirp Code Length (Bit)** \\ \hline
7 & 128 \\
8 & 256 \\
9 & 512 \\
10 & 1024 \\
11 & 2048 \\
12 & 4096 \\ \hline \hline \end{tabular}
\end{table}
Table 2: Chirp code length.  
An optional Cyclic Redundancy Check (CRC) is sent at the end of the frame. Figure 5 depicts the LoRa frame content.  
To calculate the time on air (or packet duration), we start with the calculation of the payload symbol [16]. For a given payload noted \(PL\) (in bytes), a spreading factor \(SF\) and a coding rate \(CR\), the number of symbols \(N_{payload}\) used to transmit the payload can be calculated by Equation (14):  
\[N_{payload}=8+max\left(ceil\left(\frac{\Theta(PL,SF)}{\Gamma(SF)}\right)\cdot \frac{1}{CR},0\right), \tag{14}\]  
where ceil indicates the ceiling function, \(\Theta(PL,SF)=8\cdot PL-4\cdot SF+16+28-20\cdot H\); with \(H=0\) when the header is enabled and \(H=1\) when no header is present and \(\Gamma(SF)=SF-2\cdot DE\); with \(DE=1\) when the low data rate optimization is enabled and \(DE=0\) for the other case. Then, the time on air is the sum of the preamble and the payload duration:  
\[T_{Packet}=T_{Preamble}+T_{payload}, \tag{15}\]  
where \(T_{Packet}\), \(T_{Preamble}\) and \(T_{payload}\) are, respectively, the packet duration, the preamble duration and the payload duration. The preamble duration is expressed as:  
\[T_{Preamble}=(4.25+N_{P})\cdot T_{Symbol}, \tag{16}\]  
where \(N_{p}\) is the preamble symbol number and \(T_{Symbol}\) is the symbol period. It is defined as the time taken to send \(2^{SF}\) chips. Then, recalling that the bandwidth \(BW\) is equal to the chip rate, the symbol period is given by Equation (17):  
\[T_{Symbol}=\frac{2^{SF}}{BW} \tag{17}\]  
The payload duration is defined in Equation (18):  
\[T_{payload}=N_{payload}\cdot T_{Symbol} \tag{18}\]  
We introduce the energy per useful bit \(E_{bit}\) in this paper, which is an important metric to evaluate the power consumption of the sensor node. The \(E_{bit}\) expression is given in Equation (19):  
\[E_{bit}=\frac{E_{Total}}{8\cdot PL}=\frac{Pcons(P_{Tr})\cdot T_{Packet}}{8\cdot PL }, \tag{19}\]  
where \(PL\), \(E_{Total}\) and \(Pcons(P_{Tr})\) the payload size, the total consumed energy and the total consumed power which depends on transmission power. Using Equations (15), (16) and (18), the energy per useful bit can be rewritten in the following equation:  
\[E_{bit}=\frac{Pcons(P_{Tr})\cdot T_{Packet}}{8\cdot PL}=\frac{Pcons(P_{Tr}) \cdot(N_{payload}+N_{P}+4.25)\cdot T_{Symbol}}{8\cdot PL} \tag{20}\]  
Figure 5: LoRa packet structure.  
Replacing \(T_{Symbol}\) with its expression in Equation (17), we can write \(E_{bit}\) as a function of the spreading factor \(SF\). As can be seen, the \(E_{bit}\) is an increasing function according to \(SF\):  
\[E_{bit}=\frac{Pcons(P_{Tr})\cdot(N_{Payload}+N_{P}+4.25)\cdot 2^{SF}}{8\cdot PL \cdot BW} \tag{21}\]  
Table 3 presents different transmission power levels and corresponding current consumption that can be used with the LoRa _XX1272_ transceiver [29].