A Bluetooth Low Energy Indoor Positioning System with Channel Diversity, Weighted Trilateration and Kalman Filtering

Indoor Positioning Systems (IPS) using Bluetooth Low Energy (BLE) technology are currently becoming real and available, which has made them grow in popularity and use. However, there are still plenty of challenges related to this technology, especially in terms of Received Signal Strength Indicator (RSSI) fluctuations due to the behaviour of the channels and the multipath effect, that lead to poor precision. In order to mitigate these effects, in this paper we propose and implement a real Indoor Positioning System based on Bluetooth Low Energy, that improves accuracy while reducing power consumption and costs. The three main proposals are: frequency diversity, Kalman filtering and a trilateration method what we have denominated “weighted trilateration”. The analysis of the results proves that all the proposals improve the precision of the system, which goes up to 1.82 m 90% of the time for a device moving in a middle-size room and 0.7 m for static devices. Furthermore, we have proved that the system is scalable and efficient in terms of cost and power consumption. The implemented approach allows using a very simple device (like a SensorTag) on the items to locate. The system enables a very low density of anchor points or references and with a precision better than existing solutions.


Introduction
By 2019, the estimated value of the indoor positioning market will increase to $4.4 billion [1]. The possibility of tracking people's paths in commercial areas or knowing the position of a given asset in an industrial building is becoming of interest for many companies.
Regarding the challenges that positioning systems face in indoor environments, there are many factors that might impair the propagation of the signals. According to [2] these issues are mainly caused by: • Reflection and diffraction around objects (including walls and floors) within the rooms that can cause multipath and fading effects respectively. In the case of BLE technology, its main strength lies in its low cost and low power consumption, even though with an acceptable accuracy (1 m error). However, this technology usually needs additional equipment (deployment of a BLE network) and it has a short range, up to 20-30 m.

•
In the case of RFID systems, its accuracy is the best among all the technologies (error below 0.1 m) within its lifetime (no battery needed). Its main drawback is the short range (below 1 m) and the extensive and expensive installation of large amount of readers to cover large areas.

•
In the case of UWB technology, the most important features are: (1) its accuracy (error below 0.3 m); and (2), its range, up to 150 m, which is the highest among the technologies presented here. However, its main disadvantages are: (1) high power consumption; and (2) high cost.
Although WiFi solutions have been popular in the past, BLE devices offer such a low cost and low power alternative [5], that they have become attractive for places that do not offer WiFi infrastructure. WiFi does make possible the transmission of high data rates, however, the type of data typically required to be sent for a positioning system does not require high throughput, therefore BLEs offering of 1 Mbit/s for their data transmission are acceptable. Consequently, BLE represents a cheaper and more energy-efficient option to implement indoor-outdoor detection and position applications (by means of systems like BlueDetect [33]) than WiFi solutions.
Fast fading or multipath effects have a special impact on the propagation of BLE signals, since the indoor environments contribute to RSSI fluctuations. In [18], an analysis that shows that the BLE signals suffer from a −30 dBm drop caused by the multipath effect was presented. Focusing on this fact, the multipath attenuation is not constant and it can vary at any distance without any pattern. All of the effects mentioned before make it difficult to model an indoor mobile radio channel, because the channel varies significantly with the environment. Therefore, in order to use the relationship between distance and RSSI for and IPS, it will be necessary to understand and deal with all the fluctuations of the signals so that a precise system can be implemented.
As regards IPS with BLE, we should take into account that this technology usually uses RSSI to estimate the location. The authors in [6] detailed the reliability of this assumption. They compared a set of different mathematical methods, such as moving average method or weighted average method, with a theoretical reference curve, in order to verify the reliability of RSSI measurements. Their experiments show that considering RSSI values as the only input to reliably compute the location of a node is not enough. In addition, they state that when using trilateration techniques, both antennas, sender and receptor, must be isotropic.
In this paper, we propose and present an implementation of an IPS that uses BLE technology with CC2650 SensorTags [34,35] as the devices sending BLE beacons, Raspberry Pi as receivers with Adafruit sniffers [36] to get the BLE beacons, and a server platform in charge of processing the distances. Our main goal with this implementation is to develop a complete IPS with low cost and high accuracy independently of the environment the system is placed on. In order to do so, we have defined and implemented the following features:

•
The use of channel diversity as a way of mitigating the effect of fast fading, as well as the effect of interferences during RSSI measurements. Instead of choosing only one BLE communication channel, we use the three BLE advertisement channels (Channel 37, Channel 38 and Channel 39) available to send BLE beacons. They are sent in small lapses of time (the three advertisements in 3 ms intervals), so that channel characteristics are quite the same, and then the effect of fast fading can be minimized by combining them. After that, we compute the channel having the best accuracy in terms of distance-RSSI, and use that one for positioning calculations. By the knowledge of the authors there is no other proposal using this approach and achieving such an accuracy.

•
The use of a trilateration method based on weights. Trilateration works perfectly when the measurements taken converge to a single point. However, in most of the cases we have an area of possible locations instead of a single location point. Our proposal improves the accuracy of trilateration by considering as more reliable the information provided by the closest receivers to the sender and move the estimated position to the position that receiver suggests.

•
The use of Kalman filtering (KF) to avoid incoherent computation of the location. Sometimes, we may get wrong RSSI measurements leading to wrong and very unlikely estimated positions. KF is a well-known method to help reduce the impact of wrong measurements on the system.
The estimation of the cost in an IPS is affected by several factors. There is the infrastructure, the installation and the maintenance costs. In the most commonly used applications, where the item to be tracked is a person, or better said the smartphone of a person, the infrastructure to be deployed is a set of beacons or anchors that can be battery powered and that do not require any connectivity. In this use case, the device tracked is costly, requires connectivity and the batteries have to be recharged quite frequently. If this solution is adopted to track objects, we can say that the infrastructure cost depends on the area to provide service and the number of objects or items to be tracked. A density of one beacon every 20 square meters with a precision between one and two meters is common. The installation cost is low since no connection or main power is required, but the maintenance cost is high since the recharging of batteries in the objects to be tracked is required. Moreover, the calibration of the propagation environment is needed (it is common to use fingerprinting). In the system we propose, the cost of the infrastructure depends on the coverage area and the number of devices also, but in a different manner. In our case, the device to be tracked is similar in cost to the beacons used in the previous example, and ranges from 15€ to 30€ depending on the battery size (the system has low power consumption). The devices that are fixed and receive the beacons require three BLE radio interfaces and a system with Ethernet or WiFi connectivity. For our setup, the cost is around 150€ per device, assuming that they are connected to the power mains. The density of these devices that are fixed and receive the beacons can be low, due to the radio processing technique we employ (BLE), being around one node every 200 square meters for a precision of one to two meters. The system does not require frequently recharging the battery, and no periodic calibration is needed. Using a different radio technology for implementing tracking is possible. One interesting candidate is UWB, specifically the one based on IEEE802.15.4a. In this case, and assuming the most common method, the device to be tracked requires a device that costs between 100€ and 150€, and a set of fixed devices that should be powered and connected to the network, with an estimated cost of 120€ each. The density of fixed devices is of one every 600 square meters. The precision in this case can be between 0.5 and one meters. The system does not require calibration, but, as the power consumption is significantly higher than with BLE, the battery of the devices to be tracked must be replaced/ recharged quite frequently. The figures we have provided show that if we have a large number of devices to be tracked, which should work unattended our proposed solution is the best in terms of cost.
The rest of the paper is organised as follows: Section 2 presents the state of the art of WiFi and BLE IPSs. In Section 3 we detail our implementation. In Section 4 we discuss the used methodology and the theoretical basis of the implementation. Also in Section 4 we present the tests carried out in the different scenarios, and the corresponding results. Finally, we present the conclusions of the study, summarising the performance of the system, in Section 5.

