# IoT-Based Smart Management of Healthcare Services in Hospital Buildings during COVID-19 and Future Pandemics

Authors: Omid Akbarzadeh; Mehrshid Baradaran; Mohammad R. Khosravi
Journal: Wireless Communications and Mobile Computing
 (2021)

---

## Abstract

The paper aims to design and develop an innovative solution in the Smart Building context that increases guests’ hospitality level during the COVID-19 and future pandemics in locations like hotels, conference locations, campuses, and hospitals. The solution supports features intending to control the number of occupants by online appointments, smart navigation, and queue management in the building through mobile phones and navigation to the desired location by highlighting interests and facilities. Moreover, checking the space occupancy, and automatic adjustment of the environmental features are the abilities that can be added to the proposed design in the future development. The proposed solution can address all mentioned issues regarding the smart building by integrating and utilizing various data sources collected by the internet of things (IoT) sensors. Then, storing and processing collected data in servers and finally sending the desired information to the end-users. Consequently, through the integration of multiple IoT technologies, a unique platform with minimal hardware usage and maximum adaptability for smart management of general and healthcare services in hospital buildings will be created.


---

## Body

## 1. Introduction

During the COVID-19 pandemic, high-tech solutions like the Internet of Things (IoT) for smart buildings have been critical in keeping our urban societies functional [1–2]. The aim of highlighting the smart building with IoT technologies is to identify COVID-19 cases, decrease the spread, and reduce the impact of the pandemic. Smart buildings, supported by IoT, were primarily relied upon for security, automated management and control, increasing energy efficiency, safety, usability, and accessibility. Furthermore, as lockdown eases, they will also help manage building occupancy levels and social distancing [3–5].This research is aimed to improve smart buildings’ features by adding queue management, smart navigation of places to minimize people connection, and social distancing safety mechanisms. Besides, environmental advancement features to increase people’s safety are features that this project can offer in the subsequent development [6–8].This solution implements through several steps can be seen in Figure1. Our model-building to develop our proposed solution is a hospital, which is the most demanded place to make it smart based on surveys [9–12]. As the first step, sensors’ positioning is deployed using our Building Information Modeling (BIM) and mathematical formulation. Next, the data will send to the gateway through several specific protocols. Then, received data will be stored in the servers and processed through the designed middleware; consequently, the processed data sent to the mobile application, shown in Figure 2 [13–16]. The presented platform’s primary thinking is to propose an application that users can control through their smartphones using the data gathered through sensors and beacons located in the different parts of a hospital [17–20]. IoT would be the best solution to combine all collected information and send it to the end-users [20].Figure 1
A workflow depicts the general steps and components required for the implementation of the project.Figure 2
The image shows the BIM model of the building used for deploying sensors.Since position determining is considered a significant section of these solutions, we have intensely focused on position determining. Previous efforts with indoor positioning systems focus on statistical fingerprinting methods, mainly using 802.11 (WLAN) as the platform. Some efforts were made with purely signal strength-based positioning, but indoor environments have shown to work unfavorably for these kinds of methods [21–23]. The novelty of our presented platform is to take advantage of previous efforts and customize and optimize them to grant them the ability to implement in an actual project since most of the earlier efforts were limited to computer simulation. Moreover, regarding the previous efforts, developing a mobile application that offers the mentioned services to the end-users can be considered a unique feature of the proposed platform [1, 24–30].One of the major functionalities of the smart building is in healthcare, as a smart hospital. Due to the COVID-19 pandemic, the hospital’s occupancy level and social distancing are critical to reducing the communication between patients and medical staff to reduce the spread of COVID-19 pandemic cases [31–37]. Moreover, in the COVID-19 pandemic and other viral illnesses, taking good patient care is practical [38–42].Our proposed design’s supremacy provides a wide range of practical information for end-users, such as a list of exams and queuing guidance to the next room and direction to the desired destinations [43–46]. Furthermore, this scheme provides information about the point of interest, like the number of people, waited in line for service and accessibility of that service at that time [47–52]. Besides, this scheme notifies end-users about breaking the social distance in the situation of the COVID-19 pandemic.In Section3, we discuss the methodologies used in the proposed technique. Furthermore, in this section, we discuss the positioning and related components such as Bluetooth low energy, beacons, and concepts to provide a detailed project definition. Then, in Section 4, we discuss the information collected through surveys and their application to show the mobile application’s primary outcome, particularly for the COVID-19 case [53–57].


## 2. Related Work

