You are on page 1of 6

2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

Indoor Positioning System for IoT Device based


on BLE Technology and MQTT Protocol
Kais Mekki1,2, Eddy Bajic1, Fernand Meyer2
1
Research Centre for Automatic Control of Nancy, Campus Sciences, BP 70239, Vandoeuvre, 54506, France.
2
OKKO SAS, 34 Rue Nationale, Puttelange-aux-Lacs, 57510, France.
{kais.mekki, eddy.bajic}@univ-lorraine.fr

Abstract—The arrival of Bluetooth Low Energy (BLE) interference and obstacle on the environment. Thus, using a
creates opportunities for great innovations. One possible general propagation formula is also difficult [3].
application is indoor localization. This paper presents a system In this paper, we present our IPS solution which combines and
that can track mobile device and help finding their location analyzes the most accurate and relevant techniques in the
within a building perimeter. With the help of BLE beacons that
literature based on RSSI measurement (i.e. RSSI filtering,
can be deployed in different locations, the position of a mobile
device can be estimated using RSSI techniques and trilateration distance estimation, and trilateration). It can efficiently
methods. The overall system is controlled using MQTT protocol. localize the mobile device area with accuracy less than 1.5
Along this paper, we describe our system, the techniques we use, meters in real environment condition.
and the experiments we conducted along with the results. Moreover, we propose a remote-controlled IPS using MQTT
protocol. MQTT is a data transfer protocol commonly used in
Keywords—Internet of Things, Indoor localization, BLE, RSSI,
Trilateration, MQTT. Internet of Things (IoT) architectures built upon TCP/IP. It is
more suitable than other protocols, such as HTTP, due to low
I. INTRODUCTION bandwidth consumption and for adoption by devices with
Nowadays, indoor positioning systems (IPS) is a major limited resources [6]. It features a publish-subscribe paradigm
research field for various Internet of Things (IoT) applications (also known as pub-sub), which involves three entities:
such as human/object tracking and public advertisement. In publisher, subscriber, and broker. The former one is able to
the literature, a white paper [1] was released by Microsoft send messages on a specific topic. Such messages are received
regarding their indoor localization technologies. After by the broker which, in its turn, forwards them to the clients
studying the existing solutions, the authors summarize that the registered to the same topic, called subscribers.
indoor localization problem is not yet solved. There is no The idea of using the MQTT protocol to control an indoor
technology or a combination of methods that recreate the BLE localization system, is quite innovative. To our
experience that the global positioning system (GPS) offers in knowledge, this paper is a first contribution towards proposing
outdoor. Moreover, authors show that there is no solution and prototyping an MQTT controlled IPS based on BLE
working efficiently in all environments. Thus, an efficient technology.
solution for IPS might be a hybrid method. This literature The rest of paper is organized as follow. First, the RSSI
study motivates us to experiment and analyze technologies measurement and trilateration methods are studied based on
combination for designing a robust IPS solution. BLE. Then, the architecture of our IPS is detailed based on
Mostly, IPS solutions are designed based on radio signal MQTT protocol. Finally, the experimental results are
technologies such as WiFi, ZigBee, and RFID. Recently, BLE presented and discussed.
(Bluetooth Low Energy) has become the center of interest for II. RSSI-BASED LOCALIZATION
positioning methods due to its low power consumption, cost
effective, and deployment flexibility [2]. BLE for IPS uses In this section, the combination of RSSI measurements and
mainly RSSI (Received Signal Strength Indication) technique trilateration of fixed points BLE beacons, that we call BLE-
[3]. It measures the RSSI level of signals transmitted by fixed GeoMarkers (bGM), is detailed. RSSI measurement problem
BLE beacons, to finally estimate the distance between each of is firstly analyzed, and then, the formula between distance and
them and a mobile device that have to be located. Various RSSI level is presented. The trilateration method is finally
positioning methods have been presented in the literature detailed.
based on RSSI [2-5]. Accurate distance is obtained with these A. RSSI Issue
methods in a laboratory environment using a precise signal
To achieve high localization accuracy, efficient methods are
measurement. In fact, this technique uses a radio propagation
required for measuring RSSI. Thus, it is mandatory to
model for linking RSSI measurement to the position of the
understand the behaviors of the RSSI for BLE signal. BLE
mobile device. It requires precise description of the radio
signal wave is analyzed in [7]. Authors show that RSSI is
propagation environment which is difficult to predict. In
highly influenced by environment noise, signal attenuation,
addition, BLE signal propagation is highly influenced by
and fading, leading to incorrect RSSI measurements. In