Related Work
Most of the literature refers to systems using either BLE or WiFi technologies, since they are the ones that perform better in terms of quality and cost. Furthermore, the most common way to estimate the position of a device in almost all the systems is by means of RSSI. In the following sections, we present the related work taking into account the main technique used in each paper and the comparison with our proposal. In most of the research works, beacons refer to the fixed anchors or references that send the beacon signals to be received by the device to be tracked. In our proposal, beacons are the devices that we want to track, and that send the beacon signal.

Fingerprinting Approaches
One of the most common methods of positioning is by using a fingerprinting algorithm. A first approach of IPS with BLE and this technique is described in [19]. In the paper, the authors describe a massive deployment of fixed BLE beacon devices in a room, with around 0.8 m distance between them, to ensure a good location of the mobile node being monitored. The main goal of the research was to be able to decide if a BLE device is in the room or not. Although they achieve this objective, we consider a disadvantage that the cost of the deployment is high, and that an RSSI template matching method like fingerprinting is used. The average result between device position and estimated position is 2.4 m.
In [20], the authors proposed another system using the fingerprinting technique. Their system achieves a position error lower than 1.58 m when walking from a fixed position to another. It uses a smartphone as the device to capture the BLE beacons. The main drawback of this solution is the fingerprinting method, which requires intensive offline measurement to characterize the environment. There is another approach where authors use fingerprinting [21], reaching an estimated error of 4.12 m 90% of the time. Those results are not good if we take into account the extensive characterization of the environment that is needed. Another conclusion they reach to is that the orientation of the BLE device (i.e., the directivity) is an important factor.
In [29], the RSSI of the different channels is processed separately, and its data is kept in a database that was later used for fingerprinting. The scenario used was a corridor.
The authors in [22] propose a combination scheme of BLE and WiFi fingerprinting obtaining an enhanced estimation position. Results show an accuracy of 2.33 m at the cost of having to deploy both BLE and WiFi networks. In [23] we find the opposite: WiFi fingerprinting makes the roughly position estimation and the BLE is in charge of enhancing the accuracy of the system. The results are promising at the cost of duplicate BLE and WiFi devices.
In [37] the authors make a comparison between BLE with particle filtering and fingerprinting. Their results show that fingerprinting outperforms particle filtering in a 1.5 m × 12 m corridor, but particle filtering outperforms fingerprinting with an accuracy of less than 4 m in 90% of time in an 8 m × 6 m room.
In [25], the authors monitored the forty BLE channels using a spectrum analyser. A BLE scanner was also used to listen to the three advertisement channels. They used fingerprinting-based techniques and the tests were performed in two environments: an anechoic chamber and an office. The conclusion they achieved was that the results for both scenarios were very similar.
There are other authors who analyse the number of devices that should be deployed to improve the accuracy of the IPS system. In [26], the authors provided a study of BLE fingerprinting using beacons distributed around 600 m 2 to calculate the position of a device. In this case, the conclusion is that the more beacons were deployed, the more accurate the calculated positions are.
In [30] the advertisement channels are treated separately when the measurement of the RSSI is done. The authors develop a separate channel advertising scheme to measure RSSI on each advertisement channel. The technique consists in putting a mask on two of the three channels. For this research, the fingerprinting method was also used, an individual database for each of the advertisement channels was build. In the estimation stage, the RSSI values captured (one for each channel) were compared to the ones kept on each of the individual databases, in order to estimate the locations. The RSSI used to build the database were selected by calculating the mean of a series of RSSI values captured in the desired position. Tests were performed in corridors where four beacons and two receivers were deployed. The results showed a high number of errors due to the fact that, with the fingerprinting technique, the position can only be calculated if the user is inside the positions saved on the database. The authors indicated that the system proposed had an accuracy of 2.56 m at 90% of the time with one beacon each 9 m. The negative side of this study, and all the ones that use the fingerprinting method, is the fact that a characterization process needs to be performed to build the database, as also shown in [31], where authors include deep learning with its corresponding training phase.
In [28] the authors conclude that the number of BLE beacons is crucial for accuracy purposes. Moreover, they compare the accuracy of using only one BLE advertising channel and the accuracy when using the mean over all the channels, to conclude that considering the information of all the channels increases the probability of a good position estimation. In [32], researchers try to solve the problem of environment characterization for fingerprinting approaches. To do so, they use what they call Dynamic RSS feedback algorithm to characterise the environment, using part of the measurements. They achieve an estimation error of 1.5 m in a cafeteria without considering obstacles, and 2.3 m when considering them. Researchers in [24] highlight the importance of the transmission power settings on beacons, and how changing them can help avoiding refractions and multipath. Another paper concluded that there is an important relationship between the number of installed beacons and their positioning with the accuracy of the system [27]. The authors estimated a practical path loss model using four beacons. The measurements were taken during a minute at different reference distances from one to 13 m. For the distance calculation, the Log-Distance Path Loss model not considering the shadowing effects was used. The path loss exponent was characterised for the environment.
In [18], the authors carried out a more theoretical analysis also using a fingerprinting method. They provided a comparison between the BLE and WiFi fingerprinting methods considering physical aspects. Tests were performed in a corridor, where no obstacles were present. To mitigate the multipath effects, the mean of the RSSI values of the captured data were calculated. They concluded that processing data from different channels gave better results than doing it with only one. They demonstrated that BLE fingerprinting method achieves an accuracy of less than 2.6 m in 95% of the time when walking in a room, much better compared to WiFi accuracy, which is about 8.5 m, 95% of the time. Again, the authors reveal the most important drawback of any fingerprinting method: degradation of the performance over time due to environment changes.

Non-Fingerprinting Approaches
In [7], the authors analyse the energy consumption of using BLE tags as beacons, and conclude that it is one of the main advantages of the devices. They also consider the necessity of post-processing the RSSI measurements due to the dropping accuracy for distances larger than 3 m. Another interesting study is done in [38], where the authors compared the accuracy of signals at different frequencies (WiFi 2.4 GHz, BLE channel frequencies and 5 GHz). The goal is to detect the floor where a user is, and to estimate his/her position, but the results are poor, especially for 5 GHz signals. The researchers in [8] describe the problem related to RSSI sensibility to receivers, and propose a location scheme based on advertising beacons with different transmission power levels to improve the coverage of the signal and to decrease the location error.
In [9], the authors propose an equation to enhance the accuracy of the distance when BLE beacons are used. Instead of using the already known propagation models, the authors take the RSSI values captured and, accordingly, they implement a fitted distance curve to perform the distance calculation. The equation they propose is only useful for the analysed environment. The results were not favourable since they were not able to obtain accurate positions.
An example of a commercial indoor positioning system is presented in [10], in which the authors point out it to be an accurate and a robust positioning and tracking system using commercial mobile devices with an integrated feature of route finding. In the analysis, the beacons with the strongest RSSI measurements from a grid are taken. The data is saved on the database (MAC and position of the beacon). Iterative Least Squares Trilateration (LST) is applied to obtain the position. The disadvantage of this proposal is that it requires a learning phase.
A different technique called stigmergy was introduced in [11]. The principle is that the trace left in the environment by an action stimulates the performance of the next action. Applied to IPSs, it takes into account the previous states of different nodes being tracked to estimate the current position of the present node. It also uses the Min-Max localization algorithm. This algorithm maximizes the minimum gain of a system when we do not know how the system will behave. In this case, it minimises the positioning error when we have fading in the channel. Min-Max combined with the mentioned stigmergy method leads to acceptable location accuracy with a position error lower than 1.8 m during 75% of the time when moving around a room. However, the solution uses of a large amount of BLE beacon devices, increasing the overall cost of the solution.
In [12], the key point is the use of several antennas for RSSI stabilization. Taking into account the high dispersion on RSSI values due to refractions, fading and shadowing, among others, the research considers the use of multiple antennas to mitigate this problem. Furthermore, the research states some interesting RSSI combination techniques such as Equal Gain Combiner, i.e., the mean of the RSSI obtained at the different antennas, or the Maximum Ratio Combiner (MRC), which weights each RSSI depending on its signal quality. The research concludes that this method, MRC, is the one achieving the best results on RSSI stability.
In [13], its authors introduced a KF to improve the accuracy in the position calculation. The authors develop an Android app to locate a user inside a building. The key point of the research is the use of KF as a way to reduce RSSI fluctuations. The authors state that KF greatly helps to obtain a stabilized RSSI they use to accurately locate the user. However, they are still unable to locate the exact position of the user inside a room.
Finally, we find some different approaches for indoor localization. In [17] the main proposal is adaptive ranging, a device to device communication scheme to obtain information about the environment and use the information to select the best parameters for the propagation models. Additionally, the authors introduce multi-lateration along with particle filter, to estimate the final position. The authors in [39] use BLE for activity recognition, relating the location of the user with a particular activity.

