Internet of Things (IoT) in Buildings: A Learning Factory

: Advances towards smart ecosystems showcase Internet of Things (IoT) as a transversal strategy to improve energy efﬁciency in buildings, enhance their comfort and environmental conditions, and increase knowledge about building behavior, its relationships with users and the interconnections among themselves and the environmental and ecological context. EU estimates that 75% of the building stock is inefﬁcient and more than 40 years old. Although many buildings have some type of system for regulating


Introduction
According to a special report by the European Court of Auditors [1], buildings are responsible for 40% of energy consumption and 36% of greenhouse gas emissions in Europe.According to Eurostat [2], buildings have contributed approximately 25-28% to energy consumption in Europe since 1995.Energy consumption in households is the main reason for the observed greenhouse gas emissions of the sector [3].Buildings and households, given their energy savings potential, have priority consideration in the European Union (EU) 2030 agenda to meet the EU's Sustainable Development Goals (SDGs), with a commitment to reduce energy consumption by more than 30% by 2030 [4].According to the United States (US) Environmental Protection Agency (EPA) [5] and the EU [6], people spend 80-90% of their time indoors, where the air quality is two to five times worse than outdoors.High indoor air quality (IAQ) is thus of the utmost importance.
Addressing these key challenges is not mandatory but rather the subject of policy recommendations.In this context, the main relevant European norm is the Energy Performance Buildings Directive (EPBD) 2018/844/EU [7].EPBD promotes energy efficiency in buildings through several initiatives related to Internet of Things (IoT) technologies and heating, ventilation and air conditioning (HVAC) systems, among other key topics.According to EPBD, the energy performance of buildings should be calculated on the basis of a methodology which can be differentiated at national and regional levels.In addition to thermal characteristics, it considers other relevant factors, such as heating and air conditioning installations, ventilation strategies, the application of energy from renewable sources, building automation and control systems, smart solutions, passive heating and cooling elements, adequate natural light and air quality, and the design of the building, among others.The methodology should be based on hourly or sub-hourly time steps, ensure the representation of actual operating conditions, and enable the use of metered energy to verify correctness and facilitate comparability.From these premises, the proposed solutions should be transversal strategies and consider the following key aspects of building environments:

•
Few buildings have complete HVAC systems; most have air conditioning only, heating only, heating and air conditioning distribution, or systems that provide combined ventilation, heating, and cooling.

•
Few buildings include IoT: although it is becoming more common to incorporate sensors that are used by Supervisory Control And Data Acquisition (SCADA) systems to control HVAC systems, integrating such systems into IoT ecosystems, as proposed in this paper, remains a challenge.

•
The European building stock is largely obsolete, so interventions to improve energy efficiency must also ensure air quality to maintain a healthy and comfortable indoor environment with minimal energy use and environmental impact.

