Smartphone Distance Estimation Based on RSSI-Fuzzy Classification Approach

Positioning people indoors has known an exponential growth in the last few years, especially thanks to Bluetooth Low Energy (BLE) technology and the Received Signal Strength Indicator (RSSI) technique. This approach is available in wearable devices, is easy to implement and has energy consumption advantages. However, the relative distance calculation is inaccurate, as the strength of BLE signals significantly fluctuates in indoor environments. Typical coping mechanisms, such as path-loss propagation models, require mathematical modeling and time-consuming calibration, that depend on the environment. In this paper, we propose a novel distance estimator based on RSSI-fuzzy classification of the BLE signals. Fuzzy-logic improves the robustness and accuracy of RSSI-based estimators, does not require an explicit propagation model and is easy and intuitive to (graphically) tune (using basic statistical analysis). The estimator’s suitability and the feasibility to provide an easy implementation were experimentally demonstrated in two scenarios with real-world data.


I. INTRODUCTION
The study and implementation of Bluetooth Low Energy (BLE) wireless signals -transmitted by commercial wearable devices-together with the Received Signal Strength Indicator (RSSI) positioning approaches for positioning and tracking people, and sensing human social interaction in indoor environments has grown in the last few years [1]- [4]. Their widespread use and success is mainly due to their ubiquity in wearable devices, straightforward implementation and the energy efficiency of BLE [2], [5]. Also during the recent COVID-19 crisis, approaches based on the combination BLE-RSSI were used for contact-tracing applications [2], [6].
However, the BLE signal strength is prone to fluctuations due to the effect of various environment geometries, power transmission variations, and well-identified noise sources inherent to radio wave propagation [5]. In consequence, estimating the relative distance between two nodes using approaches based on RSSI is usually inaccurate. Furthermore, in the specific case of wearable devices, the heterogeneity of the embedded hardware and software, and the way the user handles the device greatly increase the uncertainty both in the transmission and the measurement of signals, even under Lineof-sight (LOS) conditions. Therefore, there have been many attempts to properly model the behavior of radio waves propagation under diverse environment conditions and mitigate the RSSI fluctuation effects on the distance estimation.
Among the existing RSSI-based approaches to estimate the relative distance between two nodes, those that rely on propagation path-loss models are the most straightforward, but require time-consuming parameter tuning. However, once parameters are well adjusted, path-loss models have shown moderate accuracy in environments with low fluctuations in the RSSI values. Generally, the Free space model, Two-ray ground model, and Logaritmic path-loss model are used to relate the RSSI with the distance between transmitter and receiver devices [7]. Nevertheless, the accuracy on the distance estimation depends on the correct selection of the models' coefficient values as well as the model used. The coefficient values depend on the environment and are commonly obtained by fitting empirical measurements with the selected model. In consequence, a generalized setup that works under a wide variety of environment conditions is still an open challenge.
Some positioning systems based on Fuzzy logic have been proposed in literature, in order to address the aforementioned drawbacks. Fuzzy logic has been noticeably integrated in fingerprint-based Indoor Positioning Systems (IPS) [8]- [10], both in their online and offline phase to improve their accuracy and robustness. Also, it is used to evaluate the scenarios and help positioning systems to select the most suitable algorithm/parameters for each specific case [11].
In this paper, we present a distance estimation approach based on the RSSI-fuzzy classification of BLE signals transmitted from smartphones. The key contributions are: • We present a novel, intuitive and versatile system based on BLE RSSI and fuzzy rules to estimate the relative distance between two smartphones, without the need for well-configured and tuned propagation models. • Our proposed system, unlike those using path-loss propagation models, increases the robustness and accuracy in the distance estimation process against signal fluctuations. • We demonstrate the suitability of the approach for distance estimation and show the feasibility of the implementation of the approach using a public dataset that includes indoor and outdoor scenarios.