978-1-5386-4980-0/19/$31.00 ©2019
978-1-5386-4980-0/19/$31.00 ©2019 IEEE
IEEE 787
2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

wireless communication, fading come from multipath model to convert an RSSI value into distance is the Log
propagation (multipath-induced fading), or from shadowing Normal Shadowing model (LNS) [2] shown by formula (1).
due to obstacles affecting the wave propagation (shadow
fading). 𝑑
𝑅𝑆𝑆𝐼 𝑑 = 𝑅𝑆𝑆𝐼 𝑑0 − 10 × 𝑒 × 𝑙𝑜𝑔10 + 𝑋𝜎 (1)
𝑑0
B. Raw RSSI measurement
To analyze RSSI phenomena, we measure fifty RSSI values Where: RSSI(d0) is the RSSI reference value measured at the
between two BLE modules with a fixed distance of 1 meter. distance d0. The parameter e is the path loss exponent, which
Figure 1 shows the results of RSSI measurements. The values indicates the rate of increasing path loss related to the
fluctuate between -86 dBm and -66 dBm with a standard distance. It also represents the multipath effect. Further, d is
deviation of 6.032. This experiment shows that the raw RSSI the actual distance to the bGM, and Xσ is a zero-mean normal
values are not reliable enough for definitive distance random variable. In the case of line-of-sight communication,
estimation. Thus, filters are required for improving RSSI Xσ can be neglected and be set to zero [2].
measurement stability. For further experimentation in this paper, d0 is set to 1 m, so
that RSSI(d0=1m) represents the measured RSSI at a distance
of 1 m to a bGM. In this paper, mobile devices and bGMs are
in line-of-sight (bGMs are installed along the building
ceiling), thus shadowing is not expected and Xσ is set to zero.
The path loss exponent e depends on the environmental
conditions. Table 1 lists some typical values for e regarding
the environment [3].

Table 1. Path loss exponents for different environments.


Environment Path loss exponent e
Free Space 2
Fig. 1. Raw RSSI measurement with fixed distance of 1 meter. Urban Area Cellular Radio 2.7 - 3.5
C. RSSI Filtering Shadowed Urban Cellular Radio 3-5
Line-of-Sight in Building 1.6 - 1.8
The significant variance in the RSSI measurement leads to Obstruction in Building 4-6
unreliable distance estimation. To avoid this, it is necessary to Obstruction in Factories 2-3
filter the RSSI values for smoothing out the noise between the
mobile device and bGM. As shown in Figure 2, various The path loss model can thus be expressed as:
techniques are proposed in the literature including Bandpass,
Lowpass, Highpass, Chebychev theorem, Median and Kalman 𝑅𝑆𝑆𝐼 𝑑 = 𝑅𝑆𝑆𝐼 𝑑0 = 1𝑚 − 10 × 𝑒 × 𝑙𝑜𝑔10 (𝑑) (2)
filter [4][5]. The simpliest way to filter out the noise is to use a
running median of RSSI measurements. This technique offers Solving formula (2) for d, the equation is simplified to:
an efficient way for RSSI filtering [8]. It is also common to
throw out particularly high or particularly low numbers in 𝑅𝑆𝑆𝐼 𝑑 0 =1𝑚 –𝑅𝑆𝑆𝐼 (𝑑 )
(3)
these data sets. The method we use in this paper discards the 𝑑 = 10 10 ×𝑒

top and bottom 10% measurements over the BLE scanning


