{'fraction_non_alphanumeric': 0.02053575304997178, 'fraction_numerical': 0.006338731385403551, 'mean_word_length': 4.856598016781083, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Indoor Navigation System using BLE and ESP32

: Indoor positioning and navigation-based applications are emerging rapidly. Indoor navigation systems play a very useful role in huge buildings and offices when one needs to locate a room, a shop, or a part of the premises. The indoor routing mechanism gives directions towards selected destinations within a building with the help of an indoor navigation application. The positioning works on a "client-based application" which requires a smartphone with the mobile application used to determine the position directly. Outdoor navigation uses global positioning system (GPS) technology, however using GPS for tracking within a building is not feasible as reception rate is low and accuracy is in the range 30 meters due to indoor environmental factors. Thus, Bluetooth Low Energy (BLE)being a wireless technology is used for short range communication. Here its battery life is preferred over its high data transfer speeds. The position coordinates of the users are estimated using trilateration method where the relative distance from each receiver is calculated based on Received Signal Strength Indicator (RSSI) value. A very lightweight publish/subscribe messaging transport protocol: Message Queuing Telemetry Transport (MQTT) and a communication protocol showing the establishment and maintenance of network conversations by which application programs exchange data: Transmission Control Protocol (TCP) are useful for establishing wireless connections within an indoor location for sending packets of data. Using these technologies indoor navigation can be successfully achieved at a greater accuracy compared to GPS.


I. INTRODUCTION
Location based services are rapidly evolving around the globe. Presently we have highly efficient outdoor location and navigation system based on Global Positioning System (GPS) technology. GPS technology cannot be implemented for positioning within indoor locations due to various shortcomings. It relies on uninterrupted satellite reception from the user, this cannot be achieved while the user is inside an enclosed building. This limitation of GPS calls for a new positioning system for indoor environment.
Indoor positioning system has numerous sets of applications in the market where it can be used to navigate inside a huge building, track assets in a warehouse, improve security of a building, data analytics, etc. Variety of indoor positioning systems has been proposed in the past which use technologies like WIFI, RFID, NFC, and Bluetooth. Bluetooth low energy (BLE) is preferred over other technologies due to its low energy consumptions, higher accuracy, and low latency. Combination of BLE, Message Queuing Telemetry Transport (MQTT) with hardware modules make a good alternative for the situation addressed.Mobile devices with Bluetooth 5.0 chip support the advertising of small packets of data using Bluetooth low energy. This feature enables us to calculate the position of a device inside a building with the help of multiple Bluetooth receivers placed at strategic places in the building. The proposed work aims to achieve the same using path loss models of wireless communication and trilateration algorithm. This paper presents an Indoor navigation System where a mobile application helps the users to navigate inside a building. It provides a user friendly and reliable navigation system for indoor facilities using which the user can navigate through the whole facility without relying on any external maps or personnel. With the use of BLE and by processing most of the data on a single central processing unit, workload on user mobile devices is reduced hence mobile devices consume less energy making this system more energy efficient and user friendly. The paper is organized such that Section II discusses the background and related works, Section III describes the concepts and techniques used in detail, Section IV describes the block diagram and implementation, Section V showcases the obtained results, and the conclusions and future works are conferred in Section VI.

II. BACKGROUND
Mohd Ezanee Rusli et al., [1] show how WIFI access points can be used to implement trilateration technique to find positions of the user with the help of multiple reference points to minimize received signal error rate for more accurate positioning of the user. They also show the feasibility of using RSSI-LOG distance model for indoor positioning. But their proposed model cannot be scaled easily due to increased complexity, price of WIFI access points and the need to define new reference points for increase in operation area.  [2] discuss how RFID can be used to locate object indoors along with Bayesian K nearest Neighbour algorithm. RFID has good efficiency, low cost, and lower energy consumption. The gaussian filters reduce the error rates for location coordinates. However, it is seen that RFID signals get easily affected by environmental factors and obstacle. The phase values are cyclic, and the phase difference is tag sensitive. Thus, we concluded that RFID is not the appropriate technology for large scale implementation of indoor positioning. Megha C. K and D Haripriya [3] provide experimental results that are performed using Microcontroller Unit (MCU) as a beacon and a scanner for locating individuals inside a campus. Since Bluetooth low energy has range coverage of 10 meter the scanner can scan for advertising packets in that range and consume less power during transmission and reception of the advertising packets. The problem associated was that the working of the system was based on the previously estimated location rather on the live locations calculated. Hence, the possibility of real time tracking and positioning is reduced. Kais Mekki et al., [4] have used BLE technology to obtain RSSI value of the user and implement RSSI LOG distance model alongside trilateration algorithm to obtain position coordinates of the user. Paper explains how BLE is a better technology for indoor positioning as it balances cost, complexity, and accuracy trade-offs effectively. It is also evident that MQTT is a much reliable lowlevel protocol to handle many-to-one connection for our specific need. The hardware used is ESP32 which acts as both Bluetooth transmitter and receiver with built-in WIFI module. This configuration was found be the perfect match for our proposed work. Syed Abdullah Fadzli et al., [5] explain the technique to find the shortest distance between two points or coordinates. This paper helps to generate a floor plan consisting of all the nodes as rows and has links as paths. Also, a table can be generated to list out the path, length of path, degree of turns, the nodes of the path and directions to reach destination from source. At each node, the mobile robot is subject to execute one of these commands, by guiding the robot from starting point to destination. Mobile phones running on Android 8.0 or above support Bluetooth 5 which enables them to advertise data packets using BLE, using this the mobile device itself can be used as a beacon to advertise data thus eliminating the need for additional BLE tags or beacons. In this paper we combine the previous works done in various different papers in order to design an indoor positioning system using BLE enabled mobile phones as advertisers, ESP32 as receivers along with the help of techniques such as RSSI LOG distance model, trilateration algorithm, Dijkstra's algorithm for position estimation and navigation and MQTT and TCP protocols for communication between the hardware. III. METHODOLOGY This paper aims to come up with an indoor navigation system providing a mobile application that helps the users to navigate inside a building without any use maps or personnel. Detecting the location of a user in an indoor facility and navigating the person to the desired location can be achieved by using the following concepts and technologies -RSSI to distance calculation, Trilateration, MQTT Protocol for communication between ESP32 stations and PC, TCP protocol for communication between user (mobile device) and PC and Dijkstra's algorithm for path planning.

A. RSSI to Distance Calculation
Received Signal Strength Indicator (RSSI) helps in determining the signal strength from transmitter obtained on the receiver. The signal strength is mainly influenced by distance between transmitter -receiver and broadcasting power value from transmitter [6]. There could be a considerable amount of variance from the measured RSSI value. To overcome this condition, we use mean or averaged value from the received RSSI values for a defined time interval and then process the value further, this increases the accuracy of the obtained value. The distances between the mobile equipment and each close by receiver station (ESP32) can be estimated using RSSI to Distance Calculation technique. This calculation uses log path loss model based on the relation of the distance to the RSSI value. Formula: ( As shown in the equation 1, "d" is the actual distance between mobile device and the ESP32 receiver station. RSSI (d0=1m) is the obtained RSSI reference value measured having transmitter (mobile device) at a distance d0 =1 meter from the ESP32 receiver station and "e" is the path loss exponent which is influenced by the environmental factors such as interference, reflections and diffraction which ranges from 2 to 4. Based on different environment conditions Table 1 lists some distinctive values for e [4]. Note that Signal propagation with obstacles around is the reason for causing errors in calculation of RSSI values as the received RSSI values in the communication process are live they are subjected to error at times converting RSSI values to distances.

B. Trilateration
Trilateration is a technique used to calculate the relative location of the user with the help of distances obtained from the measured RSSI values. Trilateration calculations estimate distance of the mobile device (user) from the ESP32 receivers and estimate the relative position of the user using the fixed coordinates of the nearby ESP32 receivers. This method uses the overlapping area formed by three circles of receiving station to determine the exact position of the user providing an area of localization for given distances.
In Fig. 1 circles represent all the possible locations of a mobile device at a given distance (radius) of ESP32 receiver. The purpose of a trilateration technique is to calculate the coordinates (x, y) i.e., the intersection point of the three circles. Least Square (LSQ) method is an efficient way to determine the position of the mobile device [7]. The coordinates of each ESP32 receiver (i.e., ESP-1(x1, y1), ESP-2(x2, y2), ESP-3(x3, y3)) as shown in Fig. 1 are utilized to determine the coordinates of the BLE device (x, y), which indicates the location of the user.

Fig. 1 Trilateration
As shown in Fig. 1 to calculate the position coordinates of the user (BLE device): The centres of the three circles ((x 1 , y 1 ), (x 2 , y 2 ), (x 3 , y 3 )) are the predefined coordinates of ESP32 receivers whose intersection is the required coordinate. The radii of each circle are the distances between each ESP32 and the user. For which each circle the equation is: (4) Expanding and Subtracting the equations accordingly, we get (10) The x and y values from equation 9 and 10 indicate the user co-ordinates obtained from the trilateration procedure.

C. TCP Protocol
Transmission Control Protocol (TCP) is a protocol that establishes a virtual connection between two processes and maintains it till the completion of data transmission between them. TCP works based on Internet Protocol (IP) which defines how packets of information are exchanged between computers. TCP is a connection-oriented protocol, it uses three-way handshake process i.e. data transmission is done in 3 distinct steps: connection establishment, data transfer and connection termination.

Fig. 2 TCP Communication
In TCP process-to-process communication is achieved using port numbers which organizes the data such that there is secure transmission of data between two processes, as shown in Fig. 2. TCP offers full-duplex service, which enables simultaneous flow of data between two processes in both the direction at the same time. It is a reliable transport protocol that guarantees the integrity of information sent over the network regardless of the amount. i.e. each transmission of data packet has a feedback acknowledgment which lets the sender know that the data packet is received at the correct destination successfully. TCP is a byte-oriented protocol enabling many features such as error control, flow control and congestion control which makes this protocol light and more reliable at the same time.

D. MQTT Protocol
Message Queuing Telemetry Transport (MQTT) is stated as ISO standard publish-subscribe based messaging protocol which is used for connections with limited or restricted bandwidth. As shown in Fig. 3, MQTT protocol consists of clients and broker referred as server communicating with one another. Here, publishers and subscribers both are termed as MQTT clients. Broker acts as an intermediate between multiple clients, each client (Publisher) sends the data to broker first where the data waits for other clients (subscribers) which have the access to that data to retrieve it from broker, this operation is also known as publishing and subscribing of data respectively. The broker is responsible for all transmission of data between clients, it determines which subscribing clients have access to the published data, it also manages multiple publishing and subscribing requests at the same time. So, the broker here is the one that handles the publishing/subscribing actions to the target topics and thus the publisher has no information to which client its data has been shared too.

Fig. 3 MQTT Communication
The publisher client sends the data to be transmitted to the broker along with the information necessary to establish connection, details of subscriber clients who have access to the data. After establishing the connection broker shares that information to all the clients subscribed to that topic. If there is any data sent to a topic which does not have any subscribers, the broker discards the data unless the publisher has indicated it to retain the data in that topic. This ensures that the subscribers always have the most recent data in the topic.

E. Dijkstra's Algorithm
For a user to navigate from source to destination via shortest and most feasible path, suitable path planning algorithms should be used. Dijkstra's algorithm is one such robust algorithm which is used for finding the shortest path between two points, it uses weighted graph which defines distance between each node to find the shortest possible route. Dijkstra's algorithm creates a tree of shortest paths called shortest path tree from the source point to all other points in the weighted graph. It creates two different set of nodes namely: permanent set and tentative set.

Fig. 4 Dijkstra's Algorithm
As shown in Fig. 4, initially the root node is moved to the tentative list. Considering the least cumulative cost of all nodes in the tentative list, all neighbours of root node are added to tentative list and root node is moved to the permanent list. Now the node with shortest cumulative cost is selected from all nodes in the tentative list and is moved to the permanent list with all its neighbouring nodes still in tentative list. This process is continued till the tentative list is empty. Thus, shortest path tree is obtained.

Fig. 5 Block Diagram
The Fig. 5 represents the Block diagram in which Block-1 is a mobile application where the device is set to advertising mode by publishing unique ID and RSSI value and establishes a TCP connection between personal computer (PC) and mobile device to send the destination details and unique ID. Block-2 is a ESP32 hardware module representing the receiver station or scanner consisting of Bluetooth module for scanning nearby BLE advertisers within its vicinity and get unique IDs and RSSI values of all nearby mobile devices scanned and WIFI module sends the collected data to the PC using MQTT protocol. Block-3 is a router that establishes a Local area network (LAN) and acts as a gateway for all the communications between the modules. Block-4 is a PC consisting of three subunits. Unit-1 is the server (Mosquitto broker) used to receive the data published from the ESP32 modules, Unit-2 is the Subscriber client application subscribed to Mosquitto broker and Unit-3 is the TCP application which communicates the data between mobile device and PC acting as both server and client. For the process of Navigation, initially the user selects the destination from the mobile application and the Device is set to advertising mode by publishing unique ID and RSSI. A TCP connection is established between PC and device. The destination addresses and unique ID is sent to PC via TCP. ESP32 Scans all available nearby BLE advertisers at certain interval within its vicinity and get unique ID and RSSI values of all nearby devices scanned. The unique ID and RSSI are sent to the PC using MQTT protocol. Here the PC acts as both server (Mosquitto Broker) and subscriber client to receive the data from the ESP32. The data received from ESP32 stations and user application via MQTT and TCP respectively are validated and the distance between each user and station is calculated using RSSI LOG distance model. Further Trilateration algorithm is initiated to get the coordinates of the user and Dijkstra's algorithm is applied between user location and destination for shortest path. The Directions calculated are sent to user application via TCP. The user application displays the directions received on the user interface and the TCP connection is terminated on arrival to destination. For general implementation, as shown in Fig. 6 ESP 32 receivers are placed along the corridors in the facility which scans for BLE data packets. Users use mobile phones to advertise BLE data packets at regular intervals. All ESP32 modules are connected to PC via a gateway through which they send all scanned data. Users send their destination and mobile device data to PC via TCP communication. PC processes all received data and finds the shortest path for the user among all the possible paths available. Users navigate to their destinations using this system while they are tracked continuously, and path is updated in real time. The detailed implementation steps at individual blocks are as follows: 2) Device is set to advertising mode and is publishing its unique ID.
3) TCP connection is established between PC and device. 4) Send the destination address and unique ID to PC via TCP.
B. ESP32 Stations 1) Scan all available nearby BLE advertisers at certain interval.
2) Acquire unique ID and RSSI values of all nearby devices scanned.
3) Send the unique ID and RSSI to the connected PC using MQTT protocol.