Similar Studies to Our Proposal
Projects that use a similar architecture to the one proposed in our paper can be found in [5,14,15]. In [5] the authors analyse the operation of BLE tags for IPSs. They conclude that their low cost makes them attractive for the deployment of IPS. The authors in [14] show the usage of CC2650 SensorTags to implement an IPS in a 12 m corridor. Their positioning calculation results offered low accuracy, but they stated that this BLE tag are ideal for IPS, since they not only allow broadcasting RSSI values, but they can also be used to control environmental variables (temperature and pressure) with low cost. In [15], the authors propose a smoothing algorithm to decrease the effects of the environment on the RSSI values by locating a device using also CC2650 SensorTags. A database with the captured RSSI data was build and used to characterise the path loss exponent to the environment. They calculated the distance to the different tags and used trilateration as the location algorithm. The testing scenario was a wide space with metal and wood obstacles in which four BLE tags were fixed. The authors stated that the accuracy of their system was high (error of less than 1.162 m). These results were obtained after doing the characterization of the environment, which is a process that complicates the deployment of the system. The research in [16] has a similar structure than the one presented in our paper. However, the main difference with our work is that they use devices with BLE modules as advertisers and a mobile phone as a receiver. We use BLE tags as advertisers and Raspberry Pi with the same BLE modules as receivers. Another difference is that the authors propose a system using BLE modules at fixed positions within KF to filter the RSSI. In addition to filtering, they use trilateration and dead reckoning as algorithms to locate the node. Additionally, they integrate those algorithms into what they call "Kalman-based fusion". The results of their experiments show that trilateration and Kalman-based fusion have the best performance of the three methods (trilateration, dead reckoning and Kalman-based fusion), with an error below 0.75 m. However, they consider a corridor whose first 6 m have a width of 2.3 m and a height of 2.65 m and after that the width is increased to 3.6 m, which is pretty small considering real environments, and they place the BLE modules very close to each other, increasing the final cost of the solution. Beyond accuracy, researchers also state advantages and disadvantages between the methods. Regarding precision, trilateration and fusion methods achieve a nearly constant error while when using dead reckoning, which requires no additional hardware, the error grows with time. Table 1 summarises some of the studies presented in this section, including a comparison of some relevant research with the implementation we present in this paper. From the research presented in this section we can reach some important conclusions. Some of the studies mentioned before characterized the environment in order to obtain a higher accuracy in their results. This characterization was done through the implementation of a fingerprinting method or through the characterization of the propagation model variables. The problem with characterization is that resulting systems can only be used in the scenario where the characterization was performed. They cannot be immediately deployed in other scenarios because a learning phase is always needed to collect all the relevant data. This means that an extra investment of time and resources will be necessary. Another important aspect that stands out in most of the researches, is that their tests were performed in corridors without obstacles where the results will always be better in absence of obstacles and with better signal propagation.

Comparison of Related Work Studies
The system we propose does not require the characterization of the environment, and it has been tested in different scenarios to show that we have consistent results that can be extrapolated. Regarding the use of BLE tags over beacons in [5,14,15] we were able to see the advantages that come with the use of these devices: high accuracy, low power consumption, low price and different applications. As it was mentioned, with a BLE tag an IoT deployment that calculates the position and other environmental variables could easily be implemented.
In this paper we present an implementations of a BLE IPS that offers high accuracy in the positioning calculation, while using a low cost and energy efficient device.

Proposed IPS BLE Based System
The objective of the system proposed is to track the position of a device by means of BLE in indoor environments. In order to do so, the system places L receivers (BLE modules) in fixed positions, while the senders (BLE SensorTag modules) move around the scenario. These senders represent the devices that are being tracked. The BLE SensorTag modules act as BLE beacons.
Regarding the receivers, three measurements are needed, in order to apply the trilateration method so that a minimum of three receivers is mandatory for each room.
As we mentioned in the introduction, our main goal is to deploy a full working system with low cost and low error. We define the error e as the euclidean distance from the estimated position p e to the real position, p r : where the subindices x and y correspond to the x and y axis, respectively. To improve the accuracy, we propose the use of frequency channel diversity, a weighted trilateration method and Kalman filtering.