•
The built environment is huge, so transversal strategies need to be low in cost and economically sustainable.
All these considerations call for the consideration of which strategies are the most effective in improving building performance, especially energy efficiency and IAQ.This question is beginning to be addressed in research on the design and construction of new buildings called smart buildings when integrated with IoT technology.However, as mentioned previously, the current reality of the built environment is that only a minority of buildings include IoT.It is necessary to assess how IoT-based strategies can be cost effective and sustainable.Incorporating IoT technologies enables the continuous collection of data to know how buildings behave and make data-driven decisions to improve IAQ and reduce its energy consumption and carbon footprint [8].IoT allows the collection of vast amounts of data that, if properly transmitted and processed (by cloud or in-house facilities), can be converted into meaningful information [9].This information, conveniently visualized and analyzed, generates knowledge, induces feedback on the acquisition and processing of data, and, most importantly, allows intelligent decisions based on valuable data [10].Thus, IoT monitoring offers configurable solutions in a customized way for specific cases and contexts.Furthermore, each building is unique in its shape, construction solution, location, climate, and usage, making IoT monitoring a transversal solution, offering both configurable options and the ability to adapt to each specific case and context.IoT is one of the technological paradigms destined to exponentially increase with a high impact on the daily behavior of potential users [11].However, since this research area is an emerging field, the available literature is still limited.In [12], assuming this scope is a relatively new development, a comprehensive review was detailed by analyzing the potential of connecting building information modeling (BIM) and smart buildings with IoT-based data sources.In [13], several examples of IoT implementation (within the last five years) in residential and commercial buildings were reviewed.And in [14], a system was developed in an IoT lab system to monitor the activities in the lab.The added value of this paper is to highlight IoT ecosystems as key elements in turning a building into a learning factory.And university buildings are especially suitable as experimental testbeds for current and future generations because of their heterogeneity, use variety (classrooms, offices, laboratories, study rooms, canteens, etc.), seasonality, high variability in occupancy and density, high energy demands, diversity of management systems, and other multiple factors.In this complex context, learning implies performance: learning by doing.Thus, this work proposes a methodology (from a real intervention in built environment through a designed, implemented, and deployed IoT ecosystem) as a learning factory in a continuous cycle for direct application in academic works, researching projects and institutional initiatives, extendable to professional environments, tertiary buildings and smart cities, focused on energy efficiency, IAQ and (building and human) behavior patterns.
With regard to energy efficiency, in the current context in which climate change and environmental degradation pose serious global challenges [15,16], energy efficiency is essential to decarbonization and limiting, as set in the Paris Agreement in 2015, the increase in the global temperature to 1.5 • C [17].Some studies have examined the usefulness of continuous monitoring systems in improving the energy efficiency of buildings [18][19][20].However, most such studies rely on BIM software models, unlike the methodology proposed in this paper, which is based on real building measurements.Other studies propose recognizing innovations in the energy efficiency and sustainability of existing buildings (as a building renovation passport, BRP) but do not implement technological solutions to quantify their potential outcomes.This paper demonstrates how quantitative results can be obtained by the deployment and implementation of an entire IoT ecosystem.Batista et al. [21] used an equipment control system to investigate the performance of the air conditioning system of a small auditorium in Brazil, achieving a 20% energy consumption reduction and improving thermal comfort, but those outcomes are not correlated with IAQ parameters, such as CO 2 and occupancy.More recently, the occupancy of an office building was monitored with the objective of developing occupancy models and determining their impact on the energy performance of the building [22], but the monitored spaces were not categorized according to their key characteristics, such as location, orientation, use, size, occupancy, etc.With regard to thermal comfort, Li et al. [23] performed correlation analyses based on continuous thermal comfort measurements from four office buildings in Australia, supporting the use of continuous monitoring technologies for long-term thermal comfort evaluation.Furthermore, several key actions to improve building operation management have been shown to reduce energy demand, such as rating tools and disclosure [24], energy audits [25], energy management systems [18], smart controls, and building passports [19].The literature shows that buildings can be understood as complex systems and that there is a lack of published research on quantitative analysis, such as this work, about the interaction of building energy performance parameters interacting with factors such as weather, use patterns, occupancy variation, etc.
With regard to IAQ, the World Health Organization (WHO) estimates that more than 100 diseases are associated with the effects of unhealthy indoor environments.In this context, the United Nations (UN) has established various SDGs for 2030 [20], paying special attention to air quality [4].According to the US EPA, IAQ refers to the air quality within and around buildings and structures, especially as it relates to the health and comfort of building occupants [5].Good IAQ contributes to well-being, comfort, health, and productivity in people.Some recommendations to improve IAQ include the following [26]: to choose building materials and furnishings with low pollutant emission rates (new buildings or renovations), to reduce sources of pollutant emissions (stoves and cleaning products), purify the air (by particle filtration, removal of pollutant gases, and microbiological control), and ventilate building interiors (which dilutes any type of pollutant through mixing with outside air).Although IAQ is not exclusively related to the CO 2 concentration [27], some articles relate occupancy to CO 2 concentration and propose required air ventilation rates to keep the concentration below a set level [28][29][30][31][32][33].The European Commission analyzed the regulations on IAQ in countries and the existing varieties of ventilation systems, concluding that there is still significant progress to be made in IAQ measurement and quantitative analysis [34].All these studies remark on the need for continuous monitoring systems through IoT ecosystems that provide real measurements of building behavior to improve IAQ in buildings.
Moreover, given the relationship between energy efficiency and IAQ with people's behavior, as well as the building itself [35,36], it is necessary to complement simulation studies with real quantitative measurements.In the last 20-30 years, notable advances have been made in building energy simulation, but much less progress has been made in terms of measuring, analyzing, and learning about the real operation and performance of the buildings.Numerous studies [37][38][39] show that there is a large difference between theoretical values and real data on building environments, which has been called the building performance gap (BPG), especially in heterogeneous university buildings with high complexity and variable occupation.These differences are due to the numerous simplifying assumptions required to model and simulate the real behavior of buildings.Algorithms have been designed to reduce the BPG [40].All this reveals that it is necessary to not only simulate buildings but also perform continuous IoT monitoring and data analysis to understand how they behave under real operating conditions.
In recent years, the integration of IoT technologies in buildings has emerged as a promising approach to enhance energy efficiency and indoor comfort [41,42].However, buildings often face challenges in optimizing their HVAC systems, as data can be dynamic and highly variable [43,44].Nevertheless, IoT data analytics offers a better opportunity to analyze such data and provide valuable insights for building management.Leveraging data-driven models such as machine learning (ML) and deep learning (DL) becomes essential for analyzing nonlinear relationships between buildings and occupants [45][46][47].With numerous variables influencing indoor comfort and energy savings, predictive control methods like model predictive control (MPC) can contribute significantly to energy conservation efforts [48][49][50].
Furthermore, in this technological context, in which buildings can be understood as complex dynamic processes, advances in MPC show promise for analyzing how variables such as occupancy, weather, climate, orientation, infiltration (air permeability), thermal inertia, and HVAC systems interact to improve energy efficiency and IAQ [51].And, to continue developing MPC, it is key to have quality and structured data and therefore IoT ecosystems.In recent years, recurrent neural network (RNN) modeling used to predict CO 2 and temperature has experienced significant growth.In [52], it was shown that a linear regression model is not able to predict indoor environment indicators with high accuracy, concluding that more complex models based on neural networks are needed.In [53], an RNN was used to predict CO 2 levels using 10 weeks of measurements with 75% of the data used to train the network and the remaining 25% used to test it.In [54], a modeling and optimization approach was proposed to minimize energy consumption by developing models to predict indoor environmental parameters (humidity, temperature, and CO 2 ) and energy consumption in real time using neural networks, achieving very high reliability.
This paper targets two objectives.One objective is to understand the built environment as a complex system, in which IoT ecosystems are key to enabling technologies to move towards transversal strategies to improve energy efficiency and IAQ.Thus, this work proposes IoT as a learning factory (from the Latin factorium, "place of doers, makers"), where the dataset is open and public for third-party use to contribute to the scientific community in its research efforts (available from https://sensorizar.unizar.es,accessed on 31 July 2023).The other objective is to understand IoT ecosystems as cost-effective solutions that acquire data (from real measurements through connected sensors), analyze real-time information (to improve operations: maintenance, scheduling, etc.), and build knowledge (to make data-driven decisions).
With these aims, in the current context of the built environment (Section 2 analyzes the main factors involved in the building reality) with economic restrictions, complexity, higher energy costs, social vulnerability and climate change, this work proposes IoT-driven strategies as a novel and necessary contribution due to their open, modular, interoperable, transversal and cost-effective approach as it is properly justified with the obtained outcomes in Section 4. Section 3 details the functional scheme of the IoT ecosystem applied to the built environment (as complex systems) focused on energy efficiency and IAQ.Section 4 shows several results of experiments at building scale, focused on CO 2 and energy-consumption monitoring through real installations, to promote IoT as key to understanding building complexity and proposing a proof of concept of the prediction of CO 2 and temperature based on a neural network.Finally, Section 5 details the scientific contributions of the work from a critical point of view and proposes further research studies.

Building and IoT: Reality and Challenges
The EU says in its "Renovation wave for Europe" strategy that a trend of renewal for Europe allows "greening our buildings, creating jobs, and improving our lives".Its goal is to double the annual energy renewal rates in the next ten years.In 2014-2020, the EU allocated approximately EUR 14 billion to improving the energy efficiency of buildings [55].In addition, member states budgeted €5.4 billion in national co-financing for the improvement of all types of buildings.These renovations will improve the quality of life for the people who live in and use buildings, reduce greenhouse gas emissions, and create up to 160,000 additional green jobs in the construction sector.However, the new paradigm of smart environments faces the challenge of the reality of the current built environment, characterized by the following main factors: age, infrastructure, electrification, climatic and urban context, energy demand, diversity of stakeholders, and complexity.
Age.The EU estimates that 75% of the European building stock is inefficient and more than 40 years old on average [56].Buildings around the world (mostly in Europe), when they are appropriately designed, constructed, renovated, and maintained, are long-lasting structures capable of provide providing their occupants with suitable indoor conditions, protection from extremes of hot and cold temperatures, and low energy costs.As detailed in Table 1 (from Eurostat [57]), the average ages of buildings in Europe are distributed as follows: greater than 75 years (22.3%),45-75 years (44.1%),25-45 years (22.1%), and less than 25 years (9.8%).In Spain, there are approximately 10 million buildings (9,730,999 dwellings and 83,786 with other uses), with an average age of 37 years [57].In addition, the percentage of new buildings (0.34%) is minimal compared to the total number of buildings: at that rate, more than 300 years would be required to replace the entire building stock.Infrastructures.Although many buildings have some kind of system for regulating their indoor temperature, only a small subset provides an entire HVAC system; within that subset, only a low percentage includes smart sensors, and only a minimum of that percentage integrates those sensors into IoT ecosystems.And these facts especially impact non-residential buildings (e.g., public institutions, government, and services), mostly located in old monumental buildings that lack HVAC systems.From the HVAC systems engineering point of view, historic buildings that have not been affected by recent maintenance work, whether ordinary, extraordinary, or preventive, are generally equipped with obsolete equipment.In many buildings, the thermal envelope is inefficient.Existing heating and air conditioning systems can be replaced but can be evidence of the past and, as such, have historical interest; therefore, they should be carefully recovered, valued, and, if possible, made useable.
IoT technologies.Among all the technical characteristics of IoT technologies, in the context of this study, it is important to highlight three key features.The cost is minimal compared to the economic costs of any action at building scale.IoT wireless technologies offer very high capabilities with a very low number of sensors, with lifetimes of years (even for photovoltaic batteries), without the need for wiring (neither for power nor for communications), and without impact in the infrastructures (by putting sensors on walls, windows or ceilings).IoT ecosystems require highly qualified technical staff, continuous management (for calibration and monitoring), managers with digitalization training, and analysts with data-driven vision to obtain operational conclusions.On the other hand, IoT technologies are already mature: once deployed, they require very little maintenance and return real-time data that represent building performance well.
Electrification.The climate emergency and dependence on fossil fuels have promoted policies to replace boilers in buildings with heat pumps.Following EPBD, the European Commission proposes that all new buildings do not produce emissions from 2028 onward, as well as the elimination of fossil fuels from 2035 onward, with replacement by heat pump systems based on electricity or hydrogen (blended with natural gas or waste), although some reports rule this out as being unfeasible on a large scale [58,59].Thus, continuous monitoring provided by IoT ecosystems appears to be the best option for HVAC systems (based on electrical energy) to adjust their regulation to the environment, consumption, behavior, and renewable energies.In addition, building systems whose operation is electrical are easier to regulate (than systems based on combustion) and allow adjustments with respect to energy demand both at the building scale and at the city scale.The increasing adoption of HVAC systems and the rising demand for thermal comfort, coupled with the imperative to reduce emissions, has positioned it as a primary driver of global electricity demand growth [60].
Climatic and urban context.The current climatic and energy context involves sequenced boundary conditions: (1) extreme temperatures will involve extreme climate events (2) that will increase the demand for air conditioning and heating equipment (3) that will produce an increase in energy demand (4) in an aged built environment, the majority of which is energy inefficient, (5) without a monitoring or management system.Furthermore, urban trends suggest that, in 2030, 50.9% of Europeans will live in cities, 26.9% in towns and semi-dense areas, and only 20.6% in rural areas [61].The combination of an aging population and highly urbanized ecosystems means that the population is becoming more vulnerable to heat and that demand for cooling in buildings is rising quickly.All of these concerns require intervention in buildings to examine key elements of sustainable cooling policies and their potential impacts on vulnerable groups by reducing health risks, inequalities, and summer energy poverty.In the EU in 2022, compared with 1979, the need for heating a given building was approximately 20% lower, and the need to cool a given building was almost four times higher [62].In the summer of 2022, with successive long heatwaves and high energy prices, heat stress created a sense of urgency about acquiring air conditioning devices.However, there is a gap between knowledge about overheating in buildings and the percentage of EU citizens unable to keep their homes comfortably cool during the summer.This growth in demand for thermal comfort and healthy environments with good IAQ creates a growth in energy demand, despite the current situation of economic restrictions, high energy costs, emissions consequences, and climatic, social, and environmental impacts [63].Thus, IoT ecosystems, as proposed in this paper, provide transversal strategies for addressing this complex context and choosing customized solutions for each specific situation.
Energy demand and IAQ.The growth in the need for thermal comfort and better IAQ implies increased energy demand.Environmental change is estimated to be responsible for an increase of 212% in energy use for cooling residential buildings between 2010 and 2019 [64].The majority of European buildings lack air conditioning and ventilation systems, and only recently have buildings been designed in accordance with energy criteria [56].Therefore, various actions are necessary, such as the renovation of building envelopes, the installation of photovoltaic panels, the improvement of HVAC systems, the promotion of passive strategies, efficient air conditioning systems, the installation of ventilation systems, urban revegetation policies (to avoid the heat island effects and extreme temperatures), access to renewable energy, and living in greener environments with lower traffic densities, among others.However, all these strategies carry high economic costs, are difficult to provide for vulnerable groups, and imply social inequities and energy poverty.Thus, IoT-based strategies, as proposed in this paper, mean a cost-effective contribution that is technically feasible and socially accessible, especially for public buildings and urban areas occupied by vulnerable groups.
Diversity of stakeholders.Buildings are interconnected at various scales and levels (see Table 2): space (local), building (community), neighborhood (intra-local), city (local), region (intra-national), country (national), and zone (international).Thus, the widespread implementation of IoT transversal strategies at all scales is key to understanding building behavior in relation to human behavior by obtaining accurate information to make datadriven decisions at different levels:

•
For users, IoT enhances HVAC systems with low cost, time and impact.

•
For architects, IoT improves knowledge about the real behavior of buildings and users (overcoming the gap between theoretical values and real data) for use in evidencebased architectural design.

•
For engineers, IoT facilitates the study of the most suitable energy system for each building according to its location, orientation, design, typology of spaces, uses, etc.

•
For urbanists, extrapolated to the urban scale and combined with the geographical information system (GIS), IoT provides general strategies by zones.

•
For geographers, overcoming the urban scale, IoT learns social behaviors, patterns, trends, etc.

•
For epidemiologists and doctors, IoT makes it possible to correlate the spread of certain diseases with IAQ and environmental parameters and trends.

•
For local, national, and international institutions, IoT provides data on behavior patterns for use in developing and implementing strategies for rehabilitation, energy management, etc., for energy, electricity, CO 2 , etc.
Complexity.The growing availability of information, technological advances, global interconnectivity, population growth, and environmental, biological, and socioeconomic challenges generates more interdependent systems that are difficult to understand in their entirety.The acquisition and measurement of data provide empirical and quantitative information to understand and characterize key aspects of the reality under study.Monitoring and analyzing data allows the identification of patterns, relationships, dynamics, and new emergent features that reveal the most significant interdependencies, diversity, and structure within a system.Thus, IoT-driven solutions allow the evaluation of system adaptability, and an understanding of how different variables interact with each other and impact the overall system behavior.Simulation of scenarios and evaluation of the international strategies about the built environment with social implications.

Materials and Methods
Following the theory of knowledge by which "everything flows, is in permanent evolution . . .nothing is static, everything is dynamic: every entity or object is a complex process", a building can be defined as a set of dynamic, interconnected processes to provide a human habitat.Furthermore, the large number of systems, services, functionalities, parameters, metrics, etc., of a building lead to complexity in understanding it as a whole and foreseeing how it will behave and evolve.From these two approaches, a building can be defined as a complex system as illustrated by the central element in Figure 1.
Buildings do not exist in isolation but rather are interconnected at various scales and levels (neighborhood, city, region, etc.), forming communities.Information flows and knowledge is shared at these interconnected levels.Therefore IoT-based initiatives are mandatory to develop transversal strategies as emphasized in EPBD [7]: ". . .promotion of smart technologies and infrastructure for sustainable mobility in buildings," and ". . .integration of smart charging services enable[s] the energy system integration of buildings".In this context, it is essential to understand the relationships between buildings and their communities (urban and rural, cities and villages, etc.) conforming to the built environment (see Figure 1) that also constitute complex systems understood as interconnections of buildings used by many people, who are themselves also interconnected with each other and with the environmental context.As remarked in EPBD [7], "In order to digitalize the building sector, the Union's connectivity targets and ambitions for the deployment of high-capacity communication networks are important for smart homes and well-connected communities".Buildings do not exist in isolation but rather are interconnected at various scales and levels (neighborhood, city, region, etc.), forming communities.Information flows and knowledge is shared at these interconnected levels.Therefore IoT-based initiatives are mandatory to develop transversal strategies as emphasized in EPBD [7]: "… promotion of smart technologies and infrastructure for sustainable mobility in buildings," and "… integration of smart charging services enable[s] the energy system integration of buildings.".In this context, it is essential to understand the relationships between buildings and their communities (urban and rural, cities and villages, etc.) conforming to the built environment (see Figure 1) that also constitute complex systems understood as interconnections of buildings used by many people, who are themselves also interconnected with each other and with the environmental context.As remarked in EPBD [7], "In order to digitalize the building sector, the Union's connectivity targets and ambitions for the deployment of high-capacity communication networks are important for smart homes and well-connected communities.".
These concepts of building performance and behavior patterns (see Figure 1) lead to understanding IoT as enabling technologies to quantitatively parameterize key performance indicators (KPIs) of the built environment.As EPBD emphasizes, as of 2026 (article 13), the smart readiness indicator (SRI) [65] is an essential parameter for making building owners and occupants aware of the value hidden in building automation and the digital supervision of building technical systems by providing energy savings thanks to new smart features that IoT enables [66].In summary, moving towards the paradigm of hybrid twins means integrating IoT ecosystems into smart communities (buildings, cities, etc.) to acquire data (through real measurements), comparing them and turning them into information to generate knowledge for use in making data-driven decisions.
The functional scheme of an IoT ecosystem consists of five modules grouped in three layers (see the upper area of Figure 1): perception (including sensors and networks), technology (cloud), and application (analytics and user).Each of these five modules is described in detail below:

•
Sensors.There is a huge variety of sensors available to measure parameters of interest in buildings, such as (see the left area of Figure 1) ambient (CO2, temperature, humidity), mobility, occupancy, energy consumption, wearable devices, mobile infor- These concepts of building performance and behavior patterns (see Figure 1) lead to understanding IoT as enabling technologies to quantitatively parameterize key performance indicators (KPIs) of the built environment.As EPBD emphasizes, as of 2026 (article 13), the smart readiness indicator (SRI) [65] is an essential parameter for making building owners and occupants aware of the value hidden in building automation and the digital supervision of building technical systems by providing energy savings thanks to new smart features that IoT enables [66].In summary, moving towards the paradigm of hybrid twins means integrating IoT ecosystems into smart communities (buildings, cities, etc.) to acquire data (through real measurements), comparing them and turning them into information to generate knowledge for use in making data-driven decisions.
The functional scheme of an IoT ecosystem consists of five modules grouped in three layers (see the upper area of Figure 1): perception (including sensors and networks), technology (cloud), and application (analytics and user).Each of these five modules is described in detail below:

•
Sensors.There is a huge variety of sensors available to measure parameters of interest in buildings, such as (see the left area of Figure 1) ambient (CO 2 , temperature, humidity), mobility, occupancy, energy consumption, wearable devices, mobile information, contactless information (such as radio frequency identification (RFID) tags), etc.As the focus of this study is on energy efficiency and IAQ, sensors for measuring energy consumption (kWh), CO 2 level (ppm), temperature ( • C), humidity (%) and occupancy (pax) were included.The strategies for the selection of sensors followed several alternatives to prioritize the most appropriate suitability implementation with minimal cost.Wired alternatives were discarded because their installation would be problematic, and combinations of wired sensors and wireless gateways were also discarded because their connectivity would be problematic.Wireless sensors that work with both commercial solutions and open IoT cloud networks were considered.The latter option was chosen for its good scalability, high adaptability, and moderate cost.Monitoring spaces were representatively selected and labelled according to their key characteristics, such as location (floor, building, and campus), orientation (north, south, east, and west), use (classroom, study room, office, laboratory, library, canteen, etc.), size (large, medium, and small), occupancy (high, medium, and low), etc.

•
Networks.Sensors collect data.These collected data are sent to the following communication levels by various interconnected devices through their associated connectivity technologies.There are two main strategies: rely on classical cabled infrastructure centralized in SCADA systems, or use wireless protocols routed to the cloud using specific gateways, such as wireless fidelity (WiFi), 4G and the low power wide area network (LPWAN) technological family, such as SigFox, narrow band IoT (NB-IoT) and low range wide area network (LoRaWAN).Figure 2 shows a performance comparison to determine the most appropriate technology in order to propose homogeneous infrastructures.This comparison shows, among other issues, the importance of battery life and ease of battery replacement.As a consequence of the minimum maintenance cost and highest energy optimization and coverage range, LoRaWAN technology was selected for this work from the rest of LPWAN technological family.LoRaWAN specification [67] is a networking protocol, designed to wirelessly connect batteryoperated sensors with bi-directional communication and localization services, that targets other key IoT requirements, such as end-to-end security, high interoperability and low monthly costs due to provider network fees.

•
Cloud.Cloud computing services use a network layer (to connect remote devices or industrial TCP-IP protocols, such as MODBUS-TCP or OPCUA through SCADA systems) with centralized resources (data centers).Currently, there are different types of clouds (public, private, and hybrid) and new service models called X as a Service (XaaS), where X can be software (SaaS), platform (PaaS), and infrastructure (IaaS), among others.With the popularization of cloud services, the number of devices has exponentially increased.Given that critical and large-scale processes require increasingly fast and effective computational power, a new concept emerges: edge computing.Thus, edge computing refers to how computational processes are performed on or near the peripheral devices (edge).Finally, a third concept arises, fog computing, to refer a decentralized structure in which resources, including data and applications, are located in a logical place between the cloud and the data source.Due to the wide variety of sensors and scenarios in smart buildings, this research has utilized both edge services (for energy measurements considered big data) and cloud services (for IAQ measurements considered as small data).The IoT ecosystem developed in this work integrates three main functionalities (see middle area in Figure 1): a management platform (to homogenize and control acquired data), an information repository (following the design principles of scalability, flexibility and big data processing), and real-time monitoring (with geopositioned information).Furthermore, these functionalities interconnect with two key services (above detailed): analytics technics (artificial intelligence, machine learning, deep learning and neuronal networks) and applications and services for user experience to offer variability for visualization and interaction through mobile apps, web interfaces, data dashboard with KPIs and other added-value services.

•
Analytics.From the information processed and stored in the cloud, many analytics technologies exist for the extraction of key factors, real-time data exchange, remote monitoring, etc.This is crucial, as it provides ubiquitous access, either through platforms or online applications, to real-time levels of CO 2 , temperature, occupancy, and energy consumption in a specific place, thereby facilitating the monitoring and control of KPIs as well as the subsequent analysis of both user behavior and building performance.In addition, the connection of sensors to the IoT infrastructure of a building enables integration with other systems, such as (see lower area in Figure 1) HVAC, lighting, security (alarm, fire, etc.), mobility, energy management, etc.This provides facilities for coordination and global optimization of building systems and improves their structure by enhancing their efficiency, safety, wellness and comfort.
IoT systems allow obtaining the necessary data to obtain information using computer science techniques.This information is crucial to increase the knowledge about a system, enabling real-time operation and making predictions about its behavior.Having a robust, open, and flexible IoT system is essential for computer science to process and analyze the collected data, which in turn allows making informed decisions and optimizing the system.

•
User.From all the data collected by the sensors and the information computed by the analytics, IoT systems visualize knowledge.Report generation or dashboard visualization helps to better understand the environment behavior and supports informed decision making about the aforementioned building systems (HVAC, lighting, security, mobility, energy management, etc.).In this work, the combined analysis (from CO 2 , temperature, humidity, occupancy and energy consumption) enables the development of management models of energy efficiency and IAQ.With them, smart automation and control systems, both for ventilation and air conditioning systems, can be regulated based on occupancy levels, usage planning, and external environmental conditions.It even allows the development of models that incorporate parameters such as the economic cost of energy, on-site renewable energy production, human behavior, or the environmental impact of the building.Moreover, IoT systems can send real-time alerts or notifications when KPIs reach a predefined threshold, and take actions to correct situations, ensure a healthy environment, etc.
with minimal cost.Wired alternatives were discarded because their installation would be problematic, and combinations of wired sensors and wireless gateways were also discarded because their connectivity would be problematic.Wireless sensors that work with both commercial solutions and open IoT cloud networks were considered.The latter option was chosen for its good scalability, high adaptability, and moderate cost.Monitoring spaces were representatively selected and labelled according to their key characteristics, such as location (floor, building, and campus), orientation (north, south, east, and west), use (classroom, study room, office, laboratory, library, canteen, etc.), size (large, medium, and small), occupancy (high, medium, and low), etc.

•
Networks.Sensors collect data.These collected data are sent to the following communication levels by various interconnected devices through their associated connectivity technologies.There are two main strategies: rely on classical cabled infrastructure centralized in SCADA systems, or use wireless protocols routed to the cloud using specific gateways, such as wireless fidelity (WiFi), 4G and the low power wide area network (LPWAN) technological family, such as SigFox, narrow band IoT (NB-IoT) and low range wide area network (LoRaWAN).Figure 2 shows a performance comparison to determine the most appropriate technology in order to propose homogeneous infrastructures.This comparison shows, among other issues, the importance of battery life and ease of battery replacement.As a consequence of the minimum maintenance cost and highest energy optimization and coverage range, Lo-RaWAN technology was selected for this work from the rest of LPWAN technological family.LoRaWAN specification [67] is a networking protocol, designed to wirelessly connect battery-operated sensors with bi-directional communication and localization services, that targets other key IoT requirements, such as end-to-end security, high interoperability and low monthly costs due to provider network fees.All this implies that buildings can be characterized as complex systems (see middle area in Figure 1), where feedback from contextual knowledge includes energy efficiency performance, indoor comfort, IAQ, environmental impact, facility management and location-based services, among others.As this work is focused on energy efficiency and IAQ; their implications in this context are detailed as follows.On the one hand, the energy demand in a building can be estimated through the energy regulations when it was built.However, several key factors (design, orientation, ubication, and use) can produce large consumption variations studies [37].Even in new buildings, there are significant differences between calculated energy and measured consumption, reinforcing the idea of filling the gap between theoretical values and real data studies [38][39][40].Thus, data provided by IoT ecosystems are essential to make knowledge-driven decisions.
On the other hand, to improve IAQ, two main parameters come into play: introducing exterior air and filtering it.Introducing exterior air can be achieved without supplying energy to the system through natural ventilation.However, mechanical ventilation can provide controlled and filtered flows at the cost of energy consumption.Hybrid systems offer the advantages of both approaches, but it is essential to discern when and how to combine them.In all three cases, measurements provided by IoT ecosystems are crucial to understand how HVAC systems interact with users and the building, enabling to make knowledge-driven decisions.Therefore, the continuous and real-time monitoring of building performance (such as energy consumption, HVAC and SCADA services, ambient sensors, etc.), compared with external data (such as historical weather data and forecast), and integrating with other key variables (such as renewable energy levels of the photovoltaic panels) lead IoT ecosystems as a great learning factory to understand how a building really works under their operating conditions.
As detailed in Section 4, an entire university campus (with 3 buildings of 14,000 m 2 for 1000 students and 250 staff, 21,000 m 2 for 1500 students and 350 staff, and 27,000 m 2 for 2000 students and 450 staff) was used as the IoT learning factory.As Figure 3 shows, it is essential to understand the current status of the built environment, which typically can be classified into one of the following three general types of buildings (not only university buildings) according to ventilation and energy efficiency:

•
Buildings without mechanical ventilation, and insulation deficiencies in both thermal transmittance of the building envelope and air permeability.In many cases, none of these building types previously deployed IoT ecosystems.Thus, improvements in the key factors in building performance involve transversal efficiency and IAQ strategies, such as the following:

•
Replacement of the building envelope to reduce energy transfer and air permeability.many cases, none of these building types previously deployed IoT ecosystems.Thus, improvements in the key factors in building performance involve transversal efficiency and IAQ strategies, such as the following:

•
Replacement of the building envelope to reduce energy transfer and air permeability.

•
Replacement of the current HVAC systems with more efficient solutions by designing a ventilation network with dual flow and sectorization to incorporate heat recovery systems.

•
Integration of a smart management and control system through IoT ecosystems.
It is well known that, for the first scenario, it is essential to reduce the energy transfer that occurs in the building envelope and decrease air permeability, as well as to improve the performance of HVAC systems.In the second case, a possible improvement involves installing new distribution systems and suitable terminals for each space.Both of these strategies have significant impacts on users, as well as high economic costs.In the third scenario, it is necessary to introduce smart systems capable of making real-time adaptive decisions.In all three cases, the IoT strategy proves to be effective and compatible and could be the appropriate solution in terms of cost effectiveness, technically feasibility and socially accessibility, especially for public buildings and urban areas occupied by vulnerable groups.As shown in Figure 3, the added value of IoT-based strategies is as follows:

•
In buildings without mechanical ventilation, IoT helps to improve IAQ by detecting potentially dangerous concentrations of CO 2 (through alarms or visual indicators) and adjusting when and how to use natural ventilation, in combination with available HVAC systems, according to both indoor and outdoor conditions.It allows for manual minimization of energy losses while minimizing health risks.

•
In buildings with hybrid systems, IoT enables smart control of the systems, whether centralized or specific to each space.Thus, IoT provides users knowledge about how to modulate mechanical ventilation and HVAC systems in combination with natural ventilation, according to both indoor and outdoor conditions, and regarding the environmental context.

•
In efficient energy buildings, IoT enables the precise and smart adjustment of HVAC systems, moving towards the paradigm of an active building.An active building is capable of using artificial intelligence (AI) to make real-time adaptive decisions.This term highlights the building's ability to smartly adapt to changing conditions and demands, leading to improved energy efficiency, comfort, and IAQ.IoT informs users when to select natural ventilation, which is essential to connect people with the environment.
In all cases, the integration of IoT ecosystems into built environment leads to learning, modeling, and visualizing when the building systems (management, operating, production, distribution, etc.) are most efficient, according to its KPIs, such as (see right upper area in Figure 3) (1) building performance, (2) occupancy, (3) behavior patterns, (4) weather forecast, (5) renewable energy, (6) energy costs, (7) indoor and outdoor air quality, and (8) environmental impact.
All these concepts show that IoT ecosystems are key to understanding the building behavior in relation to human behavior.In addition to better adjust HVAC or SCADA systems, IoT compares the overall building performance and also connects it with the natural environment.And it is essential because there are no two habitats alike in the world.Two identical buildings can have different behaviors depending on how users interact with them and vice versa: identical uses in different buildings can yield different results.In this complexity of interconnections and interrelations, IoT arises as the transversal discipline that should better meet the challenge to understand buildings as complex systems by using their behavior and knowledge as a learning factory to make data-driven decisions.
As shown in the lower part of Figure 3 and discussed in Section 4, IoT as a learning factory contributes to improving overall knowledge about architectural data-driven design, energy rehabilitation actions, and occupancy planning strategies.

Results and Discussion
Following all the premises detailed in previous sections, an IoT ecosystem (named sensoriZAR) was designed, developed, and implemented on the Campus Río Ebro of the University of Zaragoza (Zaragoza, Spain) [68].sensoriZAR was designed to store a large volume of heterogeneous data (acquired at high speed), homogenize them into information, and provide added-value knowledge.Its functional architecture follows the principles detailed in Figure 1 by integrating five modules in three layers: data acquisition (from sensors) and network interconnection (perception layer); information storage and processing (technologies layer); and knowledge analytics and visualization (application layer).Thus, sensoriZAR harmonizes various mechanisms for importing, exporting, downloading, monitoring, and integrating data through application programming interfaces (APIs) for third-party use, including research studies and making data-driven decisions.sensoriZAR was built as a homogeneous and ultra-low-energy-consumption IoT ecosystem with free hardware and software to be a cost effective and sustainable IoT-based tool for improving energy efficiency and IAQ in buildings.
The methodology of sensoriZAR IoT ecosystem for systematizing the acquisition, store and processing, and analysis and visualization of real-time measurements, follows a 3-level process: 1.
Identify buildings to analyze their performance requirements.University buildings shows different orientations (north, south, east, and west), predetermined use patterns (regarding timetables), non-predetermined behaviors (regarding people performance), and high thermal variation (low temperatures in winter and high temperatures in summer), among many other sources of variation.Three buildings on the Campus Río Ebro were selected for study: Ada Byron (Building I), Torres Quevedo (Building II), and Agustín de Betancourt (Building III).These buildings were selected because of their diversity of uses, the heterogeneity of their spaces, and the possibility of sectorizing their HVAC systems, among other key factors that allow the systems to be extrapolated to the rest of the university campus.

2.
Select representative spaces to monitor.As detailed in Section 3, the monitoring spaces were selected and labelled according to their key characteristics, such as their location (floor, building, campus), orientation (north, south, east, west), use (classroom, study room, office, laboratory, library, canteen, etc.), size (large, medium, small), occupancy (high, medium, low), etc.As a representative example, Figure 4 shows all the ambient sensors deployed in Building I of Campus Río Ebro.

3.
Deploy the sensor infrastructure and configure the IoT ecosystem.sensoriZAR was deployed with more than 200 geolocated wireless ambient sensors in more than 100 representative spaces in the 3 buildings of Campus Río Ebro (Building I, II and III).This deployment collects a dataset of more than 10,000 real-time measurements every hour of CO 2 , temperature, humidity, and occupancy.Furthermore, the IoT ecosystem also integrated energy and electricity consumption data from the SCADA systems for the entire Campus Río Ebro.
From this methodology, as this work focuses on energy efficiency and IAQ, the following results show several experiments through real installations where IoT allows understanding the building complexity and proposing a proof-of-concept of prediction of CO 2 and temperature based on neural networks.
First, focused on energy efficiency analysis, Figures 5 and 6 illustrate several lessons learned about energy consumption, costs, and savings.As a representative example, Figure 5 shows the average temperature evolution each day of the week in a building of Campus Río Ebro (Building I).The measurements (graphic in orange color) are the result of averaging the daily temperature measurements of every monitoring space in Building I during the fall semester (Figure 6 details December 2022 and January 2023).As in Spain, following Order PCM/466/2022 [69] for buildings of the General State Administration and institutional public sector entities, public buildings with associated HVAC energy consumption must keep the indoor temperature (when heating) between 17 and 21 • C; thresholds are marked in Figure 5 with a pink line (for 17 • C) and a orange line (for 21 • C).Every week is delimited between the vertical blue lines, and every day can be identified by its maximum (peak) temperature value: a zoom is detailed (framed in green color), where every peak is underlined as Monday, Tuesday, etc., including the weekend (shaded in yellow color).Thus, Figure 5 highlights two interesting features:

•
Every week, there is an increase in the average daily temperature (as a sawtooth), which helps to explain the thermal inertia of the building behavior.It is very interesting to know this behavior because by measuring the daily maximums and minimums according to each day of the week and comparing the graph with the 21 • C threshold, it is possible to estimate the savings potential.According to the measurements obtained, the implementation of an IoT-managed HVAC system should imply savings between 10 and 15% of the total energy consumption by switching off the heating pumps when monitoring spaces that reach thermal comfort (around 21 • C).

•
On weekends and holidays, such as Christmas (areas shaded in yellow color), average temperatures drop below the 17 • C threshold.Thus, the start of each week on Monday implies significant energy consumption to increase temperatures to the thermal comfort zone (between 19 and 21 Campus Río Ebro were selected for study: Ada Byron (Building I), Torres Quevedo (Building II), and Agustín de Betancourt (Building III).These buildings were selected because of their diversity of uses, the heterogeneity of their spaces, and the possibility of sectorizing their HVAC systems, among other key factors that allow the systems to be extrapolated to the rest of the university campus.2. Select representative spaces to monitor.As detailed in the Materials and Methods section, the monitoring spaces were selected and labelled according to their key characteristics, such as their location (floor, building, campus), orientation (north, south, east, west), use (classroom, study room, office, laboratory, library, canteen, etc.), size (large, medium, small), occupancy (high, medium, low), etc.As a representative example, Figure 4 shows all the ambient sensors deployed in Building I of Campus Río Ebro. 3. Deploy the sensor infrastructure and configure the IoT ecosystem.sensoriZAR was deployed with more than 200 geolocated wireless ambient sensors in more than 100 representative spaces in the 3 buildings of Campus Río Ebro (Building I, II and III).This deployment collects a dataset of more than 10,000 real-time measurements every hour of CO2, temperature, humidity, and occupancy.Furthermore, the IoT ecosystem also integrated energy and electricity consumption data from the SCADA systems for the entire Campus Río Ebro.
From this methodology, as this work focuses on energy efficiency and IAQ, the following results show several experiments through real installations where IoT allows understanding the building complexity and proposing a proof-of-concept of prediction of CO2 and temperature based on neural networks.
First, focused on energy efficiency analysis, Figures 5 and 6 illustrate several lessons learned about energy consumption, costs, and savings.As a representative example, Fig- To deeply analyze some of these trends, Figure 6 shows (as a zoom) the detail of the daily temperatures of various monitored spaces in this building, specifically, six classrooms on the second floor with the same characteristics: capacity for 70 people (medium size) with medium occupancy and north orientation.The measurements (graphics in different colors for every classroom from A to F) are the instant temperature over three days (Saturday, Sunday, and a holiday Monday). Figure 6 shows that several classrooms (D, C, and F) follow anomalous trends since their temperatures reach very high values when the heating system should be disconnected.Thanks to the IoT ecosystem reporting this building performance, the energy management system was queried, and it was found that the thermostats in those classrooms (C in orange and D in were not working correctly.Thus, the HVAC system was active all weekend.In addition, classroom F (in blue) was not marked in the energy management system as a holiday, so the HVAC system started on Monday as if it were a conventional week.
during the fall semester (Figure 6 details December 2022 and January 2023).As in Spain, following Order PCM/466/2022 [69] for buildings of the General State Administration and institutional public sector entities, public buildings with associated HVAC energy consumption must keep the indoor temperature (when heating) between 17 and 21 °C; these thresholds are marked in Figure 5 with a pink line (for 17 °C) and a orange line (for 21 °C).Every week is delimited between the vertical blue lines, and every day can be identified by its maximum (peak) temperature value: a zoom is detailed (framed in green color), where every peak is underlined as Monday, Tuesday, etc., including the weekend (shaded in yellow color).Thus, Figure 5 highlights two interesting features:   Every week is delimited between the vertical blue lines, and every day can be identified by its maximum (peak) temperature value: a zoom is detailed (framed in green color), where every peak is underlined as Monday, Tuesday, etc., including the weekend (shaded in yellow color).Thus, Figure 5 highlights two interesting features:   All these quantitative results demonstrate the value of using IoT ecosystems for the real-time monitoring of building KPIs to detect anomalies, correct malfunctions, and even anticipate potential breakdowns through predictive techniques as it is studied in the third contribution of this section.
Second, focused on IAQ analysis, Figures 7 and 8 show several lessons learned about the improvement of healthy environments.Figure 7 shows the average CO 2 levels (in percentages; see the left axis) of every building in Campus Río Ebro (Buildings I, II, and III).These average CO 2 levels are the result of averaging the daily CO 2 measurements of every monitoring space in each building during the fall semester (from September 2022 to 2023).The average values show in all cases how CO 2 levels meet the recommended levels (CO 2 < 1000 ppm (in light green) under usual conditions, with CO 2 < 800 ppm (in dark green) to minimize the COVID-19 risk) around 90% of the time: 88.22% in Building I, 92.26% in Building II, and 93.36% in Building III.In a controlled masterclass environment, where only the teacher is speaking most of the time, Figure 8a shows how CO2 < 1000 ppm more than 95% of the time.In a more variable environment and a space with a smaller capacity, in which people interact with computers, talk to each other, the teacher interacts with each practice group, etc., Figure 8b shows how CO2 increases (CO2 > 1000 ppm around 20%) and also the maximum CO2 measurements increase (red dots in right axis are higher than 2000 ppm).In an environment such as a canteen, with high roaming (the flow of people constantly changing), open spaces, and high ceilings that imply air and CO2 renewal, Figure 8c shows CO2 < 1000 ppm of almost 100%.
All these results show interesting trends in the CO2 behavior in buildings depending on the typologies of spaces, their size, orientation, location, and use, among other features.Furthermore, the contribution of IoT ecosystems as learning factories allow these trends to be extrapolated to all types of buildings: administration, institutional, education, ser- Figure 8 shows, as a zoom, the detail of a representative space of each of these buildings to analyze similarities and differences according to each type of space: (a) in Building I, a classroom with a capacity for 120 people (large) with high occupancy and a northern orientation; (b) in Building II, a computer room with a capacity for 44 people (small) with high occupancy and a western orientation; and (c) in Building III, a canteen with capacity for 260 people (very large) with a medium occupancy and an eastern orientation.In a controlled masterclass environment, where only the teacher is speaking most of the time, Figure 8a shows how CO2 < 1000 ppm more than 95% of the time.In a more variable environment and a space with a smaller capacity, in which people interact with computers, talk to each other, the teacher interacts with each practice group, etc., Figure 8b shows how CO2 increases (CO2 > 1000 ppm around 20%) and also the maximum CO2 measurements increase (red dots in right axis are higher than 2000 ppm).In an environment such as a canteen, with high roaming (the flow of people constantly changing), open spaces, and high ceilings that imply air and CO2 renewal, Figure 8c shows CO2 < 1000 ppm of almost 100%.
All these results show interesting trends in the CO2 behavior in buildings depending on the typologies of spaces, their size, orientation, location, and use, among other features.Furthermore, the contribution of IoT ecosystems as learning factories allow these trends to be extrapolated to all types of buildings: administration, institutional, education, services, etc. Figure 8 shows, as a zoom, the detail of a representative space of each of these buildings to analyze similarities and differences according to each type of space: (a) in Building I, a classroom with a capacity for 120 people (large) with high occupancy and a northern orientation; (b) in Building II, a computer room with a capacity for 44 people (small) with high occupancy and a western orientation; and (c) in Building III, a canteen with capacity for 260 people (very large) with a medium occupancy and an eastern orientation.
In a controlled masterclass environment, where only the teacher is speaking most of the time, Figure 8a shows how CO 2 < 1000 ppm more than 95% of the time.In a more variable environment and a space with a smaller capacity, in which people interact with computers, talk to each other, the teacher interacts with each practice group, etc., Figure 8b shows how CO 2 increases (CO 2 > 1000 ppm around 20%) and also the maximum CO 2 measurements increase (red dots in right axis are higher than 2000 ppm).In an environment such as a canteen, with high roaming (the flow of people constantly changing), open spaces, and high ceilings that imply air and CO 2 renewal, Figure 8c shows CO 2 < 1000 ppm of almost 100%.
All these results show interesting trends in the CO 2 behavior in buildings depending on the of spaces, their size, orientation, location, and use, among other features.Furthermore, the contribution of IoT ecosystems as learning factories allow these trends to be extrapolated to all types of buildings: administration, institutional, education, services, etc.
Thus, as a third contribution to learning to estimate CO 2 levels more accurately and enhance the numerical model by applying computer science techniques, a prediction model based on a back propagation neural network (BPNN) was researched.Indeed, the BPNN enables the quick and accurate identification of nonlinear relationships between various input variables and output objectives, thus enhancing the prediction of complex systems.A prediction model for the study room can be used with a double purpose: to inform the user about the trend in the value of CO 2 and temperature, and to be implemented in a smart control system for the HVAC system, which, in the case of a predicted temperature increase (due to human load, solar, etc.), for example, switches off the heating supply before the setpoint temperature is reached, with consequent energy savings, or it renews the air, with consequent air quality improvement.
The experiment involved the study room, which is a large space located on the ground floor, facing south, and equipped with large glass windows.It has a surface area of 761 m 2 , an air volume of 2666 m 3 , and a maximum capacity of 464 people.The occupation is high and variable.The actual occupation was measured with a sensor that determines the exact number of people present at any given moment.More than 1500 measurement records of each type for the opening hours of March 2022 were analyzed.The BPNN was trained for a prediction horizon of one hour.The neural network application used was neural net fitting (MATLAB r2022a), along with a Bayesian regularization algorithm of 10 hidden neurons (the hidden layer size) as indicated by default in [70].In total, 70% of the input data was used to train the network, and of the remaining 30%, 15% was used for validation (validating the network and stopping training before overfitting occurs), and 15% was used to test the network independently.
The data collected by the sensors, such as CO 2 (ppm), temperature ( • C), humidity (%), occupancy (pax), and accumulated occupancy (pax) values, were used as inputs to predict the CO 2 values and indoor temperature.Table 3 shows the input data (columns 2-6), where accumulated occupancy is the addition of the occupancy of the last 55 min (with measurements every 11 min per period).Columns 7-8 show the predictions for CO 2 and temperature for five subsequent time periods.As an example, eight training records are shown in Table 3. Predictions (shaded in rows 1-3, columns 7-8) are adjusted accurately to measurements made one hour later (shaded in rows 13-15, columns 2-3).
Figure 9 shows the results obtained by applying the neural network to the data measured during the month of March, obtaining a regression value of R 2 = 0.996 and a Mean Squared Error (MSE) of 535 for CO 2 and 0.219 for temperature.This high degree of correlation confirms the usefulness of the BPNN as a promising strategy for making this type of prediction if the sample size is sufficiently large.The precision of the prediction (±23.13 ppm) is less than that of the CO 2 sensors, which is ±40 ppm.Similar results can be found for temperature, where a precision of ±0.46 • C is like ±0.45 • C of the sensor precision.The predicted values (indicated by the blue line) fit the measured values (indicated by the black line) remarkably well.The neural network obtained is already available for use in the IoT ecosystem as a prediction tool for CO 2 levels and temperature.To further increase the level of accuracy, additional experimental data could be obtained throughout the entire year.Furthermore, variables such as humidity, HVAC system operation, indoor activity, windows opening, wind incidence, and other external climatic characteristics should be included to increase the correlation between sensor data and predictions or the time horizon of the prediction.Given the demonstrated usefulness of the BPNN, additional experiments should be carried out to extend the methodology to other kinds of spaces.tire year.Furthermore, variables such as humidity, HVAC system operation, indo ity, windows opening, wind incidence, and other external climatic characteristics be included to increase the correlation between sensor data and predictions or horizon of the prediction.Given the demonstrated usefulness of the BPNN, ad experiments should be carried out to extend the methodology to other kinds of sp

Conclusions
The proposed methodology, understanding that the implementation of an IoT ecosystem turns buildings (especially university buildings) into a learning factory, show several lessons learned through real installations about how IoT ecosystems can behave as costeffective solutions to understand the built environment as a complex system.Moreover, the deployment of IoT-driven solutions contributes as transversal strategies to improve energy efficiency and IAQ and help to predict building performance.The implementation of IoT ecosystems facilitates the customized analytical study of specific situations.
As is well known, the major industrial companies are working on digital twin models.In the context of proprietary solutions (that usually offers closed and expensive solutions), this work proposes a transversal IoT ecosystem developed from the premises of opening (software and hardware), modularity and interoperability.Furthermore, this work provides mechanisms for importing, exporting, downloading, monitoring, and integrating data through APIs for third-party use to assist the scientific community and also the industrial sector in its innovations and research studies.
As mentioned in Section 1, IoT ecosystems are key to understanding the complexity of the built environment by filling the gap between theoretical simulations and real measurements.This change in environment (between simulated and real behavior) is attributable to the key reasons for building performance: the variety of uses, characteristics of construction, orientation, location, climatic conditions, and environmental context, among other factors.
Thus, IoT ecosystems are key to transversal strategies for reducing energy consumption, increasing energy efficiency, improving IAQ, enhancing healthy environments and predicting performance, for the following reasons:

•
IoT helps us to understand user and building behavior patterns, adjust energy production to real demand and vice versa, and understand how buildings process energy, enabling changes in the behavior patterns of their managers and users.

•
By combining real data on energy use, CO 2 , temperature, and occupancy, IoT helps us to understand buildings as complex systems in specific climatic locations and perform modeling, simulations, and predictions towards the paradigm of hybrid twins.Thus, IoT monitoring provides the knowledge to characterize the built environment (since the information to create a digital model is not always available), overcoming the difficulty of access to data, such as construction materials, architectonic decisions, thermal bridges, uncontrolled infiltrations, window efficiency, and HVAC performance, among other factors.

•
IoT permits the detailed analysis of specific cases, uses, and spaces to identify the best energy retrofit strategies.For each building case, IoT helps to quantify which energy improvement strategy will be most effective in reducing energy consumption and greenhouse gas emissions.

•
IoT facilitates the detection of anomalies, energy leaks, airflow, unused spaces, open windows, etc., as well as inefficiencies in HVAC systems and maintenance failures, among other potential malfunctions.

•
IoT enables smart management in operation together with the building systems: HVAC, SCADA, lighting, security, mobility, climate regulation, home automation, access control, etc.

•
IoT ecosystems, when interconnected on a larger scale (city, region, country, etc.), provide data for use in sociodemographic studies and analysis of how buildings are used, enabling knowledge-driven decisions for rehabilitation strategies.Mobility and communities are closely interconnected, providing insights into how users invest time and energy.
IoT also shows limitations.It needs to be integrated together with the building systems and their data deeply analyzed using computer science techniques to keep moving hybrid twins forward by combining active and passive systems for buildings that are activated (automatically and/or manually) with the IoT-generated knowledge.These are future lines of this work.On the one hand, we must include many more variables (indoor activity, outdoor weather, windows opening, wind incidence, etc.) and integrate the building systems (climate regulation, lighting, mobility, security, etc.) to better understand the complexity.On the other hand, to deepen this understanding, we must apply computer science methodologies to enhance decision making for the management and optimization of the built environment.
In summary, in real contexts of economic restrictions, complexity, high energy costs, social vulnerability, and climate change, IoT-based strategies, such as those proposed in this work, are highlighted as open, modular, interoperable, and cost-effective approaches to moving towards smart communities by improving energy efficiency and indoor and outdoor environmental quality with low cost, quick implementation, and low impact on users.These IoT-based strategies address great challenges for growth, interconnection, climate change, and overall sustainability.Through the real-time monitoring of building performance, IoT ecosystems can be seen as a way of democratizing information while saving energy and costs, especially for public buildings and urban areas with vulnerable groups, while maintaining the comfort, well-being, and quality of life of the people who live the building.

Figure 2 .
Figure 2. Comparison between LoRaWAN and LPWAN technological family.Source: own; from several studies, such as [67], among others.•Cloud.Cloud computing services use a network layer (to connect remote devices or industrial TCP-IP protocols, such as MODBUS-TCP or OPCUA through SCADA

Figure 6 .
Figure 6.Details of instant temperatures in several representative classrooms during a weekend.Source: own; data available from https://sensorizar.unizar.es,accessed on 31 July 2023.

Figure 6 .
Figure 6.Details of instant temperatures in several representative classrooms during a weekend.Source: own; data available from https://sensorizar.unizar.es,accessed on 31 July 2023.

Figure 6 .
Figure 6.Details of instant temperatures in several representative classrooms during a weekend.Source: own; data available from https://sensorizar.unizar.es,accessed on 31 July 2023.

Figure 8 Figure 8 .
Figure8shows, as a zoom, the detail of a representative space of each of these buildings to analyze similarities and differences according to each type of space: (a) in Building I, a classroom with a capacity for 120 people (large) with high occupancy and a northern orientation; (b) in Building II, a computer room with a capacity for 44 people (small) with high occupancy and a western orientation; and (c) in Building III, a canteen with capacity for 260 people (very large) with a medium occupancy and an eastern orientation.