II. RELATED WORK
The combination of BLE with RSSI measurements for distance estimation has played a relevant role in the last few years. This approach is mainly used in deployments where commercial wearable devices are involved [1]- [4], as its easy implementation on wearable devices and low energy consumption are distinctive advantages [2], [5]. On the downside, the BLE signals' propagation behaviour is highly affected by the environment features, even in LOS conditions. Also, the diversity of hardware and software embedded in the communication devices affect the RSSI. Consequently, these disadvantages generate inaccuracies in the distance estimation and, therefore, in the corresponding IPS. In order to face these drawbacks, different approaches have been proposed in the literature, based on Regression models [12], Filters [13], Neural networks [5] and fuzzy-logic. In this work, we focus on the latter category, and describe the most relevant ones below.
As a first type of use, Orujov et al. [11] deployed fuzzy logic for algorithm selection in their IPSs. Their work is based on RSSI from BLE beacons, whereby the proposed Fuzzy logic system uses the size of the room, number of available beacons, and the RSSI as crispy inputs in order to perform a fuzzy selection of the most accurate positioning algorithm for each scenario. The results reported that fuzzy selection, with Mandami Type-2 inference, highly improved positioning.
As a second use, various authors integrate fuzzy logic in Fingerprinting methods. For example, Tsai et al. [8] proposed a BLE-Fingerprinting IPS based on Fuzzy logic, whose main goal was to face the harsh fluctuations of RSSI and increase the localization stability. In the Fingerprinting offline phase, the membership functions and three Fuzzy sets (far, medium, and near) were defined based on data collected. In the online phase, a Fuzzy Rule Base was used to match the reference points instead of Euclidean distance. Tomažič et al. [9] proposed a Fuzzy path-loss model based on the Takagi-Sugeno fuzzy model with Gaussian Membership functions to improve Fingerprinting and Particle-swarm optimization methods. In the indoor environment experiments, the authors considered BLE beacons as transmitters and a smartphone as receiver. The proposed approach was tested using fingerprinting (Fuzzy approach to built the RSSI map) and directly into the Particleswarm optimization methods. Considering the Fuzzy model instead of Log-distance path model the localization accuracy was enhanced around 45%. Al-Madani et al. [10] implemented two Fuzzy logic algorithms (Fuzzy type-1 and type-2) over the BLE-Fingerprinting method for indoor positioning as a modification to compute the Euclidean distance. The positioning results showed an improvement from 0.65 m (no Fuzzylogic) to 0.57 m (Fuzzy type-1) and 0.43 m (Fuzzy type-2).
Finally, as in our approach, Onofre et al. [14] used the Fuzzy logic to deal with the accuracy problem of BLE signal strength measurements in an indoor environment. The authors used 4 crisp inputs, determined 23 Fuzzy rules and employed the Center of gravity method as defuzzification technique. The maximum distance between transmitter (BLE beacon) and receiver (LE Sniffer nRF51822) tested was 3 m. Accordance to the experimental results, the Fuzzy logic improved the accuracy and the repeatability. Unlike our approach, the system is not based on Single Input Single Output (SISO)-Fuzzy logic (as it used 4 crisp inputs), uses fixed deployed BLE beacons and hardware-based analysis of BLE signals.
From the aforementioned studies, we can conclude that Fuzzy logic was predominately used as part of Fingerprinting methods, both in the offline and online phases. On the other hand, we also encountered single articles that used fuzzy logic as an auxiliary to evaluate the application scenarios and select the most suitable algorithm for indoor positioning accordingly, and to estimate distance in an IPS using multiple crisp inputs and fixed BLE beacons. To the best of our knowledge, in literature, no IPS has been proposed that uses SISO-Fuzzy logic to adjust for fluctuations in BLE signals and directly determine the estimated distance between two smartphones, based on RSSI.