General Overview of the System
The BLE indoor positioning system is composed of the elements shown in Figure 1. The first element is one or several senders (BLE SensorTags), who send the BLE advertisements, therefore the senders are acting as BLE beacons. The second element is a set of at least three receivers. Each receiver is a Raspberry Pi with three sniffers, in order to listen the three BLE advertisements channels (Channel 37, 38 and 39). Each sniffer is programmed so it only processes one channel advertisement. Finally, a platform (server) is needed to receive the distances computed by each receiver to estimate the current position of the sender nodes (BLE beacons).
As a sender, the SensorTag CC2650 [34,35] an IoT device developed by Texas Instruments is used. It has sensors for temperature, humidity, pressure, magnetometer, gyroscope and accelerometer, which make it a powerful tool for many applications. In our system, the SensorTag CC2650 is the one in charge of sending the BLE beacons. For each time interval (time between advertisements, that can be configured), this device transmits the beacon messages (non-connectable advertisements) through each of the channels (37, 38 and 39) sequentially, within an interval of 3 ms [40]. Therefore, the changes of RSSI in each channel are only due to the frequency used. The messages sent in the same beacon interval (one for each channel) have the same counter ID so that the receiver can identify them to apply channel diversity accordingly. Every sender has a unique MAC address used to differentiate messages from different senders.
can identify them to apply channel diversity accordingly. Every sender has a unique MAC address used to differentiate messages from different senders. Regarding the sender, firstly we have to take into account the directivity of the antenna of the BLE Tag. Even though the datasheet shows it is almost omnidirectional, tests that we performed showed that there is a difference of up to 8 dB in some cases. For a system that fully relies on omnidirectional directivity, this is a huge drawback. Secondly, the transmission power of the device, can be set up to 5 dBm maximum, while the BLE standard allows it up to 10 dBm. When dealing with environments full of people, walls and interferences, 5 dBm are not enough, in which case we must increase the number of receivers.
The SensorTag CC2650 has been programmed using the TI Code Composer Studio to send advertisement beacons each 100 ms at maximum power of 5 dBm. Moreover, it has been programmed to detect if the device is moving or not. In the first case it keeps sending beacons at the same rate, but in the second case it changes the frequency to beacon every 5 s instead of 100 ms to save battery.
As receivers, we used Raspberry PI (RPi) with three Adafruit sniffers [36] in each, responsible for sniffing the beacons sent by the senders in channels 37, 38 and 39. As we devote one sniffer per channel, the sniffer is continuously listening the channel to decode any transmission. As every advertisement has the sequence number introduced by the sender, the time of arrival to the sniffer is not relevant to differentiate advertisements. The RPi's are programmed in Python, to turn on the sniffers and configure them to listen to a particular channel in order to take advantage of the channel diversity. When beacons are received, the RPi runs a script, computes the distance to the sender and sends the information to the platform. In the rest of this section we detail how we obtain an accurate position from the received RSSI form the BLE beacon.
The Adafruit sniffers are low cost BLE devices. These modules are based on the Nordic nRF5182 BLE chipset with relatively poor RSSI measurement accuracy (max. ±6 dB [36]). Comparing this value with other devices, we can see that it is a common value, for example, the CC2650 BLE chipset [35] has a typical value of ±4 dB and others like the Cypress PSoC 4XX7_BLE family [41] have a typical value of ±5 dB. The poor RSSI measurement accuracy can affect the overall RSSI accuracy of the system, and is another reason to design and implement other methods than can improve the accuracy on the positioning system. Moreover, accuracy on BLE beacon power is another issue to take into account in overall accuracy. In our system both effects are not a critical issue, since both senders and receivers can be calibrated. In others systems, for example, when receivers are mobile phone based, this calibration cannot be performed.
The system uses the platform to estimate the position of each of the senders according to the information received from the receivers. First of all it creates a socket connection with each receiver, identified by its MAC address. Then it listens to the incoming information from the receiver, which sends to the platform its distance to each sender. In order to keep tracking the different senders without crossing of information, all of the senders are in turn identified by their MAC address as stated before. Thanks to this, the system is able to, both, keep the track of different devices, and use Regarding the sender, firstly we have to take into account the directivity of the antenna of the BLE Tag. Even though the datasheet shows it is almost omnidirectional, tests that we performed showed that there is a difference of up to 8 dB in some cases. For a system that fully relies on omnidirectional directivity, this is a huge drawback. Secondly, the transmission power of the device, can be set up to 5 dBm maximum, while the BLE standard allows it up to 10 dBm. When dealing with environments full of people, walls and interferences, 5 dBm are not enough, in which case we must increase the number of receivers.
The SensorTag CC2650 has been programmed using the TI Code Composer Studio to send advertisement beacons each 100 ms at maximum power of 5 dBm. Moreover, it has been programmed to detect if the device is moving or not. In the first case it keeps sending beacons at the same rate, but in the second case it changes the frequency to beacon every 5 s instead of 100 ms to save battery.
As receivers, we used Raspberry PI (RPi) with three Adafruit sniffers [36] in each, responsible for sniffing the beacons sent by the senders in channels 37, 38 and 39. As we devote one sniffer per channel, the sniffer is continuously listening the channel to decode any transmission. As every advertisement has the sequence number introduced by the sender, the time of arrival to the sniffer is not relevant to differentiate advertisements. The RPi's are programmed in Python, to turn on the sniffers and configure them to listen to a particular channel in order to take advantage of the channel diversity. When beacons are received, the RPi runs a script, computes the distance to the sender and sends the information to the platform. In the rest of this section we detail how we obtain an accurate position from the received RSSI form the BLE beacon.
The Adafruit sniffers are low cost BLE devices. These modules are based on the Nordic nRF5182 BLE chipset with relatively poor RSSI measurement accuracy (max. ±6 dB [36]). Comparing this value with other devices, we can see that it is a common value, for example, the CC2650 BLE chipset [35] has a typical value of ±4 dB and others like the Cypress PSoC 4XX7_BLE family [41] have a typical value of ±5 dB. The poor RSSI measurement accuracy can affect the overall RSSI accuracy of the system, and is another reason to design and implement other methods than can improve the accuracy on the positioning system. Moreover, accuracy on BLE beacon power is another issue to take into account in overall accuracy. In our system both effects are not a critical issue, since both senders and receivers can be calibrated. In others systems, for example, when receivers are mobile phone based, this calibration cannot be performed.
The system uses the platform to estimate the position of each of the senders according to the information received from the receivers. First of all it creates a socket connection with each receiver, identified by its MAC address. Then it listens to the incoming information from the receiver, which sends to the platform its distance to each sender. In order to keep tracking the different senders without crossing of information, all of the senders are in turn identified by their MAC address as stated before. Thanks to this, the system is able to, both, keep the track of different devices, and use different receivers, at the same time. We use C as the programming language in the platform to maximize performance and scalability. The number of RSSI samples that we consider in each position calculation, as well as how often we update the sender position is a system parameter that can be tuned depending on the application requirements.

Channel Diversity
As BLE transmits in three advertisements channels (37, 38 and 39), the receiver checks the RSSI in the different channels and applies a combination scheme explained later to obtain the best results, taking advantage of channel diversity to improve the performance of the system.
In our system, the BLE Tags send advertisements for the three BLE channels, 37, 38 and 39. All these advertisements are identified by the MAC of the sender and the counter ID for channel diversity. In reception, the Adafruit sniffers capture the different frames and each RPi extracts sniffers frames, and insert them into a circular matrix for each identified sender (we use the MAC of the sender to this purpose). Table 2 shows the circular matrix of one receiver for one specific sender.
The RSSI values in each row correspond to the counter ID, so that we can apply channel diversity. In each performed test we will specify the size of the matrix and how we use this matrix to estimate the position. Due to transmission errors, some rows are not completed and can have only one or two values.

Combination Algorithms
Unlike all the approaches we reviewed in Section 2, in the present paper we will use channel diversity as a way of improving performance. We could select, either randomly or using some scheme, a particular advertisement channel (Channel 37, 38 or 39) and use it as the reference. Nevertheless, we think we can use all the information we have about the channels and combine them in either of the following ways: • Select the one providing the biggest RSSI value (biggest algorithm). In this case we consider as the best channel the one whose related RSSI is the biggest among all the channels. In other words, it takes the RSSI of the channel that performs better: • Take the mean between all the channels (mean algorithm). Now we compute the mean value of the RSSI values of the three channels. Since we are using propagation models, we could get closer to a model by taking the mean instead of only using one channel: • Obtain a RSSI value from the Maximum Ratio Combining (MRC) algorithm (MRC algorithm). This approach is to weight the channel in such a way that, when combining them, we trust more the ones with bigger RSSI values than the ones with smaller values, but we still take these into account in the final RSSI computation. The RSSImin value in the numerator has been chosen according to the sensibility of the channel sniffers [36]:

Distance Estimation from RSSI
Once we have selected the optimum RSSI measurement using channel diversity, we need to calculate the corresponding distance from the sender to the receiver. We have selected three propagation models [18,42,43], looking for the most accurate one to estimate the distance (d) from the RSSI value. The first one is Log-Distance Path Loss model with shadowing showed in Equation (5), valid for distances d > d 0 : where RSSI(do) is the RSSI at a reference distance d 0 = 0.8 m (calculated with the free space propagation model), the parameter n is the path loss exponent and Xσ zero-mean Gaussian distributed random variable with standard deviation that attempts to compensate the random shadowing effects. The parameters n and Xσ have been chosen according to the different scenarios and following the recommendations of [42]. The second one is the International Telecommunication Union (ITU) model for indoor environments showed in Equation (6): where f is the frequency in MHz, N is the distance power loss coefficient and P f (n) the floor loss penetration factor. N and P f (n) have been chosen according to the different scenarios and following the recommendations of the ITU [43]. The third one is the empirical model shown in Equation (7): where A is the empirical measured RSSI at a distance of 1 m between sender and receiver considering Line-of-Sight (LOS), n is the path loss exponent. The empirical model relies on the characterisation of the scenario. Even though the idea of our research is not to use any type of characterisation to avoid the disadvantages it implies (constants calculation, changes on the environment, etc.), we have considered this model since it has not a strong characterisation and will provide us a reference performance level. In our case, we compute A as the RSSI at a distance of 1 m from the sender to the receiver, which we consider to almost be invariant, as both, sender and receiver, are really close one another, and the conditions cannot affect much at that distance. A comparison between all the models is presented in Section 4.

Weighted Trilateration
Once we have the estimated distance from the sender and each receiver, we must next estimate the position of the BLE device. As we stated before, mathematical trilateration is not always possible since there is not always a single intersection of the three estimations but rather an area of possible locations. In this paper we present a method that calculates the location by trusting more in the measurements from the devices that are estimated to be closer to the sender. We call the method weighted trilateration. It can be used with L receivers, being L greater or equal to 3, since we need at least three distances for trilateration. When more receivers are placed, we consider only the three receivers whose calculated distance to the sender is the smallest, according to our approach of trusting more the devices closer to the sender. The use of more than three receivers improves the accuracy of the system. Given three different measurements (i.e., distances), r 1 , r 2 and r 3 , from receivers R1, R2 and R3, to the sender S, we calculate the associated pair-wise weights between R1, R2 and R3 as follows: Depending on the case of trilateration we move from the initial estimated point, which is in many cases the middle point in the probable location area, to the receiver that is closer to the sender, that is, the one which provided the smaller distance d to the sender S, a distance proportional to the weights calculated in Equation (8).
In order to clarify the method, we explain the main cases we may face when dealing with location computation using trilateration with three obtained distances.

•
Circles intersect at one single point: The ideal case is shown in Figure 2, where all the circles intersect in one point.
Depending on the case of trilateration we move from the initial estimated point, which is in many cases the middle point in the probable location area, to the receiver that is closer to the sender, that is, the one which provided the smaller distance d to the sender S, a distance proportional to the weights calculated in Equation (8).
In order to clarify the method, we explain the main cases we may face when dealing with location computation using trilateration with three obtained distances.


Circles intersect at one single point: The ideal case is shown in Figure 2, where all the circles intersect in one point. We can see in Figure 2 that circles C1, C2 and C3 intersect at point P. For these circles, we have the following set of equations: where 1 , 2 and 3 are the radius of the circles C1, C2 and C3 respectively, and the tuples ( 1, 1 ), ( 2, 2 ), and ( 3, 3 ), are the centre of the same circles. In the case we have L receivers, the set of 3 equations of (9) becomes a set of L equations from which we take the three equations related to the receivers closer to the sender.
When the three circles intersect in one point, the set of equations in (9) can be solved, leading to one single point P = (x, y) given by: We can see in Figure 2 that circles C1, C2 and C3 intersect at point P. For these circles, we have the following set of equations: where r 1 , r 2 and r 3 are the radius of the circles C1, C2 and C3 respectively, and the tuples (x 1, y 1 ), (x 2, y 2 ), and (x 3, y 3 ), are the centre of the same circles. In the case we have L receivers, the set of 3 equations of (9) becomes a set of L equations from which we take the three equations related to the receivers closer to the sender. When the three circles intersect in one point, the set of equations in (9) can be solved, leading to one single point P = (x, y) given by: In this case there is no need to compute any weights since there is only one possible location.
• Circles intersect in an area: In the case shown in Figure 3, there is not a single point P but an area.
In this case there is no need to compute any weights since there is only one possible location.
 Circles intersect in an area: In the case shown in Figure 3, there is not a single point P but an area. In order to minimize the error we propose the location as the centroid of the triangle formed by the three points P1, P2 and P3: = 1 + 2 + 3 3 plus an adjustment based on weights. After computing the middle point between them (point MP), we take the intersection point related to the closest receivers to the device being tracked, that is, the intersection of circles C2 and C3 at point P2 (these circles have the minimum radius). Then, we go from MP to P2, the distance between them multiplied by the calculated weight using the distances of the closest receiver (RPI in circle C3) and the further one (RPI in circle C2). We consider the distance 3 of C3 instead of the distance 1 of C1 because, although both intersect in P2, C3 has smaller radio and therefore we trust it more: being θ the angle of the line between points and the x axis, and d the distance from MP to P2. Thus, when the radius of the further receiver goes to infinite, but it still intersects, the weight is In order to minimize the error we propose the location as the centroid of the triangle formed by the three points P1, P2 and P3: plus an adjustment based on weights. After computing the middle point between them (point MP), we take the intersection point related to the closest receivers to the device being tracked, that is, the intersection of circles C2 and C3 at point P2 (these circles have the minimum radius). Then, we go from MP to P2, the distance between them multiplied by the calculated weight using the distances of the closest receiver (RPI in circle C3) and the further one (RPI in circle C2). We consider the distance r 3 of C3 instead of the distance r 1 of C1 because, although both intersect in P2, C3 has smaller radio and therefore we trust it more: being θ the angle of the line between points and the x axis, and d the distance from MP to P2.
Thus, when the radius of the further receiver goes to infinite, but it still intersects, the weight is 0 and we choose P2 as the most probable point. When we estimate the same distance from all the receivers to the sender, the weight is equal to 1 and we choose the middle point as the estimated position. Using this method we take into account the information provided by all the receivers and we rely more on the closest receiver to the device.

•
Two circles intersect in an area, the other does not intersect: This case is shown in Figure 4.
Analysing RSSI values, we estimate the distance from the sender and each receiver. This estimation is based on RSSI by applying a propagation loss model that provides a circular area centred at the receiver. The RSSI can be affected by multipath, and so the receivers can estimate the sender is closer that it really is, therefore, circles may not intersect. position. Using this method we take into account the information provided by all the receivers and we rely more on the closest receiver to the device.
 Two circles intersect in an area, the other does not intersect: This case is shown in Figure 4.
Analysing RSSI values, we estimate the distance from the sender and each receiver. This estimation is based on RSSI by applying a propagation loss model that provides a circular area centred at the receiver. The RSSI can be affected by multipath, and so the receivers can estimate the sender is closer that it really is, therefore, circles may not intersect. Again we face a situation in which there is not a single point. Furthermore, now choosing the middle point between P1 and P2 as the best estimation is not the optimal solution, because we would not take into account the measurements of the receiver on circle C2. Instead, we calculate points P1 and P2. Then, we obtain: where: and 1 , 3 are the radius of C1 and C3 respectively and , , are the coordinates x and y of the centre of the circle Ci.
Once P1 and P2 are calculated, the distance between the centre of C2 and these points is computed (d1 and d2 in Figure 4). Finally, the location chosen as the best one is the point whose distance to the radius of the circle C2 is smaller. In this way, not only do we consider measurements Again we face a situation in which there is not a single point. Furthermore, now choosing the middle point between P1 and P2 as the best estimation is not the optimal solution, because we would not take into account the measurements of the receiver on circle C2. Instead, we calculate points P1 and P2. Then, we obtain: where: and r 1 , r 3 are the radius of C1 and C3 respectively and Ci x , Ci y , are the coordinates x and y of the centre of the circle Ci.
Once P1 and P2 are calculated, the distance between the centre of C2 and these points is computed (d1 and d2 in Figure 4). Finally, the location chosen as the best one is the point whose distance to the radius of the circle C2 is smaller. In this way, not only do we consider measurements provided by C1 and C3, but we also use the information provided by C2. Point P2 is more likely to be the right one than P1, since P2 is closer to C2 than P1. In this case, we do not consider weights because there is no closer point to C2 than P2, so we do not need to compute the weighted position.

