Using Fuzzy Logic to Improve BLE Indoor Positioning System

  • Sérgio OnofreEmail author
  • Bernardo Caseiro
  • João Paulo Pimentão
  • Pedro Sousa
Conference paper
Part of the IFIP Advances in Information and Communication Technology book series (IFIPAICT, volume 470)


Accuracy and precision are key parameters in the definition of indoor positioning systems. We want to provide a mobile robot with the capacity to autonomously determining its location inside buildings, to allow it to autonomously navigate. The solution developed is based on spreading emitter beacons of Bluetooth Low Energy in the building and use location finding techniques to determine the robot’s location. The main challenge is the capacity to obtain accurate readings of signal strength and the low repeatability of readings even under unchanged conditions. To improve the signal strength measurements it is necessary to deal with this imprecision. Our approach is based on the use of Fuzzy Logic to deal with the accuracy problem. Once better signal strength readings are achieved, using this method, approximate distances are calculated based on signal strength and the trilateration method is implemented to provide the location of the mobile robot.


Fuzzy Logic Indoor location techniques Bluetooth low energy Trilateration 

1 Introduction

Indoor location is an emerging market that can be used for commercial purposes, public safety, and military. Commercially it can be applied to track children, people with special needs, help navigate blind people, locate equipment, mobile robots, etc. For military and public safety it will be useful to track prisoners, help policeman, soldiers and firemen navigate inside buildings [1].

Location and outdoors navigation was solved long ago with GPS. The problem occurs when you need accuracy or indoors location. GPS nowadays have an error of about 10 m, radio signals coming from distant satellites don’t work well with obstructed paths and the high-frequency waves bounce around when they hit metal and walls. This technology is therefore not usable on indoor location issues [2].

Actually there are some companies searching and testing solutions using different technologies to find a solution for indoors location. In general, the most important components of the system are location sensor devices that produce metrics of the relative position of a mobile terminal (MT) and a known reference point (RP). Most conventional positioning methods are Angle of arrival (AOA) to estimate direction; received signal strength indicator (RSSI), Time difference of arrival (TDOA) and Time of arrival (TOA) are used to estimate distance [1].

Our goal is to provide a mobile robot (ServRobot1) with a tool to know is location using Bluetooth Low Energy beacons signals.

2 Cyber Physical Systems

The cyber-physical systems (CPS) consider computational components and physical units to cooperate with humans using different technologies. CPS are intelligent, real-time, distributed, networked (wired/wireless) control systems and likely linked in a loop. They can be useful in several fields. CPS design consists of a network of cooperating elements with physical inputs and outputs. It connects computational and physical rudiments to obtain better effectiveness, functionality, security and flexibility [3].

This work is related to cyber-physical systems, by combining physical entities: Bluetooth Low Energy (BLE) beacons, with computational elements that through a BLE signal receptor connected to a computer, allows to process the input values and implement algorithms to build the desired system. The final goal is to locate an autonomous mobile robot in a wireless network in real time that could be adapted in the future to locate other objects like phones or even people. It consists on build a system in real-time with feedback loops where physical processes, in this case the received signal strength indicator from the BLE beacon affect computations and have influence on the robot next moves and upgrade others functionalities by knowing the robot location, it can improve the efficiency, safety, reliability and functionality of the mobile robot.

This project could help the research on efficient and functional indoor location systems contributing for the cyber physical systems development too.

3 State of the Art

3.1 Conventional Positioning Methods

In the next sections, several conventional positioning methods are presented.

RSSI – It is a process used to estimate the distance between the receiver and a beacon. It matches the probability distribution with the strength of the received signals, and estimates the distance using a statistical method. To start a sample of the signal strength is read in different locations, but the environment changes modify the path loss models that enables to repeat the same strength of the received signal. It is necessary an environment precise path loss model to use the location estimate system [4].

AOA – This method is used to measure the direction in a system and it can do it reading the direction of the received signal using two or more antennas on different positions [4].

TOA – It is a time-based positioning technique that measures the signal travel time between nodes [5].

TDOA – This method estimates the time difference of arrival between two signals moving between two reference nodes and the given node [5].

Table 1 compares the accuracy degradation of an indoor location system due to multipath fading and increase of the distance between devices for each positioning method.
Table 1.

Comparison of position methods [5]


Accuracy degradation












3.2 Indoor Location Systems

There are different location determination systems and processes for indoor environments: ultrasound, infrared, electromagnetic, visual location, physical contact and radio frequency systems. We will focus on radio frequency systems.