III. RSSI-FUZZY CLASSIFICATION AS DISTANCE
ESTIMATOR Under ideal conditions, the power density of BLE signals are only attenuated as their waves expand through space. This phenomenon is widely-known as path-loss [15]. Considering this phenomenon, the relationship between BLE-RSSI and the distance between transmitter and receiver can be inferred. However, time-varying conditions in which the BLE signals are propagated add sources of interference, and in consequence, unbalance the relationship between RSSI and distance. In this work, we use a SISO Fuzzy logic-based system to mitigate the uncertainty and inaccuracy in the estimation of the distance under varying environment conditions. Fuzzy logic, as part of Soft Computing techniques [16], is an intuitive and easy to implement approach which simulates human reasoning and decision making to address complex problems, without explicitly requiring mathematical modeling [17]- [19].
Schematically, the used SISO-Fuzzy logic system is shown in Fig. 1. It takes crisp data as input, which are transformed to fuzzy values by the Fuzzyfier, and processed by the Fuzzy Inference Engine according to the fuzzy rules contained in the Fuzzy Rule Base. Once processed, the resulting fuzzy values are transformed back to crisp output value by the defuzzifier. In the next subsections, we explain each of these components, their internal details and how they are applied to adjust distance estimation in BLE-RSSI-based positioning under varying conditions. The Crisp input corresponds to the BLE RSSI (dBm) values collected by the smartphone and the Crisp output to the estimated distance (m) between smartphones (transmitter and receiver). We considered the information of the reference distances, where we gathered measurements (every 1 m from 1 m to 11 m) in LOS conditions, both indoors and outdoors, to define eleven Input Membership functions (explained further on) in order to specify the degree of membership of the Crisp input value to the corresponding eleven fuzzy sets. A similar criterion was to used to define the crisp outputs. Consequently, we labeled the input (I) and output (O) Membership functions as "I 01 " to "I 11 " and "O 01 " to "O 11 ", respectively.
We determined the type and parameters of the membership functions from the empirically collected reference data and its statistical analysis. The input and output Membership functions are the Trapezoidal function for the first and last labels (classes "01" and "11"), and the Triangular function for the remaining ones (classes "02"-"10"). Figure 2 shows the eleven membership functions for the outdoor scenario.
The Membership function is mathematically represented as µ A : X → [0, 1], where A is the fuzzy set and X the set of elements to be mapped. Specifically, the Triangular Membership function is expressed by eq.(1a), which is defined by three values (a < b < c) and the Trapezoidal Membership function by eq.(1b), which is defined by four values (a < b < c < d).
Hereby, the parameters a, b and c for eq.(1a) determine the position of the triangle in each membership function, or more precisely, the position of the three corners of the triangle in terms of RSSI in dBm, see Fig. 2. Similarly, the parameters a, b, c and d determine the position of the trapezoid for eq.(1b). Table I shows the parameter values represented as vectors, both for the indoor and the outdoor scenario for input and output membership functions. These values were determined with the empirical procedure described in Section IV-B.

B. Step 1: Fuzzification
The first step is the Fuzzyfication process (see Fig. 1), which consists of mapping the crisp input, x (the RSSI in dBm), into input membership degrees ([0,1]) for every fuzzy set (classes "01"-"11"). To do so, we use the Membership functions, µ, defined in eq.(1a) and eq.(1b), with the parameters for all reference distances (see Table I). As such, we obtain a vector of membership values for the M(x) = [µ I01 (x), ..., µ I11 (x)], which we call the input Fuzzy set.

C. Step 2: Fuzzy rules application
The Fuzzy logic reasoning of our system is conducted by the Mamdani method, which considers the Fuzzy set input (calculated from a crisp input through Fuzzification as explained in the previous subsection) and the rules in the Fuzzy Rule Base, and evaluates them in order to determine the Fuzzy set output. Concretely, the evaluation uses the Fuzzy implication operator (min) and applies every rule to every element of the input fuzzy set, to generate corresponding fuzzy set outputs, each of which represents the output membership degrees (using a particular rule) based on the input Fuzzy set. The following fuzzy rule is defined for each of the eleven reference distances (i.e., eleven rules in total): the input membership degree to a reference distance is used to calculate the area falling below that degree in the corresponding output membership function. The graphical representation of the rule is provided in Figure 3 using reference distance "01" as illustrative example.  Finally, the Fuzzy aggregation operator (max) is used to combine the outputs obtained for each rule into a unique Fuzzy set output, which graphically represented.

