# LaRaWAPS: A Wide-Area Positioning System Based on LoRa Mesh
## 5 Implementation
### Anchors Deployment  
We deploy the system in the Yuquan Campus of Zhejiang University. In the actual deployment of the system, the selection of the most appropriate anchor location is considered to better cover the positioning blind area. With the help of electromagnetic simulation software, the signal intensity of anchors at different positions can be generated to help evaluate the coverage ability of anchors.  
The actual deployment requires the coverage area to receive stable signals from at least three anchor points (\(RSSI\geq-85\) dBm). Through the heuristic algorithm, we hope to use as few anchor points as possible to provide positioning ability covering Yuquan Campus. The proposed algorithm is shown in Algorithm 3.  
As shown in Figure 9a, we assume several locations \(l_{n}\) where anchors can be placed at intervals of 5 m. Specifically, the green dots in the figure indicate the location of chosen anchor points. Then, we convert the spatial grid into grids spaced 1 m apart and calculate the signal intensity of the anchor placed at position \(L_{n}\) on all grid points, denoted as \(S^{n}\). The member \(s_{j}^{n}\) of the set \(S^{n}\) denotes the signal strength of the anchor placed at the \(n\)-th point at the \(j\)-th lattice point. Its value is obtained by electromagnetic simulation software. At this point, each position \(l_{n}\) in the set \(L\) can place anchors. \(c_{j}\) represents the signal coverage quality at the \(j\)-th lattice point, which is 0 data when there is no signal.  
Then, suppose that after placing an anchor point at \(l_{n}\),  
\[c_{j}^{(n)}=\begin{cases}c_{j}+1,s_{j}^{n}>-85\;\text{dBm}\quad\&\quad c_{j}<3,\\ c_{j},else.\end{cases} \tag{10}\]  
Next, find \(n_{0}\) for maximizing \(C^{(n)}\),  
\[C^{(n)}=\sum_{j}(c_{j}^{(n)}-c_{j}). \tag{11}\]  
Move \(n_{0}\) out of set \(L\) and add it to set \(L^{\prime}\), whose elements indicate where to place the anchor.  
\[c_{j}=c_{j}^{(n_{0})}. \tag{12}\]  
Finally, repeat steps 2 to 3 until a set \(L^{\prime}\) of \(k\) elements is found, the set \(L^{\prime}\) represents the lattice points where the optimal \(k\) anchor points are placed.  
Figure 8: Control and visualization Interface.  
```
Input: A set of grid position coordinates for which anchor points can be placed \(L\). The position coordinate set of the signal evaluation grid points \(S^{0}\), A cet of signal strengths at different locations \(S^{n}\). Output: A set of locations where anchor points should be placed \(L^{\prime}\)
1 Initializes the signal evaluation array \(c\);
2 whiledo
3\(n=1\);
4 while\(l_{n}\in L\)do
5 Calculate \(c^{(n)}\) according to the Formula (10);
6 Calculate \(\Delta C^{(n)}\) according to the Formula (11);
7\(n=n+1\);
8
9 end while
10 Find \(l_{n0}\) for \(max(\Delta C^{(n)})\);
11 Move \(l_{n0}\) into \(L^{\prime}\);
12 Move \(l_{n0}\) out o L, and update the element sequence number in \(L\);
13 Update \(c\) according to the Formula (12);
14 if\(\forall c_{i}\geq 3\)then
15 break;
16
17 end if
18 return\(L^{\prime}\);
```  
**Algorithm 3**LoRa anchors optimization deployment algorithm  
Based on the above algorithm, numerical experiments in the Yuquan Campus of Zhejiang University were carried out. Firstly, a number of green grid points 5 m apart are marked on the map to indicate the alternative anchor position, as shown in Figure 9. We found that only 18 anchor points could be deployed to provide a stable location service capability for the entire outdoor area of the campus. The green dots in Figure 9 indicate where the anchor points should be placed. Figure 9 shows the signal coverage capability when 18 anchor points are placed. The blue area in the figure indicates that positioning signals from more than three anchor points can be received. The white area that cannot provide positioning services corresponds to the building area.