Bluetooth based systems – Radio hardware (beacons) with Bluetooth low energy protocol. Beacons are spread over surface and the signals that they send can enable devices to determine their location. Some systems use beacons signal to incorporate on fingerprints database, others determine absolute or relative location by measuring distances, trilateration. Furniture and walls hinder signal propagation. Using three beacons is enough but a fourth one will decrease localization errors [6]. Indoor location is challenging because of the reflections and absorptions. Besides Bluetooth Low Energy there are Wi-Fi, RFID, ZigBee and Ultra-Wideband based systems. More details in [7, 8, 9]. Some developers combine multiple technologies like fusing data based on Wi-Fi and Bluetooth. Fusing helps to obtain more accurate results (Table 2).
Table 2.

Radio frequency based systems [10]


Frequency band

Power consumption


Accuracy (meters)

Wi-Fi 802.11

2.4 GHz



5 to 10




Very low

2 to 10

Bluetooth 4.0

2.4 GHz



1 to 2





3 to 5


3.1 to 10.6 GHz




3.3 Location Techniques in Indoor RF-Based Systems

There are two types of techniques to calculate the location using RF-based systems, geometric (traditional) and pattern recognition.

Geometric techniques – calculate positions based on distances between mobile transmitter-receiver and fixed receiver-transmitter. Trilateration – Provides an estimate of the device’s location by using the received signal strength from different transmitters (non-linear). The distance estimation from the transmitters to the receiver is calculated using the relation between distance and signal strength:
$$ Pr = Pt + 20\log \left( { \frac{\lambda }{4\pi } } \right) + 10n \log \left( { \frac{1}{d} } \right) $$

Pt is the transmitters power (in dBm), Pr is the power at the receiver, λ is the wavelength, n is the path loss exponent (n = 2 is free space), d is the distance transmitter/receiver. The distance estimation generates a circle centered on each transmitter, the device will be located where circles coincide. The technique is called trilateration [11]. Triangulation - Uses geometric properties of triangles to estimate the target’s location. More details in [11].

Pattern Recognition techniques – It consists in buildin a signal strength model. To estimate the mobile device’s location is necessary to calculate the match with the signal strength model. It requires two phases: the offline phase, where a map is built after collecting the RF signals from defined location points. And the online phase, where an algorithm is used to find the match between the read signals and the previously collected signals to estimate the device location [5].

Traditional methods are K-Nearest Neighbors, Neural Networks and Probabilistic. More details in [12].

3.4 Fuzzy Logic

Fuzzy Logic is bets fit on under uncertainty, it deals automatically with tolerance for imprecise values. The variables are represented by membership functions, instead of the absolute true or false values. It reproduces the human mind capacity to employ approximate reasoning. In classic logic the decision is binary, true or false, whereas in Fuzzy Logic variables have a range between 0 and 1, of degree of membership towards a fuzzy set [13]. Imprecise inputs can be considered and used as “linguistic variables” denoting values such as big and small, low/medium/high are used in the model. Common membership functions used in Fuzzy sets are triangular, Gaussian, trapezoidal, etc., although triangular (see Fig. 1) is more widely used.
Fig. 1.

Triangular Fuzzy membership function [13]

Figure 2 shows the block diagram of fuzzy logic mechanism. Fuzzification is a procedure that classifies numerical values into fuzzy sets, the rule base contains the IF-THEN rules that represent the linguistic variables. The evaluation relates the IF-THEN rules to the fuzzy sets to get a fuzzy output. The Fuzzification changes crisp data into linguistic values using linguistic variables, membership functions map every element of the input variables onto a membership rate from 0 to 1. The evaluation makes approximate reasoning [13].
Fig. 2.

Fuzzy Logic block diagram [13]

The defuzzification procedure alters the fuzzy output back to the classical output with the control goal. There are three defuzzification techniques normally used, the most widely used is the Center of Gravity method (COG) is identical to the physical calculation of center of gravity in objects, the weighted average of the membership function of the center of the gravity of the area limited by the membership function curve is computed to be the crispest value of the fuzzy values. Besides COG there are Mean of Maximum and Height Methods [13].

4 Development

Our system development starts with the interaction between a BLE transmitter (beacon) and the BLE receptor (sniffer).

Bluetooth Low Energy Sniffer and Beacon