The modern technologies used for indoor positioning are intensively various in terms of accuracy, cost, and maintenance requirements, e.g., most of them have concentrated on IEEE 802.11, known as Wi-Fi. Even though the previous works in this field have achieved acceptable results, they have not used power-efficient wireless technology, such as 802.11. But regarding Bluetooth, the initial attempts to use this technology for postponing purposes do not show promising results [5]. Since many parts of earlier versions of Bluetooth standard are not suitable for positioning. The two main problems of positioning technologies, alongside energy efficiency, are the clock accuracy and the received signal strength indication (RSSI) value that affect the expected accuracy level. Unfortunately, we have not found any closely related articles in time-based positioning with a dedicated focus on this.On the other hand, related work focused on the correlation between distance and RSSI [6]. Although this correlation is practical, the accuracy level is limited in this case. The concept of fingerprinting is a subject of other studies focused on positioning technologies as well. In the Bluetooth-based systems, all the desired location is covered with BLE beacons that constantly propagate their presence. Then, the device planned to be located computes all the received propagations’ signal strength and compares those and a precompiled database of locations. Consequently, selecting the best match can achieve an accuracy level of fewer than 3 meters with a very high level of precision [7]. Some papers also focus on Bluetooth, old versions, not BLE, which might have different properties making it more useful for other methods such as RSSI-based ones.There is almost no clear standard to address several existed commercial indoor positioning systems on the market. In fact, the technology providers do not specifically describe their products. Moreover, the used method and expected level of accuracy are not determined. However, most of them rely on the 802.11 standard, which makes them inherently power inefficient. They are typically used for positioning people, either for navigation or location-specific information such as commercial offers at retail locations or tour information.Table1 shows a selection of positioning techniques available for indoor use. Regarding GPS as a reference, the numbers are estimated, and both power consumption and accuracy may vary in the systems based on similar designs. The power figures are measured in the active condition, and it is not directly comparable between each other. Some technologies are energy efficient (drastically less than technology with similar active state power, but setup times are longer).Table 1
Small overview of positioning features technologies using wireless technology.
Wireless technologyPower efficiencyApplication (social/industrial)Positioning accuracyAdvantageDisadvantageSome related resourcesOur proposed architectureHighSocial (health, commercial, etc.)HighLow-pricen/a—Ultrawideband (UWB)Low (relatively)GeneralHighEasiness for implementationTechnology availability#ref [5-8]GPS and similar satellite-based modelsLow (relatively)GeneralAverageEasiness for implementationHigh-price#ref [5-8]802.11 fingerprintingLow (relatively)GeneralHighTechnology availabilityDifficulty for implementation#ref [5-8]802.11 time differential laterationLow (relatively)GeneralAverageTechnology availabilityDifficulty for implementation#ref [5-8]Bluetooth fingerprintingHighGeneralAverageLow-priceDifficulty for implementation#ref [5-8]Cellular proximityAverage (relatively)GeneralVery lowTechnology availabilityHigh-price#ref [5-8]Therefore, the absence of technology with less than ten meters of accuracy and an acceptable level of power efficiency can be considered the main issue. UWB and BLE-based systems are considered two options that look particularly promising, and both can be used for indoor positioning. Cost and accuracy expectations are still crucial for different technologies and critical while selecting a wireless technology. This paper focuses on BLE-based systems since BLE is deployed in mobile phones and wearable electronics, and it is expected to grow rapidly in its usage. BLE-based systems provide many economic advantages such as low-cost, low-power, and high availability of devices. Moreover, the BLE-based systems would compete with UWB for accuracy and resolution, but as mentioned, lower prices and more availability of technology [8].


## 3. Proposed Method

### 3.1. General Architectures

This section talks about the methodology used by the proposed system presents the block diagram of the working of the system at the user end Figure3. Regarding the provided graph, Figure 3, counter sensors and Bluetooth low energy (BLE) beacons are considered the source of data that sends their data to the gateway through Message Queuing Telemetry Transport (MQTT) messages. The main idea is to propose the people counting with minimum error using three sensors in each door. These three sensors should work concurrently and calibrate in a single code. The gateway can implement each sensor data using wired or wireless communication. The working principle is a simple IN-OUT principle. Whenever a person goes through the inside (dedicated direction for every room), the optimized data will increase the room’s total number. Otherwise, it will decrease. According to the provided workflow, we have a BIM model that includes information about the geometry and generally considered a database.Figure 3
This workflow shows the connection between the different components of the system as well as using technologies.Furthermore, communication between different blocks of the mentioned workflow performs through MQTT, REST API, and Bluetooth protocols. Admin DASHBOARD is a tool to help the end-user to control the data. Regarding the database, Mongo D.B. and Studio3T are used for this purpose; also, Thingsboard.io is used as the control dashboard.


### 3.2. Positioning

To discuss the concept of positioning, a brief introduction of basic concepts is necessary, mentioned in the following sections.


#### 3.2.1. Proximity

One of the easiest positioning methods is to check that the object is present in radio coverage without considering the received signal strength indicator (RSSI) or arrival time. The resolution offered is the same as the radio coverage, as it would only differentiate between two states, present and not present. Accuracy will increase through combining several radios at different positions and taking advantage of their coverage areas overlap to determine the object’s precise situation.


#### 3.2.2. Ranging Concept

The procedure of distance determination between two objects, without considering the angle. It is also the basic concept utilized for lateration. To accomplish this purpose, several methods were studied. The two most popular approaches in radio ranging are according to received signal strength or time of flight. The formulation between signal strength and distance is expressed as “d=20^RSSI+α” in the free space. In the previous formula, α is an offset according to the maximum received signal strength of the system. However, this formulation is an inaccurate estimation for indoor positioning use cases since indoor areas contain many obstacles such as walls and furniture. It is worth noting that the obstacles are the primary reasons for multipath effects that lead to the complication of the relation between distance and RSSI and reduce accuracy.


#### 3.2.3. Lateration Concept

Using multiple range measurements determines one object’s position. When the range is measured from several certain positions, each measurement is considered a circle or sphere of possible positions at that range. Combining several measurements and calculating the junction of the measurements lead to the estimation of position. For example, the mentioned procedure is depicted using three beacons located at a different distance from the object.


### 3.3. Bluetooth: Low-Power Tool

BLE is a low-power radio standard Introduced in the Bluetooth 4.0 standard. Keeping Bluetooth as part of its name does not mean complete backward compatibility with the earlier Bluetooth versions. Bluetooth 4.0 standard specifies two different kinds of radio interfaces, first, compatibility with the previous standard, known as Basic Data Rate (B.R.) or Enhanced Data Rate (EDR). Second, the dual-mode and single-mode can support BR/EDR or BLE, provided through Bluetooth 4.0. The directionality of the antenna is a primary consideration that should be considered with all BLE-enabled devices. Using small antennas leads to the property of nonisotropic radiation patterns. Therefore, in most positioning scenarios, due to antenna directionality and the size of obstacles, adding an external antenna to these devices cannot be considered as a solution. This problem can be addressed using relative signal strengths instead of absolute ones when position determination performs through multiple signals.


#### 3.3.1. Radio Interface

The radio interface is one of the drastic changes regarding the earlier Bluetooth versions. BLE takes advantage of a 2.4 GHz ISM band. Moreover, BLE uses 40 channels with 2 MHz bandwidth instead of 79 tracks with 1 MHz bandwidth. As a solution, the permitted broadcast channels are reduced to three to reduce the scanning time.


#### 3.3.2. BLE and Positioning