period and averages the rest. In the case where the mobile device is very close to the bGM,
the distance calculation can be simplified while being
accurate. For example, let’s consider bGM RSSI
measurements filtered at -50 dBm, with a reference RSSI
(d0=1m) of -59 dB. The bGM is less than one meter away
because -50 dBm is stronger than signal level of -59 dBm. So,
for very short distance, we state that the estimated distance is
equal to ratio10 with ratio = RSSI / RSSI(d0=1m). Otherwise,
the formula (3) is used.
Thus, we propose the 2-parts linearization algorithm shown in
Figure 3 to estimate distance between a mobile device and
Fig. 2. Distance estimation process based on RSSI measurements. bGMs by comparing the measured RSSI with the reference
D. Distance estimation RSSI at one meter.
Before applying trilateration to calculate the mobile device
position, it is necessary to estimate the distances between the
mobile device and each nearby bGM. The calculation is based
on the relation of the distance to the RSSI. A well-known

788
2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

Whereas (x,y) are the coordinates of the mobile device, which


have to be computed. Further, (xi,yi) is the position and di is
the distance to the mobile device of the ith bGM.
For better accuracy using formula (4), three bGMs in
maximum have to be used for trilateration process. However,
the mobile device can detect more than three bGMs in real
condition. In this paper, the mobile device selects the three
nearest bGMs based on distance estimation diagram (see
Figure 3). Then, formula (4) is used for estimating the position
(x,y).
The final algorithm of our RSSI-based localization is shown in
Figure 5. First, the mobile device scans BLE radio channels
during x seconds. For each detected bGM, the RSSI
measurements during the scanning period are filtered and the
distance is estimated (i.e. operation run using algorithm of
Fig. 3. Diagram of distance estimation algorithm. Figure 3). Then the mobile device selects the three nearest
E. Trilateration bGMs (with the lowest estimated distances). Finally, the
Trilateration is a traditional method to compute the unknown formula (4) is employed for estimating the position of the
position of a mobile device. Typically, several bGMs with mobile device.
known positions are required in this method. Besides, the
distances between these bGMs and the mobile device are
required to be known, as well. Theoretically, each bGM forms
a circle around itself with the radius of the estimated distance
to the mobile device. Thus, the position of the mobile device
corresponds to the intersection of these circles as shown in
Figure 4. An efficient way to calculate the mobile device
position is the Least Square (LSQ) method [3].

Fig. 5. Diagram of the final RSSI localization process.

III. SYSTEM DESCRIPTION


The architecture of the proposed IPS is shown in Figure 6. In
order to localize the mobile device (e.g. robot, intelligent
Fig. 4. Trilateration using Least Square (LSQ) method.
product, etc), multiple bGMs are uniformly deployed in the
supervised area. It send periodically iBeacon frames (i.e. BLE
Considering there are n reference bGM, the LSQ formula is as
advertisements) which contain unique identifier of each bGM
follow:
(i.e. iBeacon identification protocol [9]: UUID, Major and
Minor). The mobile device acts as a BLE scanner. It integrates
𝑥 = 𝐴𝑇 𝐴 −1 (𝐴𝑇 𝑏) (4)
a BLE radio module, a Processing Unit capable of filtering,
where: interpreting, and forwarding messages, and an MQTT client.
2(𝑥1 − 𝑥𝑛 ) 2(𝑦1 − 𝑦𝑛 ) The latter communicates with the broker through Internet
𝐴= ⋮ ⋮ (5) using WiFi connection over a TCP/IP stack. The broker
2(𝑥𝑛−1 − 𝑥𝑛 ) 2(𝑦𝑛−1 − 𝑦𝑛 ) manages the communications between the mobile device and
the third-party MQTT client (user interface). Both mobile
𝑥 devices and user operation rules are managed by the broker
𝑥= (6)
𝑦 which, through the pub-sub paradigm, knows to which mobile
device or user the message must be forwarded.
𝑥12 − 𝑥𝑛2 + 𝑦12 − 𝑦𝑛2 + 𝑑𝑛2 − 𝑑12 This IPS is based on the RSSI method detailed in the previous
𝑏= ⋮ (7) section. It includes four functions: RSSI filtering, distance
𝑥𝑛2−1 − 𝑥𝑛2 + 𝑦𝑛−1
2
− 𝑦𝑛2 + 𝑑𝑛2 −1 − 𝑑12 estimation between the mobile device and each scanned bGM,
selecting the three nearest bGMs, and trilateration. As shown