To receive the received signal strength indicator (RSSI) from the beacons a Bluetooth low energy sniffer (Adafruit bluefruit LE Sniffer nRF51822) is used. This device is a USB-to-BLE board that allows the computer to communicate with a BLE enabled device. The Gimbal U-Series 5 proximity beacon is a small, USB powered device that transmits a Bluetooth Low Energy signal that can be detected by other devices, in this case by the Bluetooth Low Energy sniffer. This signal enables the identification of the beacon by the MAC Address. The sniffer captures the RSSI value and with it it’s possible to calculate the distance estimation between the devices.

Obtaining Distance from RSSI Values

The code used by the device Adafruit bluefruit LE Sniffer nRF51822 is written in python and allows to retrieve the RSSI and MAC address of nearby BLE beacons, this project uses that code as start point. To obtain the distance in meters from the received signal strength indicator (RSSI) it was necessary to measure a bunch of RSSI measurements at known distances, then we did a best fit curve to match the data points, this algorithm was developed by David Young in Java. In this work the code was adapted to python language [14].

$$ distance = \left\{ {\begin{array}{*{20}c} {\left( {\frac{RSSI}{txPower}} \right)^{10} \;for\; \frac{RSSI}{txPower} < 1} \\ {0.89976 \times \left( {\frac{RSSI}{txPower}} \right)^{7.7095} + 0.111 \;for \;\frac{RSSI}{txPower} \ge 1 } \\ \end{array} } \right. $$

The variable txPower is the RSSI value at 1 meter of distance, it was calibrated and the obtained value was −87 db. The values 0.89976, 7.7095 and 0.111 are the three constants calculated when solving for a best fit curve to the measured data points. Each 0.95 s a distance reading is received, the main challenge is the capacity to obtain accurate readings of signal strength (and consequent approximate distance in meters) given the low repeatability of readings even under unchanged conditions. The direct signal strength measured by the Bluetooth signal receiver vary in each reading because of physical disturbing factors such as wall reflections and other devices transmitting the same frequency. To improve the measures, two normalizing techniques: “median and average filters” and “Fuzzy Logic” were implemented.

Median and Average Filters

After some tests comparing the real distance measured with a scale and the distance obtained at the program by the sniffer it was detected that the accuracy is bad and has low repeatability of readings. To try to improve the accuracy and the repeatability, a way to discard the absurd values on was developed. First a vector accumulates ten measurements and after that the values are sorted, the extremes are excluded and the four middle values are used to calculate the average. However, as the results were still far from good, since they were imprecise we decided to use another approach. Using Fuzzy Logic to deal with imprecision.

Fuzzy Logic Implementation

To deal with imprecise values we decided to use Fuzzy Logic. This could be a good way to improve the results. The tool used was an open source java library called jFuzzyLogic. This library imports a Fuzzy control language file with the input and output variables and the linguistic terms configured, then checks the rules to return an output variable based on inputs. We take the results of the median process and in the end it will return only one output variable with the final value. For each of the four inputs there are twelve linguistic terms possibilities to do the fuzzification ranging from “less 0.5 m” to “more 5 m”. Then the system will check the rules block with 23 rules and makes the decision (Fuzzy inference). To finish the defuzzification is done and a real value is obtained as output. Considering ten direct distance measures read by the sniffer at 1 meter away from the beacon (real distance), the four middle values are selected as inputs for the FCL file and each of them is fuzzified. Then the system checks the rules block, makes the decision and does the deffuzification to obtain a real value as output. In our test the final distance output is 1.02 m, close to the real distance 1 m. The defuzzification technique, Center of Gravity method was used.

Distance Readings Results

Three different ways to obtain the distance between the BLE beacon and BLE sniffer were tested in an office room without objects between the devices. The first method uses direct distance readings each 0.95 s, the second method applying median and average filters after ten direct readings and third method implements a fuzzy logic inference system after ten direct readings. The BLE beacon was fixed on a power supply and the BLE sniffer connected to a computer was positioned at different distances measured by a scale at 0.5 m, 1 m, 1.5 m, 2 m, 2.5 m and 3 m. The test values were obtained ten seconds after fixating the BLE sniffer position to guarantee receiving a stabilized signal. The following graphics compare the measurements obtained by the three methods (Figs. 3 and 4 and Table 3):
Fig. 3.

Distance estimations at 0.5 m

Fig. 4.

Distance estimations at 2.5 m

Table 3.

Average error for each method at different distances


0.5 m

1 m

1.5 m

2 m

2.5 m

3 m

Direct readings














Fuzzy Logic







5 Conclusions and Future Work

After doing these tests with the three methods some behaviors of the receiving signal were detected. The signal takes some time to stabilize after changing the distance between the beacon and the sniffer. It is necessary to wait some seconds until the values get closer to the real distance. Once the signal stabilizes the repeatability increases. In general as the distance between the beacon and the sniffer increases, the average error of distance estimations increases. That is an expected behavior because the disturbing factors like signal reflecting rise their negative influence as long as the direct signal wave power (the desired one) gets lower.

Comparing the direct readings average error and the estimations after applying median and average filter average error, the results of applying the filter are not as good as expected. That can be explained because even maintaining the sniffer at same fixed position when the distance estimation gets high or low it tends to still get higher or lower with time. The normalizing factor by applying median and average filter excludes the estimations that usually are far from real distance, but due to the trend to the estimation to get high or low with time, it doesn’t improve the average error. In practice the average error obtained by direct readings method is similar to the average error applying median and average filter. Comparing the direct readings average error with the Fuzzy Logic inference system estimations average error, the implementation of Fuzzy Logic reduces the error between real distance and estimation, improving the accuracy and the repeatability. This normalizing method proved to be more satisfying that Median and Average method. It proved to be useful improving the estimation values and Fuzzy Logic inference system was adopted in this project. The next step will consist in implementing the trilateration algorithm after obtaining the estimated distance between three fixed BLE beacons in known positions at x, y coordinates and the BLE sniffer which is in an unknown position and can move.


  1. 1.
    Pahlavan, K., Li, X.: Indoor geolocation science and technology. IEEE Commun. Mag. 40, 112–118 (2002)CrossRefGoogle Scholar
  2. 2.
    New Indoor Navigation Technologies Work Where GPS Can’t - IEEE Spectrum. URL consulted (2014).
  3. 3.
    Reddy, Y.: Cyber-Physical Systems: Survey Cloud-based Cyber Physical Systems: Design Challenges and Security Needs (2015)Google Scholar
  4. 4.
    Park, C., Park, D., Park, J., Lee, Y., An, Y.: Localization algorithm design and implementation to utilization RSSI and AOA of ZigBee. In: 5th International Conference Future Information Technology, pp. 1–4 (2010)Google Scholar
  5. 5.
    Roxin, A., Gaber, J., Wack, M., Nait-Sidi-Moh, A.: Survey of wireless geolocation techniques. In: 2007 IEEE Globecom Work, pp. 1–9 (2007)Google Scholar
  6. 6.
    Akif, M., Mahallesi, E., Ankara, Y.: A bluetooth signal strength based indoor localization methodGoogle Scholar
  7. 7.
    Kaemarungsi, K., Krishnamurthy, P.: Modeling of indoor positioning systems based on location fingerprinting (2004)Google Scholar
  8. 8.
    Liu, Y., Du, H., Xu, Y.: The research and design of the indoor location system based on RFID. 2011 Fourth International Symposium on Computational Intelligence and Design, pp. 87–90 (2011)Google Scholar
  9. 9.
    Fernández, S., Gualda, D., García, J. C., García, J. J., Ureña, J., Gutiérrez, R.: Indoor location system based on ZigBee devices and metric description graphs (2011)Google Scholar
  10. 10.
    Li, H.: Low-cost 3D bluetooth indoor positioning with least square. Wireless Pers. Commun. 78, 1331–1344 (2014)CrossRefGoogle Scholar
  11. 11.
    Liu, H., Member, S., Darabi, H., Banerjee, P., Liu, J.: Survey of wireless indoor positioning techniques and systems. IEEE Trans. Syst. Man Cybern. Part C Appl. Rev. 37, 1067–1080 (2007)CrossRefGoogle Scholar
  12. 12.
    Lin, T., Lin, P.: Performance comparison of indoor positioning techniques based on location fingerprinting in wireless networks, pp. 1–6 (2005)Google Scholar
  13. 13.
    Singh, A.K., Purohit, N., Varma, S.: Fuzzy logic based clustering in wireless sensor networks: a survey. Int. J. Electron. 100, 121–141 (2012)Google Scholar
  14. 14.
    Young, D.: Understanding ibeacon distancing - Stack Overflow. URL consulted (2015).

Copyright information

© IFIP International Federation for Information Processing 2016

Authors and Affiliations

  • Sérgio Onofre
    • 1
    Email author
  • Bernardo Caseiro
    • 2
  • João Paulo Pimentão
    • 2
  • Pedro Sousa
    • 2
  1. 1.Holos SACaparicaPortugal
  2. 2.Faculty of Sciences and TechnologyNOVA University of LisbonAlmadaPortugal

Personalised recommendations