D. Step 3: Defuzzification
The last step of the Fuzzy logic system is the Defuzzification. Once the fuzzy rules are applied, and fuzzy implication and aggregation operations are completed. The Center of Gravity is applied to the resulting area to compute the final distance estimate and, therefore, provide the crisp output.  4 presents an illustrative example of the proposed system. The objective of the example is to illustrate the calculation process for the proposed distance estimator based on the RSSI-Fuzzy classification as well as to explain the system's operation and its components.
The only requirement of the proposed RSSI-Fuzzy classification is to have the input and output membership functions (see Section III-A), along with their parameters, defined. The parameter values for the two scenarios included in this work, indoor and outdoor with a particular set-up, are provided in Table I; we explain the empirical procedure to determine them in Section IV-B for research reputability. To run the proposed system in a new scenario (environment + hardware setup), the versatility of the system allows to intuitively update the parameters of the membership functions, which we have provided, simply by considering basic statistics (Box-plots) of the RSSI signals at different reference distances.
In our example the Crisp input corresponds to the RSSI value of −73.8 dBm. Even though RSSI values are usually integer values, systems using multiple interfaces or applying RSSI averaging to reduce noise may provide RSSI values with decimal part. The first step, fuzzification, consists of mapping the Crisp input value (RSSI value) to the input fuzzy set M(x), applying the eleven Input membership functions (see Fig. 4 step 1). In this particular case, only µ I08 (green), µ I09 (blue) and µ I10 (orange) report non-zero input membership probabilities, with the highest probability (0.84) for µ I09 (−73.8).
In the second step, for the non-zero membership input functions (µ I08 , µ I09 and µ I10 ) and based on the intersection with the −73.8 dBm line, we calculate the area falling under the corresponding membership output functions. e.g. the area of O 09 corresponds to a probability equal or lower than 0.84, the membership degree provided by µ I09 (−73.8).
Finally, in the third step, the areas are overlapped to obtain a single complex area. Then, its center of gravity is computed to obtain the estimated distance, which is 9.25 m in this example.

A. Objectives and experimental setting
Our experiment aims validate the accuracy and robustness of our fuzzy logic-based approach for distance estimation using BLE and RSSI. To do so, we applied our approach using the data we previously collected in two scenarios, the first one outdoors (a parking lot 1 ), and the second one indoors (an office 2 ). Later, we compared it with a standard logarithmic path-loss propagation model for reference. The data sets include 656 (parking lot) and 427 (office) samples and are available as supplementary materials in [20].
Both data sets were split intro training (70%) and test (30%) subsets. For data cleaning, the outlier RSSI values were processed using a moving average filter in the training set and removing samples higher that 3 times the Median Absolute Deviation (MAD) method for the test set.
B. Empirical determination of the parameters 1) Proposed Fuzzy-RSSI system: For the proposed RSSI-Fuzzy classification, the Input and Output Membership functions parameters -shown in Table I are defined in two phases. In the first phase, the statistical information at every reference distance (from 1 to 11 m) is provided by Box-plots. For the Input triangular Membership functions, the values for [a,b,c] are given by the first, second (median) and third quartiles. For the trapezoidal Input Membership functions, the values for [a,d] are given by the first and third quartiles. The value for c (class "01") and b (class "11") are given by the second quartile (median). The remaining values -b (class "01") & c (class "11")are set to guarantee the trapezoids symmetry.
For the Output Membership functions parameters, we equally distribute them over the [1, . . . , 11] range. The highest membership degrees are located in the eleven reference distances and the width of the functions is set to 2 (i.e. c − a = 2 and d − a = 2). In the second phase, the Input and Output Membership function parameters of the first phase are manually finetuned, by testing the input values corresponding to the median, first and second quartile and comparing their output with the expected reference value. In case of large overlap between the Membership functions and/or a large distance error, the Membership function was manually shifted or even skewed to its central value. Finally, due to the increase/attenuation of the RSSI in short and large distances between transmitter and receiver, the Output Membership functions of fuzzy sets ("01" & "02") and ("10" & "11") were re-tuned (changes on vertex angles/small horizontal function shift) to avoid large errors near the distance range boundaries.
2) Traditional Path-loss Model: As a reference system to compare, we used the the Logarithmic distance path-loss model given in (2).
Where RSSI(d) is the RSSI at a distance d between transmitter and receiver; RSSI(d 0 ) is the RSSI at a reference distance d 0 (1 m in our case); and η is the path-loss attenuation factor. The RSSI and distances are expressed in dBm and m respectively. We used the Non-linear Least Squares method over the training subsets to get the values for RSSI(d 0 ) and η. RSSI(d 0 ) = −53 is used in both scenarios and η = 2.1 and η = 1.2 has been set for outdoor and indoor respectively.