789
2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

in Figure 6, the three first operations are implemented in the


mobile device, and the trilateration process is implemented in
the user interface which also displays the final results in a
virtual location map.

Fig. 8. Example of JSON data sent using user_command.

IV. EXPERIMENTAL RESULTS


The implementation of the proposed IPS is made with the use
of an ESP32 module acting as a mobile device, and nine
Kontakt.io BLE beacons [10] acting as bGMs. Each beacon
sends an iBeacon advertisement frame at a two seconds
period. As shown in Table 2, the Kontakt.io beacon allows
eight radio transmission powers which are further tested for
Fig. 6. Indoor localization system using BLE and MQTT.
the performance evaluation. We carried out the localization
Two MQTT topics were defined for communication between a experiment in an office of 6m×6m with multiple objects inside
mobile device and the user interface: user_command and including cubicles, bookcases, computers, etc. bGMs were
geomarkers_in_proximity. Both topics receive and send data uniformly deployed in the ceiling as shown in Figure 11.
in JSON format. Each topic aim is presented in the following: A functional JavaScript web application for user interface was
- MQTT Topic geomarkers_in_proximity: Used by the mobile developed to display the trilateration results and further to
device to send information towards user related to the three control the mobile device using MQTT topics. Mainly, it
nearest bGMs. It contains the mobile device ID, scanning implements the following functionalities:
timestamp, and information related to each bGM (i.e. UUID, - Trilateration method (formula (4)),
Major, Minor, and estimated distance between the mobile - Graphical map to show the bGMs deployment in the room
device and the bGM). Figure 7 shows an example of a JSON and the estimated position of the mobile device,
data sent by a mobile device using geomarkers_in_proximity
- MQTT client for exchanging data with the remote ESP32
topic.
through publishing and subscription rules.
- MQTT Topic user_command: Used to send commands
In the following, the calibration of RSSI at one meter and the
towards a mobile device by the user. Through this topic,
path loss exponent e is explained. Then, localization results
several parameters can be modified in a mobile device
are presented.
program, as for example to activate a localization operation or
to modify BLE scanning period (e.g. from 20 seconds to 50 A. Calibration of RSSI(do=1m) and the path loss exponent
seconds). Commands include: START_SCAN_IMMEDIAT, In this work, the reference RSSI value measured with the
STOP_SCAN_DURATION, SCAN_DURATION, and distance of one meter between a bGM and the ESP32 is
PERIODICITY_SCAN. Figure 8 shows an example of a determined for each transmission power as shown in Table 2.
JSON data sent by the user using user_command topic for When solving formula (2), the path loss exponent e can be
defining the periodicity of execution of a localization calculated by the following equation:
operation in two mobile devices (command
PERIODICITY_SCAN). 𝑅𝑆𝑆𝐼 𝑑0 = 1𝑚 − 𝑅𝑆𝑆𝐼(𝑑) (8)
𝑒=
10 × 𝑙𝑜𝑔10 (𝑑)

To calculate e, RSSI values are measured at different distances


from 0.5 m to 5 m under the same fixed conditions. At each
distance, 100 RSSI values are measured and then filtered. The
average value of e = 1.77 is got and used for the further
experimental results.

Table 2. Calibration of RSSI(d0=1m) for various Tx power.


Tx
-30 -20 -16 -12 -8 -4 0 4
(dBm)
RSSI
-84 -74 -70 -64 -62 -57 -54 -52
(d0=1m)

