# Enhanced LoRaWAN Adaptive Data Rate for Mobile Internet of Things Devices
## 3 Proposed ADR Schemes
### Exponential Moving Average-Based ADR (EMA-ADR)  
An EMA is a type of weighted moving average, which refers to a weighting factor for each SNR value of \(M\) packets. In general, the SNR varies over time, even in a fixed environment, resulting in an inaccurate SF and TP configuration [16]. The reasons why the SNR shows such high variability in space and time include various noise factors, fading, interference, and attenuation. The EMA for time-series data can be computed iteratively, as follows:  
\[S_{t}=\left\{\begin{array}{ll}Y_{t},&t=1\\ \beta.Y_{t}+(1-\beta).\ S_{t-1},&t>1\end{array}.\right. \tag{6}\]  
In (6), \(Y_{t}\) represents the current SNR value at time \(t\), \(S_{t}\) denotes the value of the EMA at any time \(t\), and \(\beta\) is a smoothing factor (\(0<\beta<1\)). Note that a larger value of \(\beta\) reduces the level of smoothing, whereas a value of \(\beta\) close to zero has a greater smoothing effect and it is less responsive to recent SNRobservations. Therefore, we used \(\beta\) = 0.7, because of the mobility feature (Ref. [29] uses \(\beta\) = 0.5 for indoor positioning).  
```
Input : TP = 2\(\sim\)14, SF = 7\(\sim\)12, \(M\), \(SNR_{req}\), \(device_{margin}\) Output : SF and TP // computes 1. mean of the \(SNR\) of \(M\) received packets 2. Variance (\(\sigma^{2}\)) 3. Standard deviation (\(\sigma\)) 4. LowPassFilter (LPF) = (\(\mu\) - \(\sigma\)) and HighPassFilter (HPF) = (\(\mu\) + \(\sigma\)) for\(i\gets 0\)to\(M\)do \(SNR\) = get\(SNR(i)\) if(SNR \(\geq\) LPF and \(SNR\)\(\leq\) HPF ) then  insert \(SNR\) into \(SNRlist\)  end for for\(i\gets 0\)to\(SNRlist\)do \(Sum\)  end for\(SNR_{m}\) = \(Sum\)/ Size of \(SNRlist\) // computes \(\triangleright\) Network server LoRaWAN ADR
1. \(SNR_{req}\) = demodulation \(floor\) (current data rate) 2. \(device_{margin}\) = 10 \(\triangleright\) LoRaWAN default
3. \(SNR_{margin}\) = (\(SNR_{m}\) - \(SNR_{req}\) - \(device_{margin}\)) 4. \(steps\) = \(int\) (\(SNR_{margin}\)/3) while(steps > 0 and \(SF\) > \(SF_{min}\))do \(SF\) = \(SF\) - 1 \(steps\) = \(steps\) - 1  end while (steps > 0 and TP > TP \({}_{min}\))do \(TP\) = \(TP\) - 2 \(steps\) = \(steps\) - 1  end while (steps < 0 and TP < TP \({}_{max}\))do \(TP\) = \(TP\) + 2 \(steps\) = \(steps\) + 1  end for NS transmits \(LinkADRReq\)
```  
**Algorithm 1**Proposed Gaussian filter-based adaptive data rate (G-ADR) scheme.  
In terms of SF and TP estimation while using the measured SNR, an SNR smoothing process is required. Therefore, we conducted an EMA filter-based smoothing of the SNR for several packets received at the NS through a computer simulation, as shown in Figure 5. It can be seen that the smoothing process reduced the spikes of the raw SNR values. In addition, the smoothing operation in EMA smoothing can yield results with only the first two SNR observations [29].  
It was recently shown in [20] that, by taking the average of \(M\) packets, one can improve the results in terms of the PSR and lower the energy consumption when compared to a typical ADR. Therefore, we propose using the EMA filter for SNR smoothing, which resists the rapid changes in the SNR of \(M\) packets and acts as a local averaging function, and it is directly related to the \(\beta\) parameter.  
The proposed EMA-ADR can improve the performance in terms of the PSR, convergence period, and energy consumption.