•
Circles do not intersect: In this case, we get three distances whose related circles around the receiver do not intersect. As explained before, the position I is estimated based on RSSI by applying a propagation loss model that provides a circular area centred at the receiver. The RSSI can be affected by multipath, and so the receivers can estimate the sender is closer that it really is, therefore, circles may not intersect.
As it can be seen in Figure 5, the sender will be placed somewhere in the middle. In order to compute the location, we may start from the closest receiver and move towards the other receivers depending on the radius of them and the distance between receivers. provided by C1 and C3, but we also use the information provided by C2. Point P2 is more likely to be the right one than P1, since P2 is closer to C2 than P1. In this case, we do not consider weights because there is no closer point to C2 than P2, so we do not need to compute the weighted position.
 Circles do not intersect: In this case, we get three distances whose related circles around the receiver do not intersect. As explained before, the position I is estimated based on RSSI by applying a propagation loss model that provides a circular area centred at the receiver. The RSSI can be affected by multipath, and so the receivers can estimate the sender is closer that it really is, therefore, circles may not intersect.
As it can be seen in Figure 5, the sender will be placed somewhere in the middle. In order to compute the location, we may start from the closest receiver and move towards the other receivers depending on the radius of them and the distance between receivers. To compute the location of the sender (point P), we first compute the weights of C2 and C1 respect to C3, since it is the more reliable one (smaller radius): Then we estimate the location as the point laying a distance d1 from the point P1 towards point P2 of the circle C1 and a distance d2 from there to the circle C2: where a is the closest distance between the circumferences of C1 and C3, and b is the distance from the point resulting of moving from P1 to P2 and the closest point of the circumference C2.
The rest of the possible (but unlikely) cases are also implemented: circles intersect in pairs (i.e., C1 with C2 and C3 and no intersection between C2 and C3), two circles intersect and the third one is contained in any of the others but also intersecting the remaining one, two circles intersect and the To compute the location of the sender (point P), we first compute the weights of C2 and C1 respect to C3, since it is the more reliable one (smaller radius): Then we estimate the location as the point laying a distance d1 from the point P1 towards point P2 of the circle C1 and a distance d2 from there to the circle C2: where a is the closest distance between the circumferences of C1 and C3, and b is the distance from the point resulting of moving from P1 to P2 and the closest point of the circumference C2.
The rest of the possible (but unlikely) cases are also implemented: circles intersect in pairs (i.e., C1 with C2 and C3 and no intersection between C2 and C3), two circles intersect and the third one is contained in any of the others but also intersecting the remaining one, two circles intersect and the third one is contained in any of the others but without intersecting the remaining one, the circles are contained each other (i.e., C1 inside C2 and C3, C2 inside C3), one circle isolated and one of the other ones inside the remaining one (i.e., C1 isolated, C2 inside C3).

Kalman Filtering
Once we have the estimated location from the weighted location algorithm, we intend to use the KF to smooth the calculations of the position. We have designed a second order filter to track position, velocity and acceleration in x and y axis, with no external control input. Through experimentation it was determined that the best values to initialize the filter are those detailed in Equations (25)- (30). We have to mention that tuning of the initial values is not a critical aspect since the KF adapts some of them over the time.
For the state variables x, we set them with the initial values of the variables we are measuring. In our case, for testing purposes, we set the position in x and y as the starting position of the device during the test. Velocity and acceleration are set to 0 as the initial values for our environment. Depending on the application, these values may change: Therefore, the used state transition function matrix F is: The state covariance P indicates how much the state variables influence the values each other. We have chosen medium values for the initial matrix P so that the system does not depend on the initial state values: Note: the columns are defined as position, velocity and acceleration in x and position, velocity and acceleration in y.
The process noise matrix Q is not updated in every step. Since we consider F to be accurate enough to define the movement process, the values of Q are defined small according to some performed empirical tests in all scenarios: The measurement function H defines the mapping from the states variables to the measurements. z is the measurement vector, and x the states variables. The H function is used to obtain from the state variables vector x the values that are being measured, in this case the position: Finally, the matrix R is related to the introduced noise in position measurement. We have performed some tests to tune this value, obtaining the best results for the matrix expressed in Equation (30): The Kalman gain K can be calculated as expressed in Equation (31): All those parameters are combined during the prediction step, Equations (32) and (33), and the update step, Equations (33) and (34), to get the current state of the system: wherex k is the estimate of x at current step k: where P k is the estimate of P at current step k: wherex k and P k are the updated of x and P respectively at current step k. K is also updated in the k current step of the system, as showed in Equation (36), obtaining K':

Test Scenarios
The objective of this implementation was to provide a system able to display good performance in terms of accuracy, cost and energy consumption in any environment. We have selected three different indoor scenarios, shown in Figure 6, to present the performance we have obtained.

•
Scenario #1. Indoors medium sized room environment. There are not any obstacles between sender and receivers but we observe interferences from the WiFi and other electronic devices as well as refraction and multipath due to pillars and walls. Its size is a 6 m × 4.8 m. • Scenario #2. Laboratory room. This is a laboratory full of computers, with people around using electronic devices with WiFi, Bluetooth, etc. causing interferences. Its size is 9.19 m × 6.18 m. • Scenario #3. Conference room. Unlike scenario #2, now we have a bigger room where the receivers are further away than before. Its size is a 16.50 m × 17.60 m. The interferences are similar to those in Scenario #2.
All tests are performed in the presence of people, interference signals from electronic devices and rotating the BLE devices that act as senders since we know that the antenna is not fully omnidirectional. Therefore we perform tests in a realistic situation that can be considered as the worst case. The results we have presented are obtained in LOS conditions except for people presence. To extend our system in case we have no LOS, more receivers must be placed to obtain the same accuracy as is possible in a RSSI-based system. Tests are performed when senders and receivers are in the same plane. In the case this is not possible, then we have to apply 3D trilateration schemes not implemented in this version of the system, otherwise we must add a position estimation error. For a 3D location an additional reference is needed. This case has not been implemented since we consider this is not an interesting use case for our solution, since the attenuation due to floors introduces a significant error that can be sufficient to misplace the sender to a different floor level, becoming the location system useless. additional reference is needed. This case has not been implemented since we consider this is not an interesting use case for our solution, since the attenuation due to floors introduces a significant error that can be sufficient to misplace the sender to a different floor level, becoming the location system useless. We have selected the parameters of the Log-Distance Path Loss model with shadowing and the ITU model according to the recommendations of [42] and [43], while for the empirical model we have selected A as the average RSSI value at the receiver one m away from the receiver after applying the biggest algorithm, and n is the experimental value that better matches the RSSI values. The equations for each model are described in Section 3.3, Equations (5), (6) and (7) respectively. The parameters are shown in Tables 3 to 5.