Regarding the exposure to BLE devices, the services experience a new approach, and the standard itself contains multiple services. Two service profiles containing the positioning are included. Find Me Profile (FMP) and Proximity Profile (PXP). The application of FMP, which is the “Find Me Profile,” is to locate the devices easier in case of loss. Two devices are needed To perform the FMP procedure, one is the locator, and the other is the target that wants to be found.Furthermore, the server would be our target that listens for requests from the locator. Then, the target device will be notified whenever a request arrives. The notification would be a visual or auditory signal in most cases, which helps locate the device easier. The other use case of the previous notification approach is to trigger a broadcast, or through this, the device can position itself and report back with the estimated position. This standard contains another location-based service concept that is considered PXP. It defines the behavior of a device in the case of loss or connection establishment. This service is practical for a positioning platform, and it relies on the devices establishing connections. This issue leads that both PXP and FMP suffer the same problem. Where battery life is not a consideration, both profiles may be helpful in applications. iBeacon is a commercial product by Apple that provides positioning service with compatible devices and a wide range of mobile phones and computer support; however, this is not a standard profile. This is a two-way system, and its performance is the same as PXP [1].


#### 3.3.3. Positioning Based on BLE Proximity

On a larger scale, there are many disadvantages regarding fingerprinting. Since more accuracy is unnecessary, simpler proximity or ranging systems can reduce the cost of a complete system. The fingerprint’s implementation cost is dependent on the covered area. Therefore, a fingerprint-based system would not be the first option for indoor positioning. However, it would be an efficient idea to use the concept of fingerprinting to improve other solutions.


### 3.4. Beacon

The beacons frequently broadcast their I.D. and then sleep for 500 ms. The broadcast was intended only to send on the lowest of the three available channels. It is impossible to use the same program for all beacons since different hardware platforms use. However, the low complexity of the programs does not have a destructive effect on the overall system performance. The main reason for utilizing just one announcement channel is to minimize the spread created through small changes in channel properties for different frequencies.Consequently, this reduces the fingerprint complexity. Otherwise, each beacon should be considered three times, one for each frequency. The beacons should enable to respond and provide some data to a local application where the device locate. It can be seen that this data delivery functionality and special software requirements on the devices lead to a complicated system.


#### 3.4.1. Density and Beacon Locating Strategy

This procedure defines to receive the best performance how dense beacons are needed to locate. In a small place, the deployment of many beacons possibly only adds to noisy measurements and degrades performance. The cost and power consumption of a full-scale system should be precise before commercial deployment. To determine worst-case and best-case scenarios, this should be performed in the different radio environments to collect enough data. One way to address it is to use an overlapping quantized ranging model. The RSSI of several beacons use to determine the user’s location, similar to an overlapping proximity system. However, using RSSI can be mapped to distance with low precision. This system will not impose an extra cost than a pure proximity-based one but with the same level of accuracy that practical if the positioning is only limited to the room level or similar.


### 3.5. MQTT Basic Definition

In IoT systems, the sensors are not autonomous to decide what to do. Sensors are responsible for sending their measurements to a central location for processing purposes in an IoT system. Then, whoever needs these data should be subscribed to them. Therefore, they would be able to process them and respond. For example, a switch can notify that it has been switched, or a temperature sensor can inform about the measured temperature. The following central location forwards all this data to the respective subscribers. This feature addresses the changes in application requirements and adds new functions.


### 3.6. Positioning Algorithm

This procedure performs using user position estimation through these steps. As the first step, distance estimation is performed. Two parameters are defined: RSSI (the measured power) and Tx-power (the transmitted power). A ratio between RSSI and Tx-power is defined as piecewise in Eq. (1) and Table 2 to estimate the distance. Additionally, by knowing the Beacons’ positions and the distance of users from beacons using the circle’s inverse equation, the position will estimate Figure 4. It can be shown by increasing the estimated distance; the received power will be decreased Figure 5.Table 2
The table defines the constants used in Eq. (2) empirically.
ConstantΑβγValue0.8897.78950.111Figure 4
Trilateration-based positioning system [1].Figure 5
A curve that shows the relation between signal strength at the receiver and distance could be viewed by increasing the distance signal power decreases exponentially.Moreover, Figure6 shows how people counter sensors placed in the desired building. After sensors calibration, each door will have its counting value; we use it to find the exact number of people in each dedicated place. In this simple algorithm, s1room1=R1 is the first room in the building, and in this room, we have just one door counting because the room value is equal to the s1 (door1 calibrated sensor value). When looking at room4=s7−s6−s8, which means dedicated directions of this room are inside (+) and outside is (-), and in this room, we have s7, s6, s8 (door7, door6, door8). Whenever a person comes inside room4, using s7 will increase the total number of room4; whenever a person goes outside using s6 and s8, that will decrease the total people number in room4 Figure 7. Directions are dedicated to whatever the user wants to modify the algorithm based on the dedicated paths.
(1)Ratio=RSSITx−powerd=10RatioRatio≤1,αγβRatioRatio>1.Figure 6
Part (a) depicts the position of people counter sensors, and part (b) shows the positions of BLE sensors in the building.
(a)(b)Figure 7
The procedure used to implement the people counting sensor.


#### 3.6.1. People Counting Sensors

The main idea is to propose the people counting technique with minimum error using three sensors in each door. These three sensors should work concurrently and calibrate in a single code. The gateway can implement each sensor data using wired or wireless communication. The working principle is a simple IN-OUT principle. Whenever a person enters the room (dedicated direction for every room), the optimized data will increase the room’s total number. Otherwise, it will decrease. In addition, there is a Sensor (T1), a thermal sensor (which helps not count anything else except person), and can detect the person’s direction. On the left and the right side, sensors can help to detect the movement of the people. In this project, all the connected sensors to the gateway with MQTT protocol are processed with some multithread C code to compute the IN-OUT number (Figure8).Figure 8
image shows the simple IN-OUT principle.


#### 3.6.2. Algorithm of the Counting with Three Sensors