C. Results
We have evaluated the accuracy, in terms of absolute error in determining the distance between two devices, for the two assessed models (Fuzzy-RSSI and Path-loss), both for an indoor and outdoor scenario. The results are reported as a Empirical Cumulative Distribution Function (ECDF) plot in Figs. 7 and 8, respectively. Additionally, Table II summarizes in detail, through the Root Mean Square Error (RMSE) values, the results obtained in each of the eleven reference points individually and also the result as a whole for each scenario. For the outdoor scenario (the parking lot), the BLE RSSI signals have low variability (see Fig. 5) and the signal propagation had the expected behavior. The ECDF (Fig.7) and RMSE values show that the proposed RSSI-Fuzzy system has a larger segment of virtually zero error, and generally performs slightly better than the Path-loss model, except in a few cases.
The signals in the indoor scenario (the office) have a strong noise component (see Fig. 6). Under such uncertainty of RSSI signals, the empirical results shown that the proposed Fuzzy-RSSI approach not only significantly improves the general accuracy (RMSE) of the Path-loss model, but it also reduces the presence of large errors in distance estimation. In general, our Fuzzy approach provides an error four times lower than Path-loss. In both scenarios (indoor and outdoor), the presence of large errors in estimating the relative distances is minimised using the proposed Fuzzy-RSSI approach, showing the robustness of our approach. The distances for the Fuzzy-RSSI approach are furthermore limited to the range [−0.7, . . . , 20], whereas the Path-loss model does not define ranges for the estimated distances, and is thus more sensitive to severe outliers.

V. CONCLUSIONS
This paper presented a distance estimation approach based on the fuzzy-RSSI classification of BLE signals transmitted from smartphones as an alternative to the conventional pathloss models approaches. Fuzzy models can deal better with uncertainty when data sources have a strong noise component.
We evaluated the proposed approach in two different environments, one outdoors and one indoors, and compared it with a conventional distance estimator based on the Pathloss model. The results show that the proposed Fuzzy-RSSI model improves the Path Loss model in general. For outdoor scenarios, where the signal is less affected by alterations on the signal, the Fuzzy-RSSI approach shows a larger segment of (virtually) correct estimations, and generally slightly better accuracy except in a few concrete points. For indoor scenarios, where the RSSI has a strong noise component, the proposed Fuzzy logic-based solution significantly and consistently outperforms the path-loss model, with errors on average four times lower than the Path-loss model.
The results have not only demonstrated the suitability and feasibility of the proposed model, but also highlighted the usefulness of fuzzy logic to counteract the uncertainty of RSSI measures, which help us to minimize large distance estimation errors and increasing the robustness of the estimator.
As future work, we plan to create a hybrid distance estimation, using the Path-loss model for near distance and the Fuzzy-RSSI model for the intermediate and large distances. Another idea is to include other sources of data (i.e., light, Inertial Measurement Unit (IMU), Wi-Fi) in the fuzzy logic system to increase the accuracy and self-calibrate the system through additional crisp inputs and a more complete rule sets.