Estimation of the Most Accurate Propagation Model and RSSI Selection Algorithm
In order to evaluate the best propagation model and RSSI selection algorithm, we use scenarios #1 and #2. We have moved the sender away from the receiver from 0.5 to 5 m in steps of 0.5 m, taking 500 RSSI measurements at each step, as shown in Figure 7. We have selected the parameters of the Log-Distance Path Loss model with shadowing and the ITU model according to the recommendations of [42] and [43], while for the empirical model we have selected A as the average RSSI value at the receiver one m away from the receiver after applying the biggest algorithm, and n is the experimental value that better matches the RSSI values. The equations for each model are described in Section 3.3, Equations (5), (6) and (7) respectively. The parameters are shown in Tables 3-5.

Estimation of the Most Accurate Propagation Model and RSSI Selection Algorithm
In order to evaluate the best propagation model and RSSI selection algorithm, we use scenarios #1 and #2. We have moved the sender away from the receiver from 0.5 to 5 m in steps of 0.5 m, taking 500 RSSI measurements at each step, as shown in Figure 7. The scatter plots of the 500 RSSI values at each distance for each scenario are illustrated in Figures 8 to 10. Plotting all the channels together, we have the overall dispersion and the mean for each channel.  The scatter plots of the 500 RSSI values at each distance for each scenario are illustrated in Figures 8-10. Plotting all the channels together, we have the overall dispersion and the mean for each channel. The scatter plots of the 500 RSSI values at each distance for each scenario are illustrated in Figures 8 to 10. Plotting all the channels together, we have the overall dispersion and the mean for each channel.    Figures 8 to10 show high fluctuations in RSSI, not only along the distances, but also within the same distance. These results prove the need of a combination scheme that reduces spread of the RSSI and ensures that the system uses the best channel to estimate the most accurate position. The results of applying the combination algorithms we are considering (detailed in Section 3.2.1), are shown in Figures 11 to 13. In this case we have combined the three values of each row of Table 2 according to   Figures 8 to10 show high fluctuations in RSSI, not only along the distances, but also within the same distance. These results prove the need of a combination scheme that reduces spread of the RSSI and ensures that the system uses the best channel to estimate the most accurate position. The results of applying the combination algorithms we are considering (detailed in Section 3.2.1), are shown in Figures 11 to 13. In this case we have combined the three values of each row of Table 2 according to Figure 10. Scatter plot of RSSI measurements for different distances from sender to receiver at scenario #3 for different channels. Figures 8-10 show high fluctuations in RSSI, not only along the distances, but also within the same distance. These results prove the need of a combination scheme that reduces spread of the RSSI and ensures that the system uses the best channel to estimate the most accurate position. The results of applying the combination algorithms we are considering (detailed in Section 3.2.1), are shown in  In this case we have combined the three values of each row of Table 2    Comparing Figures 11 to 13 with Figures 8 to 10, we visually observe that the difference between the maximum and minimum values of the RSSI measurement scatter plot is reduced when applying the different combination schemes over the three channels. Moreover, for example, for scenario #2, Table 6 shows the RSSI standard deviation as a dispersion measure. RSSI standard deviation is Comparing Figures 11 to 13 with Figures 8 to 10, we visually observe that the difference between the maximum and minimum values of the RSSI measurement scatter plot is reduced when applying the different combination schemes over the three channels. Moreover, for example, for scenario #2, Table 6 shows the RSSI standard deviation as a dispersion measure. RSSI standard deviation is Comparing Figures 11-13 with Figures 8-10, we visually observe that the difference between the maximum and minimum values of the RSSI measurement scatter plot is reduced when applying the different combination schemes over the three channels. Moreover, for example, for scenario #2, Table 6 shows the RSSI standard deviation as a dispersion measure. RSSI standard deviation is maintained or reduced in all the cases applying a combination algorithm. There are several techniques to use so as to minimize the fast fading effect, such as antenna diversity or frequency diversity. Thanks to the fact that the advertisement message is transmitted almost simultaneously in three different frequencies, we can apply the frequency diversity by free. The three combination schemes are commonly used against fast fading. As we compensate the fast fading, we reduce the variability of the RSSI. Therefore, we demonstrate that this combination has an impact on RSSI dispersion, and we conclude that we reduce the dispersion when applying the different combination schemes over the three channels.  Figure 14 shows the correlation between the propagation models and the combination schemes we have proposed. We observed that in scenario #1 the Log-Distance Path Loss model with shadowing fits better with the biggest algorithm than any other combination of propagation model and combination scheme. In scenario #2 there is almost no difference between ITU and Log-Distance Path Loss models with or without shadowing, and both perform well. Nevertheless, in scenario #3 we observe that the RSSI values are smaller and they do not match well with neither the ITU nor the Log-Distance Path Loss model. The best model the RSSI values match is with the empirical model, as expected since it considers some characterization. This last model is the one that performs the best.    However, to be precise, we want to check the position estimation error for any combination of propagation model and combination scheme. According to Equation (1), we have computed the Cumulative Distribution Function (CDF) of the error average over all the distances from 0.5 m to 5 m. Figure 15 shows the results. CDF represents the probability that the error average takes a value less than or equal to the error average in meters. From Figure 15 we observe that, as expected, the best propagation model is the empirical one. However, the improvement in the accuracy is not as high as the drawback, in terms of characterization, that this propagation model entails. Respect to the other two models, ITU and Log-Distance Path Loss model with shadowing, we came around a dilemma. In scenario #1 the Log-Distance Path Loss model achieves a better accuracy than the ITU model (2 m during 90% of the time against 3 m during 90% of the time). In scenario 2 there is almost no difference between models, but in scenario #3, the ITU model is the one outperforming the Log-Distance Path Loss model for around 2 m (ITU gets 4 m accuracy 90% of the time while Log-Distance Path Loss model with shadowing gets an accuracy of 6 m during 90% of the time).
Since one of our main objectives is to build a system as independent of the environment as possible, we recommend using the Log-Distance Path Loss model with shadowing. While the ITU model considers different values for its parameters N and P f (n) according to the type of the building, the number of floors it has, and the frequency, the Log-Distance Path Loss model with shadowing takes its parameters n and Xσ depending on the frequency and the type of the building.
Therefore, from now on, the Log-Distance Path Loss model with shadowing and the biggest RSSI algorithm are the propagation model and the channel diversity combination scheme we are going to use, respectively.

Performance of the System
Once we have selected the propagation model and the combination scheme, we must measure the performance, by means of position error, of the overall system. In order to do this we have selected scenarios #2 and #3, as they have the same interference conditions, to check the behaviour of the system in two different sized indoor environments. In this case, we have placed four receivers in each scenario. In the trilateration algorithm, we have used the three receivers whose calculated distance to the sender is the smallest, according to our approach of trusting more the devices closer to the sender. Using more than three receivers increases the accuracy, but also increases the cost of the system.
The performed tests will calculate the position of the senders every time interval. This time interval can be greater than the advertisement interval (in the tests set to 100 ms). The results presented calculate the position of each sender every second. This is why we have up to N = 10 rows of the matrix of Table 2 to estimate the sender position. Therefore, we can decide how to use this amount of data. For testing purposes we use the measurements of seven rows (21 RSSI measurements), to obtain an optimized RSSI each second. This value has been chosen as a compromise of accuracy, used memory and delay in the position computation.
The procedure is as follows: we start from a given position and we move with the sender at a constant velocity of 0.3 m/s following a defined path in each scenario as shown in Figure 16, with the purpose of calculating the CDF. Then we compare the estimated positions with the one we should be at each second and perform the CDF of the averaged error.
To show the improvements of the different proposals, we have tested the system using raw values (i.e., without diversity, without KF, without weighted trilateration or a combination of those techniques), only diversity, diversity plus weighted trilateration or KF, and finally all of them together. We have performed four trials for each technique to compute the averaged results. In case we do not use diversity, we have selected one channel randomly, and to compute the position we have used the basic trilateration algorithm. Table 7 shows the results for the 90% and 95% in both scenarios.   Figure 17 shows that our proposal, that includes channel diversity, Kalman filtering and weighted trilateration, improves the estimation error compared to the other approaches. In scenario #1, an improvement of 43.47% is achieved when comparing errors at 90% of the time. Furthermore we observe that, while the error in scenario #2 is low, below 1.82 m during 90% of the time, in scenario #3 the error goes up to 4.6 m during 90% of the time. This issue is due to the fact that accuracy of the RSSI measurements decreases drastically as the distance between the sender and the receiver increases from 5 m on. This is a design trade-off so that we could decrease the error by adding more receivers if the application requires greater accuracy, but increasing the cost.