First, subscribe to the MQTT broker to get all three-sensor data. We could subscribe and get the current data and use it. In the following, we will provide algorithms to show how to subscribe MQTT server. Here, the coding algorithm shows how the code should modify in every selected sensor in the actual testing algorithms1–5, subscribing to the three sensors’ data topic and creating five threads working concurrently in the process. We have five conditions to change the value of the final value of the three sensors.Algorithm 1: It shows the main process.
/∗subscribe to MQTT broker ∗/mqtt_subscribe(&client, topic, 0);/∗ start publishing the time ∗/printf(“%s listening for ‘%s’ messages.\n”, argv[0], topic);printf(“Press CTRL-D to exit.\n\n”);/∗ block ∗/while(fgetc(stdin) != EOF);/∗ disconnect ∗/printf(“\n%s disconnecting from %s\n”, argv[0], addr);sleep(1);/∗ exit ∗/exit_example(EXIT_SUCCESS, sockfd, &client_daemon);Algorithm 2: Getting the sum value (last value of the three sensors) and publishing it to the broker to calculate the number of people in each room.
pthread_t pid1, pid2, pid3, pid4, pid5;t1= pthread_create(&pid[i], NULL, thread1, (void∗) &input1);if(t1){printf(“Error creating thread1%d!”, i);return -1;t2= pthread_create(&pid[i], NULL, thread2, (void∗) &input2);if(t2){printf(“Error creating thread2%d!”, i);return -1;t3= pthread_create(&pid[i], NULL, thread3, (void∗) &input3);if(t3){printf(“Error creating thread3%d!”, i);return -1;t4= pthread_create(&pid[i], NULL, thread4, (void∗) &input4);if(t4){printf(“Error creating thread4%d!”, i);return -1;t5= pthread_create(&pid[i], NULL, thread5, (void∗) &input5);if(t5){printf(“Error creating thread5%d!”, i);return -1;Algorithm 3: If sensor S1 and sensor T1 detect the movement in the same way and +1 direction, it will increase the total value.
/∗ Thread-2 ∗/void∗ thread2(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == OUT && T1 == OUT){/∗if sensorS1 and sensorT1 detectthe movement in the sameway and -1 direction it willdecrease the total value.∗/room --;}while(1); /∗loop forever∗/}Algorithm 4: If sensor S1 and sensor T1 detect the movement in the same way and -1 direction, it will decrease the total value.
/∗ Thread-1 ∗/void∗ thread1(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == IN && T1 == IN){/∗if sensorS1 and sensorT1 detect the movementin the same way and +1 direction itwill increase the total value.∗/room ++;}while(1); /∗loop forever∗/}Algorithm 5: Using the thermal sensor data described in C.
/∗ Thread-5 ∗/void∗ thread5(void ∗ unused){int∗value;value = (int∗) unused;if(S2 == OUT && T1 == OUT && S1 == OUT) || (S2 == IN && T1 == IN && S1 == IN){room (--)(++);}while(1); /∗loop forever∗/}


### 3.7. Middleware

In this section, we focus on the middleware block and its related connection and definition. Furthermore, we have provided several images of the operation of our middleware Figure9. Middleware block is software that serves as an interface between the end-users and other hardware components to aggregate and filter received data from the hardware components, perform information discovery, and provide access control to the end user’s application.Figure 9
Image focused on the middleware section and used components and performed operations.


#### 3.7.1. Receiver

The receiver controller would be considered the crucial part of the software. The receiver works with a straightforward C-program responsible for transferring BLE packets between the gateway and the BLE host controller. Packet transform performs as raw streams of data. They should decode in software to be helpful to address the essential required functions in all the experiments with the aim of code recycling maximization, for example, initialization of the host controller, initializing the radio, and scanning enabling/disabling. Support for suitable packet encoding and decoding is limited since it is time-consuming. Therefore, it does not have a significant positive point for these types of positioning systems implemented here.


## 3.1. General Architectures

This section talks about the methodology used by the proposed system presents the block diagram of the working of the system at the user end Figure3. Regarding the provided graph, Figure 3, counter sensors and Bluetooth low energy (BLE) beacons are considered the source of data that sends their data to the gateway through Message Queuing Telemetry Transport (MQTT) messages. The main idea is to propose the people counting with minimum error using three sensors in each door. These three sensors should work concurrently and calibrate in a single code. The gateway can implement each sensor data using wired or wireless communication. The working principle is a simple IN-OUT principle. Whenever a person goes through the inside (dedicated direction for every room), the optimized data will increase the room’s total number. Otherwise, it will decrease. According to the provided workflow, we have a BIM model that includes information about the geometry and generally considered a database.Figure 3
This workflow shows the connection between the different components of the system as well as using technologies.Furthermore, communication between different blocks of the mentioned workflow performs through MQTT, REST API, and Bluetooth protocols. Admin DASHBOARD is a tool to help the end-user to control the data. Regarding the database, Mongo D.B. and Studio3T are used for this purpose; also, Thingsboard.io is used as the control dashboard.


## 3.2. Positioning

To discuss the concept of positioning, a brief introduction of basic concepts is necessary, mentioned in the following sections.


### 3.2.1. Proximity

One of the easiest positioning methods is to check that the object is present in radio coverage without considering the received signal strength indicator (RSSI) or arrival time. The resolution offered is the same as the radio coverage, as it would only differentiate between two states, present and not present. Accuracy will increase through combining several radios at different positions and taking advantage of their coverage areas overlap to determine the object’s precise situation.


### 3.2.2. Ranging Concept

The procedure of distance determination between two objects, without considering the angle. It is also the basic concept utilized for lateration. To accomplish this purpose, several methods were studied. The two most popular approaches in radio ranging are according to received signal strength or time of flight. The formulation between signal strength and distance is expressed as “d=20^RSSI+α” in the free space. In the previous formula, α is an offset according to the maximum received signal strength of the system. However, this formulation is an inaccurate estimation for indoor positioning use cases since indoor areas contain many obstacles such as walls and furniture. It is worth noting that the obstacles are the primary reasons for multipath effects that lead to the complication of the relation between distance and RSSI and reduce accuracy.


### 3.2.3. Lateration Concept

Using multiple range measurements determines one object’s position. When the range is measured from several certain positions, each measurement is considered a circle or sphere of possible positions at that range. Combining several measurements and calculating the junction of the measurements lead to the estimation of position. For example, the mentioned procedure is depicted using three beacons located at a different distance from the object.


## 3.2.1. Proximity

One of the easiest positioning methods is to check that the object is present in radio coverage without considering the received signal strength indicator (RSSI) or arrival time. The resolution offered is the same as the radio coverage, as it would only differentiate between two states, present and not present. Accuracy will increase through combining several radios at different positions and taking advantage of their coverage areas overlap to determine the object’s precise situation.


## 3.2.2. Ranging Concept

The procedure of distance determination between two objects, without considering the angle. It is also the basic concept utilized for lateration. To accomplish this purpose, several methods were studied. The two most popular approaches in radio ranging are according to received signal strength or time of flight. The formulation between signal strength and distance is expressed as “d=20^RSSI+α” in the free space. In the previous formula, α is an offset according to the maximum received signal strength of the system. However, this formulation is an inaccurate estimation for indoor positioning use cases since indoor areas contain many obstacles such as walls and furniture. It is worth noting that the obstacles are the primary reasons for multipath effects that lead to the complication of the relation between distance and RSSI and reduce accuracy.


## 3.2.3. Lateration Concept

Using multiple range measurements determines one object’s position. When the range is measured from several certain positions, each measurement is considered a circle or sphere of possible positions at that range. Combining several measurements and calculating the junction of the measurements lead to the estimation of position. For example, the mentioned procedure is depicted using three beacons located at a different distance from the object.


## 3.3. Bluetooth: Low-Power Tool

BLE is a low-power radio standard Introduced in the Bluetooth 4.0 standard. Keeping Bluetooth as part of its name does not mean complete backward compatibility with the earlier Bluetooth versions. Bluetooth 4.0 standard specifies two different kinds of radio interfaces, first, compatibility with the previous standard, known as Basic Data Rate (B.R.) or Enhanced Data Rate (EDR). Second, the dual-mode and single-mode can support BR/EDR or BLE, provided through Bluetooth 4.0. The directionality of the antenna is a primary consideration that should be considered with all BLE-enabled devices. Using small antennas leads to the property of nonisotropic radiation patterns. Therefore, in most positioning scenarios, due to antenna directionality and the size of obstacles, adding an external antenna to these devices cannot be considered as a solution. This problem can be addressed using relative signal strengths instead of absolute ones when position determination performs through multiple signals.


### 3.3.1. Radio Interface

The radio interface is one of the drastic changes regarding the earlier Bluetooth versions. BLE takes advantage of a 2.4 GHz ISM band. Moreover, BLE uses 40 channels with 2 MHz bandwidth instead of 79 tracks with 1 MHz bandwidth. As a solution, the permitted broadcast channels are reduced to three to reduce the scanning time.


### 3.3.2. BLE and Positioning

Regarding the exposure to BLE devices, the services experience a new approach, and the standard itself contains multiple services. Two service profiles containing the positioning are included. Find Me Profile (FMP) and Proximity Profile (PXP). The application of FMP, which is the “Find Me Profile,” is to locate the devices easier in case of loss. Two devices are needed To perform the FMP procedure, one is the locator, and the other is the target that wants to be found.Furthermore, the server would be our target that listens for requests from the locator. Then, the target device will be notified whenever a request arrives. The notification would be a visual or auditory signal in most cases, which helps locate the device easier. The other use case of the previous notification approach is to trigger a broadcast, or through this, the device can position itself and report back with the estimated position. This standard contains another location-based service concept that is considered PXP. It defines the behavior of a device in the case of loss or connection establishment. This service is practical for a positioning platform, and it relies on the devices establishing connections. This issue leads that both PXP and FMP suffer the same problem. Where battery life is not a consideration, both profiles may be helpful in applications. iBeacon is a commercial product by Apple that provides positioning service with compatible devices and a wide range of mobile phones and computer support; however, this is not a standard profile. This is a two-way system, and its performance is the same as PXP [1].


### 3.3.3. Positioning Based on BLE Proximity

On a larger scale, there are many disadvantages regarding fingerprinting. Since more accuracy is unnecessary, simpler proximity or ranging systems can reduce the cost of a complete system. The fingerprint’s implementation cost is dependent on the covered area. Therefore, a fingerprint-based system would not be the first option for indoor positioning. However, it would be an efficient idea to use the concept of fingerprinting to improve other solutions.


## 3.3.1. Radio Interface

The radio interface is one of the drastic changes regarding the earlier Bluetooth versions. BLE takes advantage of a 2.4 GHz ISM band. Moreover, BLE uses 40 channels with 2 MHz bandwidth instead of 79 tracks with 1 MHz bandwidth. As a solution, the permitted broadcast channels are reduced to three to reduce the scanning time.


## 3.3.2. BLE and Positioning

Regarding the exposure to BLE devices, the services experience a new approach, and the standard itself contains multiple services. Two service profiles containing the positioning are included. Find Me Profile (FMP) and Proximity Profile (PXP). The application of FMP, which is the “Find Me Profile,” is to locate the devices easier in case of loss. Two devices are needed To perform the FMP procedure, one is the locator, and the other is the target that wants to be found.Furthermore, the server would be our target that listens for requests from the locator. Then, the target device will be notified whenever a request arrives. The notification would be a visual or auditory signal in most cases, which helps locate the device easier. The other use case of the previous notification approach is to trigger a broadcast, or through this, the device can position itself and report back with the estimated position. This standard contains another location-based service concept that is considered PXP. It defines the behavior of a device in the case of loss or connection establishment. This service is practical for a positioning platform, and it relies on the devices establishing connections. This issue leads that both PXP and FMP suffer the same problem. Where battery life is not a consideration, both profiles may be helpful in applications. iBeacon is a commercial product by Apple that provides positioning service with compatible devices and a wide range of mobile phones and computer support; however, this is not a standard profile. This is a two-way system, and its performance is the same as PXP [1].


## 3.3.3. Positioning Based on BLE Proximity

On a larger scale, there are many disadvantages regarding fingerprinting. Since more accuracy is unnecessary, simpler proximity or ranging systems can reduce the cost of a complete system. The fingerprint’s implementation cost is dependent on the covered area. Therefore, a fingerprint-based system would not be the first option for indoor positioning. However, it would be an efficient idea to use the concept of fingerprinting to improve other solutions.


## 3.4. Beacon

The beacons frequently broadcast their I.D. and then sleep for 500 ms. The broadcast was intended only to send on the lowest of the three available channels. It is impossible to use the same program for all beacons since different hardware platforms use. However, the low complexity of the programs does not have a destructive effect on the overall system performance. The main reason for utilizing just one announcement channel is to minimize the spread created through small changes in channel properties for different frequencies.Consequently, this reduces the fingerprint complexity. Otherwise, each beacon should be considered three times, one for each frequency. The beacons should enable to respond and provide some data to a local application where the device locate. It can be seen that this data delivery functionality and special software requirements on the devices lead to a complicated system.


### 3.4.1. Density and Beacon Locating Strategy

This procedure defines to receive the best performance how dense beacons are needed to locate. In a small place, the deployment of many beacons possibly only adds to noisy measurements and degrades performance. The cost and power consumption of a full-scale system should be precise before commercial deployment. To determine worst-case and best-case scenarios, this should be performed in the different radio environments to collect enough data. One way to address it is to use an overlapping quantized ranging model. The RSSI of several beacons use to determine the user’s location, similar to an overlapping proximity system. However, using RSSI can be mapped to distance with low precision. This system will not impose an extra cost than a pure proximity-based one but with the same level of accuracy that practical if the positioning is only limited to the room level or similar.


## 3.4.1. Density and Beacon Locating Strategy

This procedure defines to receive the best performance how dense beacons are needed to locate. In a small place, the deployment of many beacons possibly only adds to noisy measurements and degrades performance. The cost and power consumption of a full-scale system should be precise before commercial deployment. To determine worst-case and best-case scenarios, this should be performed in the different radio environments to collect enough data. One way to address it is to use an overlapping quantized ranging model. The RSSI of several beacons use to determine the user’s location, similar to an overlapping proximity system. However, using RSSI can be mapped to distance with low precision. This system will not impose an extra cost than a pure proximity-based one but with the same level of accuracy that practical if the positioning is only limited to the room level or similar.


## 3.5. MQTT Basic Definition

In IoT systems, the sensors are not autonomous to decide what to do. Sensors are responsible for sending their measurements to a central location for processing purposes in an IoT system. Then, whoever needs these data should be subscribed to them. Therefore, they would be able to process them and respond. For example, a switch can notify that it has been switched, or a temperature sensor can inform about the measured temperature. The following central location forwards all this data to the respective subscribers. This feature addresses the changes in application requirements and adds new functions.


## 3.6. Positioning Algorithm

This procedure performs using user position estimation through these steps. As the first step, distance estimation is performed. Two parameters are defined: RSSI (the measured power) and Tx-power (the transmitted power). A ratio between RSSI and Tx-power is defined as piecewise in Eq. (1) and Table 2 to estimate the distance. Additionally, by knowing the Beacons’ positions and the distance of users from beacons using the circle’s inverse equation, the position will estimate Figure 4. It can be shown by increasing the estimated distance; the received power will be decreased Figure 5.Table 2
The table defines the constants used in Eq. (2) empirically.
ConstantΑβγValue0.8897.78950.111Figure 4
Trilateration-based positioning system [1].Figure 5
A curve that shows the relation between signal strength at the receiver and distance could be viewed by increasing the distance signal power decreases exponentially.Moreover, Figure6 shows how people counter sensors placed in the desired building. After sensors calibration, each door will have its counting value; we use it to find the exact number of people in each dedicated place. In this simple algorithm, s1room1=R1 is the first room in the building, and in this room, we have just one door counting because the room value is equal to the s1 (door1 calibrated sensor value). When looking at room4=s7−s6−s8, which means dedicated directions of this room are inside (+) and outside is (-), and in this room, we have s7, s6, s8 (door7, door6, door8). Whenever a person comes inside room4, using s7 will increase the total number of room4; whenever a person goes outside using s6 and s8, that will decrease the total people number in room4 Figure 7. Directions are dedicated to whatever the user wants to modify the algorithm based on the dedicated paths.
(1)Ratio=RSSITx−powerd=10RatioRatio≤1,αγβRatioRatio>1.Figure 6
Part (a) depicts the position of people counter sensors, and part (b) shows the positions of BLE sensors in the building.
(a)(b)Figure 7
The procedure used to implement the people counting sensor.


### 3.6.1. People Counting Sensors

The main idea is to propose the people counting technique with minimum error using three sensors in each door. These three sensors should work concurrently and calibrate in a single code. The gateway can implement each sensor data using wired or wireless communication. The working principle is a simple IN-OUT principle. Whenever a person enters the room (dedicated direction for every room), the optimized data will increase the room’s total number. Otherwise, it will decrease. In addition, there is a Sensor (T1), a thermal sensor (which helps not count anything else except person), and can detect the person’s direction. On the left and the right side, sensors can help to detect the movement of the people. In this project, all the connected sensors to the gateway with MQTT protocol are processed with some multithread C code to compute the IN-OUT number (Figure8).Figure 8
image shows the simple IN-OUT principle.


### 3.6.2. Algorithm of the Counting with Three Sensors

First, subscribe to the MQTT broker to get all three-sensor data. We could subscribe and get the current data and use it. In the following, we will provide algorithms to show how to subscribe MQTT server. Here, the coding algorithm shows how the code should modify in every selected sensor in the actual testing algorithms1–5, subscribing to the three sensors’ data topic and creating five threads working concurrently in the process. We have five conditions to change the value of the final value of the three sensors.Algorithm 1: It shows the main process.
/∗subscribe to MQTT broker ∗/mqtt_subscribe(&client, topic, 0);/∗ start publishing the time ∗/printf(“%s listening for ‘%s’ messages.\n”, argv[0], topic);printf(“Press CTRL-D to exit.\n\n”);/∗ block ∗/while(fgetc(stdin) != EOF);/∗ disconnect ∗/printf(“\n%s disconnecting from %s\n”, argv[0], addr);sleep(1);/∗ exit ∗/exit_example(EXIT_SUCCESS, sockfd, &client_daemon);Algorithm 2: Getting the sum value (last value of the three sensors) and publishing it to the broker to calculate the number of people in each room.
pthread_t pid1, pid2, pid3, pid4, pid5;t1= pthread_create(&pid[i], NULL, thread1, (void∗) &input1);if(t1){printf(“Error creating thread1%d!”, i);return -1;t2= pthread_create(&pid[i], NULL, thread2, (void∗) &input2);if(t2){printf(“Error creating thread2%d!”, i);return -1;t3= pthread_create(&pid[i], NULL, thread3, (void∗) &input3);if(t3){printf(“Error creating thread3%d!”, i);return -1;t4= pthread_create(&pid[i], NULL, thread4, (void∗) &input4);if(t4){printf(“Error creating thread4%d!”, i);return -1;t5= pthread_create(&pid[i], NULL, thread5, (void∗) &input5);if(t5){printf(“Error creating thread5%d!”, i);return -1;Algorithm 3: If sensor S1 and sensor T1 detect the movement in the same way and +1 direction, it will increase the total value.
/∗ Thread-2 ∗/void∗ thread2(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == OUT && T1 == OUT){/∗if sensorS1 and sensorT1 detectthe movement in the sameway and -1 direction it willdecrease the total value.∗/room --;}while(1); /∗loop forever∗/}Algorithm 4: If sensor S1 and sensor T1 detect the movement in the same way and -1 direction, it will decrease the total value.
/∗ Thread-1 ∗/void∗ thread1(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == IN && T1 == IN){/∗if sensorS1 and sensorT1 detect the movementin the same way and +1 direction itwill increase the total value.∗/room ++;}while(1); /∗loop forever∗/}Algorithm 5: Using the thermal sensor data described in C.
/∗ Thread-5 ∗/void∗ thread5(void ∗ unused){int∗value;value = (int∗) unused;if(S2 == OUT && T1 == OUT && S1 == OUT) || (S2 == IN && T1 == IN && S1 == IN){room (--)(++);}while(1); /∗loop forever∗/}


## 3.6.1. People Counting Sensors

The main idea is to propose the people counting technique with minimum error using three sensors in each door. These three sensors should work concurrently and calibrate in a single code. The gateway can implement each sensor data using wired or wireless communication. The working principle is a simple IN-OUT principle. Whenever a person enters the room (dedicated direction for every room), the optimized data will increase the room’s total number. Otherwise, it will decrease. In addition, there is a Sensor (T1), a thermal sensor (which helps not count anything else except person), and can detect the person’s direction. On the left and the right side, sensors can help to detect the movement of the people. In this project, all the connected sensors to the gateway with MQTT protocol are processed with some multithread C code to compute the IN-OUT number (Figure8).Figure 8
image shows the simple IN-OUT principle.


## 3.6.2. Algorithm of the Counting with Three Sensors

First, subscribe to the MQTT broker to get all three-sensor data. We could subscribe and get the current data and use it. In the following, we will provide algorithms to show how to subscribe MQTT server. Here, the coding algorithm shows how the code should modify in every selected sensor in the actual testing algorithms1–5, subscribing to the three sensors’ data topic and creating five threads working concurrently in the process. We have five conditions to change the value of the final value of the three sensors.Algorithm 1: It shows the main process.
/∗subscribe to MQTT broker ∗/mqtt_subscribe(&client, topic, 0);/∗ start publishing the time ∗/printf(“%s listening for ‘%s’ messages.\n”, argv[0], topic);printf(“Press CTRL-D to exit.\n\n”);/∗ block ∗/while(fgetc(stdin) != EOF);/∗ disconnect ∗/printf(“\n%s disconnecting from %s\n”, argv[0], addr);sleep(1);/∗ exit ∗/exit_example(EXIT_SUCCESS, sockfd, &client_daemon);Algorithm 2: Getting the sum value (last value of the three sensors) and publishing it to the broker to calculate the number of people in each room.
pthread_t pid1, pid2, pid3, pid4, pid5;t1= pthread_create(&pid[i], NULL, thread1, (void∗) &input1);if(t1){printf(“Error creating thread1%d!”, i);return -1;t2= pthread_create(&pid[i], NULL, thread2, (void∗) &input2);if(t2){printf(“Error creating thread2%d!”, i);return -1;t3= pthread_create(&pid[i], NULL, thread3, (void∗) &input3);if(t3){printf(“Error creating thread3%d!”, i);return -1;t4= pthread_create(&pid[i], NULL, thread4, (void∗) &input4);if(t4){printf(“Error creating thread4%d!”, i);return -1;t5= pthread_create(&pid[i], NULL, thread5, (void∗) &input5);if(t5){printf(“Error creating thread5%d!”, i);return -1;Algorithm 3: If sensor S1 and sensor T1 detect the movement in the same way and +1 direction, it will increase the total value.
/∗ Thread-2 ∗/void∗ thread2(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == OUT && T1 == OUT){/∗if sensorS1 and sensorT1 detectthe movement in the sameway and -1 direction it willdecrease the total value.∗/room --;}while(1); /∗loop forever∗/}Algorithm 4: If sensor S1 and sensor T1 detect the movement in the same way and -1 direction, it will decrease the total value.
/∗ Thread-1 ∗/void∗ thread1(void ∗ unused){int∗value;value = (int∗) unused;if(S1 == IN && T1 == IN){/∗if sensorS1 and sensorT1 detect the movementin the same way and +1 direction itwill increase the total value.∗/room ++;}while(1); /∗loop forever∗/}Algorithm 5: Using the thermal sensor data described in C.
/∗ Thread-5 ∗/void∗ thread5(void ∗ unused){int∗value;value = (int∗) unused;if(S2 == OUT && T1 == OUT && S1 == OUT) || (S2 == IN && T1 == IN && S1 == IN){room (--)(++);}while(1); /∗loop forever∗/}


## 3.7. Middleware

In this section, we focus on the middleware block and its related connection and definition. Furthermore, we have provided several images of the operation of our middleware Figure9. Middleware block is software that serves as an interface between the end-users and other hardware components to aggregate and filter received data from the hardware components, perform information discovery, and provide access control to the end user’s application.Figure 9
Image focused on the middleware section and used components and performed operations.


### 3.7.1. Receiver

The receiver controller would be considered the crucial part of the software. The receiver works with a straightforward C-program responsible for transferring BLE packets between the gateway and the BLE host controller. Packet transform performs as raw streams of data. They should decode in software to be helpful to address the essential required functions in all the experiments with the aim of code recycling maximization, for example, initialization of the host controller, initializing the radio, and scanning enabling/disabling. Support for suitable packet encoding and decoding is limited since it is time-consuming. Therefore, it does not have a significant positive point for these types of positioning systems implemented here.


## 3.7.1. Receiver

The receiver controller would be considered the crucial part of the software. The receiver works with a straightforward C-program responsible for transferring BLE packets between the gateway and the BLE host controller. Packet transform performs as raw streams of data. They should decode in software to be helpful to address the essential required functions in all the experiments with the aim of code recycling maximization, for example, initialization of the host controller, initializing the radio, and scanning enabling/disabling. Support for suitable packet encoding and decoding is limited since it is time-consuming. Therefore, it does not have a significant positive point for these types of positioning systems implemented here.


## 4. Results and Implementation

### 4.1. Review Results

According to the latest surveys, we have gathered some information about our project’s different aspects. Furthermore, we have found out that almost 50 percent of surveyed cases prefer to use Android, followed by 46 percent iOS. This survey has covered the data about smartphone users’ age. The related pie charts illustrate that almost 60 percent of smartphone users are in the 18-29 age range, while the minor smartphone users belong to the 30–39 age groups. Regarding smartphone usage during an emergency, it can be viewed that a hefty 95 percent of cases express their preference for using their cell phone during an emergency. In the case of waiting time that the surveyed cases must spend in hospital services lines, almost half of them have stated that is more than their expected time. Eventually, it is worth noting that the mentioned information is collected through several surveys held in Turin, Italy, Figures10 and 11.Figure 10
The pie chart illustrates information based on a survey about the most voted place to implement the project.Figure 11
The pie charts a, b, c, and d depict information about preferred smartphone O.S., the age range of users, the expectation of waiting in the queues, and smartphone usage in an emergency.
(a)(b)(c)(d)


### 4.2. Platform Implementation

The proposed design was successfully implemented by integrating multiple IoT technology services and applications to create a comprehensive platform with minimal hardware usage and maximum adaptability for smart management of presented services in the hospitals. This section offers a discussion on the results obtained. The following objectives were satisfied with the current final application provided below. As the first result, this application provides precise navigation in the building toward the end user’s desired destination through the application. This option offers a better experience for its user and decreases unnecessary commuting in the building.As the second result of this project, the information about the point of interest can be mentioned. Through this capability of the project, end-users can access a wide range of information about the kinds of presented services and the availability of those services. The most important feature of the provided application is social distancing by notifying its users about immune distance with other people in the same area in the building. The last part of the delivered application would be highly beneficial due to the situation created by COVID-19, as Figures12–14.Figure 12
Interface of application.Figure 13
Interface of end-user application.Figure 14
A general view of the project’s operation when the end-user uses the application for navigation purposes.


## 4.1. Review Results

According to the latest surveys, we have gathered some information about our project’s different aspects. Furthermore, we have found out that almost 50 percent of surveyed cases prefer to use Android, followed by 46 percent iOS. This survey has covered the data about smartphone users’ age. The related pie charts illustrate that almost 60 percent of smartphone users are in the 18-29 age range, while the minor smartphone users belong to the 30–39 age groups. Regarding smartphone usage during an emergency, it can be viewed that a hefty 95 percent of cases express their preference for using their cell phone during an emergency. In the case of waiting time that the surveyed cases must spend in hospital services lines, almost half of them have stated that is more than their expected time. Eventually, it is worth noting that the mentioned information is collected through several surveys held in Turin, Italy, Figures10 and 11.Figure 10
The pie chart illustrates information based on a survey about the most voted place to implement the project.Figure 11
The pie charts a, b, c, and d depict information about preferred smartphone O.S., the age range of users, the expectation of waiting in the queues, and smartphone usage in an emergency.
(a)(b)(c)(d)


## 4.2. Platform Implementation

The proposed design was successfully implemented by integrating multiple IoT technology services and applications to create a comprehensive platform with minimal hardware usage and maximum adaptability for smart management of presented services in the hospitals. This section offers a discussion on the results obtained. The following objectives were satisfied with the current final application provided below. As the first result, this application provides precise navigation in the building toward the end user’s desired destination through the application. This option offers a better experience for its user and decreases unnecessary commuting in the building.As the second result of this project, the information about the point of interest can be mentioned. Through this capability of the project, end-users can access a wide range of information about the kinds of presented services and the availability of those services. The most important feature of the provided application is social distancing by notifying its users about immune distance with other people in the same area in the building. The last part of the delivered application would be highly beneficial due to the situation created by COVID-19, as Figures12–14.Figure 12
Interface of application.Figure 13
Interface of end-user application.Figure 14
A general view of the project’s operation when the end-user uses the application for navigation purposes.


## 5. Conclusions

According to collected data, BLE indicates its suitability for simple positioning systems, where accuracy is not a priority. Moreover, BLE-based systems allow for low power consumption and low implementation cost. However, this is dependent on the existed local commercial offers, such as iBeacon. Although these systems are predicted to indicate the same level of functionality as proximity-based ones, ranging functionality is limited.As the implemented system worked and provided the desired precision for a restricted set of tests, the results show that the performance of the proposed system is better than a ranging-based solution. Moreover, with some slight modifications, it can achieve a performance level like Wi-Fi-based systems with lower power consumption. Unfortunately, it is impossible to provide a detailed power consumption measurement since the available equipment cannot perform it. It is estimated that with two 3 Wh cells, the battery life for the beacons in the proposed solution can be extended to years. This study’s theoretical contribution is to enhance the literature by providing a practical mobile application for the smart management of hospitals. Furthermore, the developed platform processes the buildings’ information about the number of its customers and the date and time of their presence to better and smarter management of the hospital’s presented services.In addition, there is a possibility to enhance the features of the implemented system to check the space occupancy and the automatic adjustment of the environmental elements like temperature and light for better energy efficiency use.



---

*Source: 5533161-2021-07-02.xml*