Fig. 7. Example of JSON data sent using geomarkers_in_proximity.

790
2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

B. Distance estimation results C. Trilateration results


In this second phase, our aim is to evaluate the efficiency of Multiple experiments were realized for testing the trilateration
the distance estimation using the algorithm in Figure 3. Figure method of the proposed IPS. Figures 11, 12, 13, and 14 show a
9 shows the distance computed on the ESP32 for a given bGM screen-shot of four experiments from the JavaScript web
and for known real distances (from 0.5 m to 5 m). The application. bGM1, bGM2, … , bGM9 represents the BLE
experiment was tested for all transmission powers in the GeoMarkers which are uniformly deployed in the room
Kontakt.io beacon. Figure 10 shows the related error between ceiling. The red circle represents the estimated zone of the
the estimated distance by ESP32 and the real distance. The ESP32 with a radius of 1.5 m (i.e. 1.5 m is the average error of
error formula is as follow: distance estimation as discussed in the previous section). The
red cross is the real position of the ESP32 in the room. Finally,
𝐸𝑟𝑟𝑜𝑟 = | 𝑟𝑒𝑎𝑙 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 − 𝑒𝑠𝑡𝑖𝑚𝑎𝑡𝑒𝑑 𝑑𝑖𝑠𝑡𝑎𝑛𝑐𝑒 | (9)
the green dots represent the three nearest bGMs calculated by
The results show that the estimation method offers high the ESP32.
accuracy for distance less than 2 m. However, it has a As demonstrated in these Figures, the proposed IPS works
significant degree of uncertainty starting from 2 m. As properly, and the accuracy of 1.5 m is acceptable considering
example, for a bGM at 5 m away from the ESP32, the the uncertainty of the BLE signal over long distances as
estimation error fluctuates between 0.5 m and 4 m. As a discussed previously. Localizing a mobile device within a
consequence, within 0-2 m from a bGM, the distance circle of radius 1.5 m is sufficient in many real location-aware
estimation of the mobile device (ESP32) is much more applications (e.g. mall, human tracking, warehousing, etc.) [4].
accurate than for distances above 2 m or more. As shown in
Figures 9 and 10, even increasing the transmission power of
the bGM does not improve the accuracy in case of long
distance. Despite that ESP32 and bGMs are in a line-of-sight
communication, factors that influence the error include
reflections and attenuation of the radio signal, radio noise in
the environment, and antenna orientation of ESP32 and bGMs.
As shown in Figure 10, the overall average error is equal to
1.5 m. This result will be used in the next section to draw up a
circular area where ESP32 is estimated to be situated. Figure 9
shows that transmission power of -20 dBm (red line) allows a
good linear estimation of the distance. This power level is
used in the next section for trilateration tests of the proposed Fig. 11. Trilateration experiment #1.
IPS.

Fig. 9. Measurement of estimated distance vs. real distance. Fig. 12. Trilateration experiment #2.

Fig. 10. Error of estimated distance vs. real distance.

Fig. 13. Trilateration experiment #3.

791
2019 IEEE 5th World Forum on Internet of Things (WF-IoT)

