# Real-Time Indoor Positioning Approach Using iBeacons and Smartphone Sensors
## 3 Research Method
### BLE-Based Method  
By combining ranging of RSSI and the radio map, RSSI data of iBeacons can be used for accurate positioning. Trilateration can provide location estimates according to real-time RSSI, while fingerprinting can support it with the NLOS features in the radio map. **Trilateration**. Inspired by the notion of pseudo ranges in GNSS positioning, we use RSSI ranging for the trilateration method.We also infer the related formula similar to the single point positioning with pseudo ranges. As indoor positioning is conducted in a small range, the propagation time from a beacon to the receiver is quite short. In this sense, clock error is negligible. Equation (1) presents this simple ranging model, where \(\rho^{i}\) is the pseudo range and \(v\) represents stochastic noise. Because Equation (1) is a nonlinear function of the location coordinates (\(x\), \(y\), \(z\)), we expand it according to Taylor series and keep linear terms only. The derived linear form is given in Equation (2). \[d^{i}=\rho^{i}+v=\sqrt{(x^{i}-x)^{2}+(y^{i}-y)^{2}+(z^{i}-z)^{2}}+v \tag{1}\]  
\[d^{i}-\rho_{0}^{i}=\frac{x_{0}-x^{i}}{\rho_{0}^{i}}\Delta x+\frac{y_{0}-y^{i}} {\rho_{0}^{i}}\Delta y+\frac{z_{0}-z^{i}}{\rho_{0}^{i}}\Delta z \tag{2}\]  
According to the model of 'log distance path loss' of radio signals [30], RSSI is a function of distance (see Equation (3)). \(P(d_{0})\) indicates the RSSI of a reference location with distance of \(d_{0}\) to a known transmitter, and \(d\) indicates the distance from the current location to the transmitter. Parameter \(n\) reflects attenuation of signal. Equation (4) shows the simplified case where the distance \(d_{0}\) is a unit distance (i.e., 1 m) and \(A\) represents the RSSI of the unit distance. \[RSSI=P(d_{0})-10 nlg(\frac{d}{d_{0}}) \tag{3}\]  
\[RSSI=A-10 nlg(d),\,\,\,d_{0}=1,A=P(d_{0}) \tag{4}\]  
Conversely, RSSI value can be used to infer the distance (see Equation (5)) between a BLE beacon (the transmitter) and the current location of smartphone (the receiver). Thus, the distance between the received location and the emitted location of a beacon is given as follows:  
Figure 1: The data fusion workflow of Bluetooth Low Energy (BLE) positioning and pedestrian dead reckoning (PDR) locations. \[d=10^{\frac{A-RSSI}{10n}} \tag{5}\]  
To implement Equation (5), two parameters have to be determined for this transformation from RSSI to length, i.e., \(A\) and \(n\). The two parameters reflect the characteristics of specific environments. For the testbed in this paper, we pre-computed the two parameters at reference points via surveying adjustment. With more than four known distances between the selected points and BLE beacons, Equation (6) presents the error equation of the two parameters, which is derived from Equation (4). For \(k\) (\(k>4\)) distances, we can obtain the adjustment values of \(A\) and \(n\) by inputting these distances (\(d_{k}\)), RSSI measurements (\(RSSI_{d_{k}}\)), and the related RSSI estimate (\(RSSI_{d_{k}}^{0}\), the initial value). \[ \begin{bmatrix}v_{1}\\ v_{2}\\ \dots\\ v_{k}\end{bmatrix} = \begin{bmatrix}1&-10 lg(d_{1})\\ 1&-10 lg(d_{2})\\ \dots\\ 1&-10 lg(d_{k})\end{bmatrix}\begin{bmatrix}A\\ n\end{bmatrix} - \begin{bmatrix}RSSI_{d_{1}}-RSSI_{d_{1}}^{0}\\ RSSI_{d_{2}}-RSSI_{d_{2}}^{0}\\ \dots\\ RSSI_{d_{k}}-RSSI_{d_{k}}^{0}\end{bmatrix}  \tag{6}\]  
After obtaining the environmental parameters of Equation (5), we can generate real-time locations by applying the trilateration algorithm in an iterative way (see Equation (7)). The error equation of location coordinates is derived from Equation (2):  
\[V=BX-l,l= \begin{bmatrix}d^{1}-\rho_{0}^{1}\\ d^{2}-\rho_{0}^{2}\\ \dots\\ d^{n}-\rho_{0}^{n}\end{bmatrix} ,X= \begin{bmatrix}\Delta x\\ \Delta y\\ \Delta z\end{bmatrix} ,B=