Power Consumption Analysis and Application Examples
Apart from performance and location error, the device lifetime is one of the most important aspects in a system like the one we propose. For this reason, in this section we do an estimation of the power consumption of the system. Texas Instrument has developed a tool [44] to do an estimation of the power consumption of SensorTag CC26xx series. For a device with a power source voltage of 3 V, a CR2032 coin cell battery, considering only non-connectivity advertising at 100 ms 24 h/day, with an output power level of 5 dBm (the maximum) and advertising in the three BLE channels using frames of 30 bytes, we show the current consumption and device lifetime estimation in Table 8.   Figure 17 shows that our proposal, that includes channel diversity, Kalman filtering and weighted trilateration, improves the estimation error compared to the other approaches. In scenario #1, an improvement of 43.47% is achieved when comparing errors at 90% of the time. Furthermore we observe that, while the error in scenario #2 is low, below 1.82 m during 90% of the time, in scenario #3 the error goes up to 4.6 m during 90% of the time. This issue is due to the fact that accuracy of the RSSI measurements decreases drastically as the distance between the sender and the receiver increases from 5 m on. This is a design trade-off so that we could decrease the error by adding more receivers if the application requires greater accuracy, but increasing the cost.

Power Consumption Analysis and Application Examples
Apart from performance and location error, the device lifetime is one of the most important aspects in a system like the one we propose. For this reason, in this section we do an estimation of the power consumption of the system. Texas Instrument has developed a tool [44] to do an estimation of the power consumption of SensorTag CC26xx series. For a device with a power source voltage of 3 V, a CR2032 coin cell battery, considering only non-connectivity advertising at 100 ms 24 h/day, with an output power level of 5 dBm (the maximum) and advertising in the three BLE channels using frames of 30 bytes, we show the current consumption and device lifetime estimation in Table 8.  Depending on the user application, the advertising interval can be greater or smaller. However, 100 ms advertising interval is already a high value. Table 9 shows current consumption and device  Depending on the user application, the advertising interval can be greater or smaller. However, 100 ms advertising interval is already a high value. Table 9 shows current consumption and device lifetime for applications where the advertising requirements are not so high and the BLE tag can advertise each 500 ms. Table 9. Current consumption and device lifetime when considering only non-connectivity advertising at 500 ms 24 h/day, with an output power level of 5 dBm. Different applications and environments under several conditions where our system may be useful as well as the device lifetime, are explained as follows:

•
Tracking assets in a factory where workers move them from one building to another, and they want to track that all the assets are where they are supposed to be. Each asset must have a BLE tag on it or in its container. If we want to track in which building the assets are at every moment, we need to have the device on 24 h but we do not need an extreme location precision, so we transmit advertisements from the BLE tag every 5 s instead of every 100 ms. Under these conditions (24 h running, 5 s advertisement, low transmission power of −20 dBm), the assets could stay monitored for 6.238 years.

•
Tracking people inside a building where, for security reasons, we want to have the control of where the people are at every moment. People must have a BLE Tag. We have considered a real operation time of the system of 10 h per day. In addition, we know we will have many interferences and occlusions from people moving and the devices they carry, so we need to set the advertising interval to a low value (100 ms) and the transmission power to 5 dBm so that the accuracy does not drop. In this case the device lifetime is about 4.2 months. • Tracking customers in a mall to know users' preferences and offer them the products that they are interested in. The IPS may be used to track the path of the customers. With the information obtained, companies of the mall may, for example, redistribute the different shops in a way that is more comfortable for the customers, or place together shops that are usually visited in a row. Taking into account that malls usually open 12 h per day, and that we need a medium precision for this purpose (500 ms advertisement interval and medium transmission power of 0 dBm), we obtain a device lifetime for the BLE tags of 1.4 years.
Moreover, the BLE SensorTag chosen for this project can be programmed so that it stops advertising frames when it is not in movement.

Conclusions
In this paper we have presented a survey of different IPS BLE based systems. Then we have proposed and implemented a novel IPS BLE system that improves accuracy while reducing costs. In our research, we have proposed three different techniques to enhance the precision of a BLE indoor positioning system: channel diversity, Kalman Filtering and a weighted trilateration method. With channel diversity our main goal is to reduce the dispersion of the RSSI measurements inherent to this kind of systems. We use Kalman Filtering as a way to mitigate the effects of unlikely or impossible location estimations due to wrong RSSI measurements, so that we can track the location of a device with more precision. Finally, the weighted trilateration is an improvement of the basic trilateration algorithm, since not always the three measurements converge to a single point. Our results prove that combined together, the precision is increased by 43.47% in a medium-size room scenario and by 38.33% in a big-size room scenario compared to precision without using any of the proposed techniques.
If we compare the results of our experiments to those reviewed in the literature, we observe that most of the systems use fingerprinting, since it is the technique that achieves the best results in terms of precision. For example, [19] shows a precision under 0.8 m during 96.6% of the time which is far better than the results of our proposal at 95%, of two m in scenario #2 and 5.06 on scenario #3. Nevertheless, there are two important factors which make our system a good choice: the number of beacons and the characterization of the scenario. In [19], they use 44 beacons which implies a more expensive solution compared to our four beacons. In addition to the cost, their system is highly dependent of characterization, as any other fingerprinting approach, while our proposal does not need any characterization.
When comparing our solution to other BLE systems using propagation models without characterization, we observe that, in general, ours is the most balanced one in terms of precision and cost. Comparing with [11] we see that our proposal outperforms it in every metric, namely number of beacons, size of the room, and accuracy. Finally, the authors in [17] used 10 beacons in a bigger room than ours in scenario #3, and the precision was 3.02 m during 80% of the time. In our case, the precision in scenario #3 is around 4 m during 80% of the time. However, we still have to consider that they are using six more beacons that, again, increase the final cost. As the result of applying all the techniques proposed in our work, we achieve an estimation error for a device moving lower than 1.82 m during 90% of the time for a 54 m 2 room, and lower that 4.6 m during 90% of the time for a 290 m 2 room, in both cases using only 4 beacons. An estimation of the cost of BLE devices used in the system is between 15€ to 30€ each BLE beacon (one per sender), and about 120€ per each receiver. The comparison of the system we have proposed with other studies has proved that our solution is better as a trade-off between precision and cost, as the density of receivers is very low for the accuracy achieved. From the figures provided it is clear that if we have a large number of low power tracking devices, which should work unattended, the proposed solution is the best in terms of cost.