## 4 Smart IoT-Based Early Warning System  
In this section, the proposal is described. It has been designed as an AI-powered solution that analyzes people flow and predicts their next move, generating strategic and tactical insights at the operational level. The key performance indicators that our system generated were the number of people in a specific location in a given time, the average time spent in particular areas, and the number and density of people that interacted over a particular period, among others. As depicted in Figure 2, our proposal (called Dolphin) followed a sensor fusion approach, specifically operating as a data level fusion algorithm, merging sensor data from different sources in a way that less uncertainty is present in the output information than would be obtained if raw data were processed separately [49]. Thus, at the first level, the low-cost IoT devices were selected and deployed. Off-the-shelf IoT devices were selected to accelerate the implementation phase. These devices (e.g., Raspberry Pi 3 and Raspberry Pi Zero W) incorporate both Bluetooth low energy (BLE) and WiFi communication modules. People carrying any portable device compatible with BLE and/or WiFi would then be detected by our proposal. It is important to note that all processes included in our system are secure-by-design (i.e., no personal identifiable information (PII) is stored at any time, and temporal non-recoverable virtual identifiers are created from BLE and WiFi device information using hash functions and temporal keys). These anonymized data from detected devices are then transmitted to the edge nodes using the Message Queuing Telemetry Transport (MQTT) protocol. MQTT is a standard messaging protocol for the IoT with numerous advantages [50; 51]. One of them is its design as a lightweight messaging transportation, which makes it a much more energy efficient option compared to other alternatives such as Hypertext Transfer Protocol (HTTP). MQTT follows a topic-based publish-subscribe operation mode. Its header size is small, so it optimizes network bandwidth. MQTT messages can be sent in both directions, from IoT nodes to the edge devices or the cloud and vice versa, hence allowing more versatility in the system design. Finally, it is possible to enable encryption for the exchanged MQTT messages and different levels of quality of service (QoS) can be configured. Consequently, it has been used in some interesting previous works related to IoT-based monitoring [52]. Edge nodes are also IoT devices whose function is not to capture data but to apply the first level of processing by applying a machine learning (ML) algorithm that locates the anonymized device's carrier with an estimated error smaller than 1 m in indoor areas. The error estimation as well as the initial configurations were calculated by carrying out extensive experimental tests in two control testbeds, one indoor and one outdoor (see Figure 3). Figure 4 illustrates the initial results in terms of pedestrian flows in the outdoor real scenario. The supervised ML algorithm for indoor geolocation was based on a convolutional neural network and is currently under an intellectual property process. Then, the output of the algorithm, composed of the \(x\) and \(y\) coordinates of all located virtual identifiers within the geographical area under monitoring, is then sent by the edge nodes to the central servers at the cloud. In our experiments, only one server was needed to deal with the amount of data generated (\(\approx\)1.8 GB of data per month). Table 2 includes the characteristics of the cloud server and an example of the CPU usage of the server is depicted in Figure 5. The central server is in charge of the second level of processing, with two main goals, namely forecasting and visualization. The forecasting procedure, also under PI, permits us to estimate the evolution of the KPIs for the next hour and/or days, depending on the amount of data already stored by the platform.