# Indoor Vehicles Geolocalization Using LoRaWAN
## 4 The Proposed Architecture
### The Geolocalization Algorithm  
Our localisation application makes use of the metadata fields provided by the networks server. As shown above, the LoRaWAN architecture directly provides complete information about the gateways that received the packet sent by the tagging client device and the strength of the signal (RSSI) with which it was received. With this information, we applied the localisation algorithm. Our solution to determine the  
Figure 3: The metadata content provided by the networks server. localisation of a client is based on trilateration. Trilateration is the mechanisms used by GPS for example and it involves measuring the distances to some known reference points, the satellites in the case of GPS. Satellites simply broadcast a signal which is received by the GPS device with a specific time and distance. Consider a single satellite that broadcasts a signal that eventually hits the GPS receiver; in this case, we will know the distance and this distance forms a circle equal in all directions. With three satellites, the true location can be determined as the point where all three circles intersect. In reality, since we are in a three-dimensional world that GPS satellites broadcast signals as a sphere, the exact result is the one given by where all spheres intersect, determining the position of the GPS receiver. In our case, the gateways that receive the broadcasted message from the client act as the satellite, and the RSSI value for each gateway perceived by the client is used to determine an estimate of the distance. The value of airtime was not used because, while testing various devices, we discovered that the actual measurement of these data was not implemented. So the basic goal is to pass from the values of the RSSI to an estimation of the distance. This process has been widely studied in the literature and many models are available. There are also various studies in the literature specifically oriented to LoRa. Next, Section 5 will review some of this work, compared to our approach. We took as a starting assumption that we were not aiming for exact measurements and we therefore opted for a simple _Log-distance model_, derived from analytical and empirical methods. It can simply be defined as:  
\[P_{r}(d)=\frac{P_{t}}{d^{n}}, \tag{1}\]  
where \(n\) is the called distance-power gradient. In the ideal case, \(n=2\); however, \(n\) is typically 4 in realistic situations. A value of \(n\) in the interval [2; 6] is commonly accepted. In Section 5 we detail how we computed the used value for \(n\). To fit to our purposes we adapted this equation as:  
\[RSSI=-10 nlog_{10}(d), \tag{2}\]  
from which an estimator of \(d\), indicated as \(\delta\), was obtained as:  
\[\delta=10^{\frac{RSSI}{10+n}}. \tag{3}\]  
Now, supposing the use of the RSSI values from three different gateways, \(g_{1}\), \(g_{2}\), and \(g_{3}\) that are located at coordinates \((x_{g_{1}},y_{g_{1}})\), \((x_{g_{2}},y_{g_{2}})\), and \((x_{g_{3}},y_{g_{3}})\). If we indicate the point to be located as \((x,y)\) and the computed distances are \(d_{g_{1}}\), \(d_{g_{2}}\), and \(d_{g_{3}}\) (see Figure 4 for a graphical representation of this structure), we can state the following equations:  
\Subtracting the second equation from the first, we obtain:  
\[(-2x_{g_{1}}+2x_{g_{2}})x+(-2y_{g_{1}}+2y_{g_{2}})y=d_{g_{1}}^{2}-d_{g_{2}}^{2}-x _{g_{1}}^{2}+x_{g_{2}}^{2}-y_{g_{1}}^{2}+y_{g_{2}}^{2}. \tag{6}\]  
Doing the same, thus subtracting the third equation from the second:  
\[(-2x_{g_{2}}+2x_{g_{3}})x+(-2y_{g_{2}}+2y_{g_{3}})y=d_{g_{2}}^{2}-d_{g_{3}}^{2} -x_{g_{2}}^{2}+x_{g_{3}}^{2}-y_{g_{2}}^{2}+y_{g_{3}}^{2}. \tag{7}\]  
We obtain a system of two equations in two unknowns:  
\[ \begin{cases}Ax+By=C\\ Dx+Ey=F,\end{cases}  \tag{8}\]  
which has the solution:  
\[ \begin{cases}x=\frac{CE-FB}{EA-BD}\\ y=\frac{CD-AF}{BD-AE}.\end{cases}