V. CONCLUSION
In this paper, we proposed an indoor positioning system (IPS)
based on BLE technology and MQTT protocol. RSSI
techniques combined with trilateration methodology are used
to estimate the position of a mobile device based on a 2-parts
linearization algorithm. A number of experiments are
performed to analyze the distance accuracy and trilateration
efficiency with the use of BLE-GeoMarkers. MQTT is also
experimented for communication delay between the user and
mobile devices. The results concluded that the system offers
efficient position estimation with an accuracy of less than 1.5
meters which is relevant for many IoT applications. In the
Fig. 14. Trilateration experiment #4. future, we plan to extend the experiment by evaluating other
properties of our IPS such as energy consumption and
D. IPS configuration through MQTT protocol scalability. In addition, we plan to analyze the impacts of other
Two public MQTT brokers on the Internet were tested in this RSSI filters such as Kalman and Chebychev theorem.
study: HiveMQ (broker.hivemq.com) [11] and Flespi
(mqtt.flespi.io) [12]. Sending commands through Internet- REFERENCES
based MQTT protocol in order to remotely configure and [1] D. Lymberopoulos, J. Liu, X. Yang, R.R. Choudhury, V. Handziski, S.
Sen, "A Realistic Evaluation and Comparison of Indoor Location
control the ESP32 does not need complex software Technologies: Experiences and Lessons Learned", 14th International
development and works efficiently. We measured the delay Conference on Information Processing in Sensor Networks, 13-16 April
occurred from pressing a "Send Command" button in the user 2015, Seattle, WA, USA.
interface, and the reception by ESP32 of the published value [2] L. Guoquan, G. Enxu, Y. Zhouyang, X. Yongjun, L. Jinzhao, P. Yu,
of topic "user_command" from MQTT broker. We sent 15 "Indoor Positioning Algorithm Based on the Improved RSSI Distance
Model", Sensors Journal, Vol. 18, No. 9, 2018, pii. 2820.
different commands to the ESP32, and the delay of each one is
[3] J. Röbesaat, P. Zhang, M. Abdelaal, O. Theel, "An Improved BLE
measured for both tested brokers. As shown in Figure 15, the Indoor Localization with Kalman-Based Fusion: An Experimental
time delay fluctuates between 0.9s and 4.7s for HiveMQ. As Study", Sensors, Vol. 17, No. 5, 2017, pii. E951.
for Flespi, it fluctuates between 0.5s and 5.01s. This variation [4] Z. Ma, S. Poslad; J. Bigham, X. Zhang, L. Men, "A BLE RSSI ranking
is due to the overload activity of these public brokers. In fact, based indoor positioning system for generic smartphones", Wireless
a broker handles up thousands of concurrently connected Telecommunications Symposium, 26-28 April 2017, Chicago, IL, USA.
MQTT clients in the Internet (i.e. MQTT brokers cause a [5] Y. Zhuang, J. Yang, Y. Li, L. Qi, N. El-Sheimy, "Smartphone-Based
Indoor Localization with Bluetooth Low Energy Beacons", Sensors
queuing delay if large clients are connected as discussed in Journal, Vol. 16, No. 5, 2016, pii. 596.
[13]). Finally, the measured average control delay is [6] T. Yokotani, Y. Sasaki, "Comparison with HTTP and MQTT on
respectively 2.7s and 2.5s with HiveMQ and Flespi, which required network resources for IoT", IEEE International Conference on
could be further improved with the use of a private enterprise Control, Electronics, Renewable Energy and Communications, 13-15
Septembre 2016, Bandung, Indonesia.
broker.
[7] R. Faragher, R. Harle, "An analysis of the accuracy of bluetooth low
energy for indoor positioning applications", 27th International Technical
Meeting of the Satellite Division of the Institute of Navigation, 8-12
September 2014, Tampa, FL, USA.
[8] K. Zhang, Y. Zhang, S. Wan, "Research of RSSI indoor ranging
algorithm based on Gaussian - Kalman linear filtering", IEEE
Conference on Advanced Information Management, Communicates,
Electronic and Automation Control, 3-5 Octobre 2016, Xi'an, China.
[9] N. Newman, "Apple iBeacon technology briefing", Journal of Direct,
Data and Digital Marketing Practice, Vol. 15, No. 3, 2014, pp. 222-225.
[10] BLE Beacon of Kontakt.io Available in: https://store.kontakt.io/our-
products/30-smart-beacon-sb16-2.html.
[11] Public HiveMQ MQTT Broker Available in: broker.hivemq.com.
Fig. 15. Command delay measurement. [12] Public Flespi MQTT Broker Available in: mqtt.flespi.io.
[13] J. Park, H. Kim, W. Kim, "DM-MQTT: An Efficient MQTT Based on
SDN Multicast for Massive IoT Communications", Sensors Journal,
Vol.18, No. 9, 2018, pii: 3071.

792

You might also like