C. Positioning and Path Planning of User (in PC)
1) Listen to all the data sent by ESP32 stations and user application via MQTT and TCP, respectively. 2) Using RSSI LOG distance model, find distance between each user and station.
3) Trilateration algorithm is initiated to get the coordinates of the user. 4) Dijkstra's algorithm is applied between user location and destination for shortest path.

5) Direction is sent to user application via TCP.
User is navigated to the destination and the connection is terminated on arrival at the destination.

V. RESULTS
The implementation of indoor navigation system as shown in Fig. 7 was done with the use of android application as Bluetooth transmitter and ESP32 module as Bluetooth receivers. The mobile application advertises BLE data packets at regular intervals which were picked up by ESP32 receivers placed at strategic positions inside the building. This system was tested in a small closed indoor environment which emulated the environment where the system could be deployed. Eight ESP32 modules were placed such that at least 3 receivers get signal from the mobile users at all times, we declare Nodes A, B, C, D… respectively where each node represents a start end or a turning point in the testing environment. The ESP32 receivers scan for BLE devices in the vicinity and publish RSSI values and Unique ID of those devices to an MQTT broker. The data sent by all the receivers is processed to find the position coordinates of the mobile user inside the building. User selects the destination in the mobile app which is connected to the processor over the same local area network. The processor sends directions to the mobile user based on their real time locations determined by trilateration algorithm and distances calculated using RSSI LOG distance model.  As shown in Fig. 8 the system finds live coordinate of the user and starts directing the user to the destination starting from the closest Node to him at that point of time. The path is calculated from that node using Dijkstra's algorithm and navigation of the user is started. The path list is then modified as and when the user reaches next node, this is repeated till the user reaches destination. The android applications as shown in Fig. 9 was designed to help the user to navigate themselves to the preferred destination without relying on any external maps or personnel in an indoor facility. In contrast to previous works where similar systems were able to detect location of a user with an accuracy around 1.5 meter but with longer scan time (i.e. 20sec) [4] or few which used additional devices(beacons) to get an accuracy of 2.3meters [6]. This system provides similar accuracy around 1.5 meter with lesser scan times(4-6sec) and uses Bluetooth of mobile phones eliminating the need for additional beacons. Hence it can be used for various real time applications like indoor navigation as shown in this paper.

VI. CONCLUSION
In the proposed indoor navigation system, the positioning of the user was done using BLE technology. Using the concept for IPS we were able to reduce BLE scan time while maintaining enough accuracy for the system to be feasible for real time applications like live tracking and indoor navigation. The logarithmic changes in RSSI value of Bluetooth energy transmitted with respect to change in distance from transmitter and receiver is used to estimate the distance between the mobile user and each receiver, this combined with trilateration technique was used to determine the position coordinated of the user. The estimated position has enough accuracy to be used for navigation in an indoor facility. In future we plan on improving the accuracy of the system even more by reducing errors in distance estimation of mobile user from the receivers, improve the UI of mobile application, optimize the receivers to consume less power and look at the possibilities of running them remotely on batteries.