Next Article in Journal
Analysis of Structural Health Monitoring Data with Correlated Measurement Error by Bayesian System Identification: Theory and Application
Previous Article in Journal
A Multirobot System in an Assisted Home Environment to Support the Elderly in Their Daily Lives
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:

Internet-of-Things Based Hardware-in-the-Loop Framework for Model-Predictive-Control of Smart Building Ventilation

LERMA Lab, College of Engineering, The International University of Rabat, Technopolis Rabat-Shore Rocade Rabat-Salé, Sala El Jadida 11100, Morocco
I&A Laboratory, Faculty of Science, Moulay Ismail University of Meknès, B.P. 11201 Zitoune, Meknès 50070, Morocco
ENSIAS, Mohamed V University, Rabat 10713, Morocco
Univ. Bourgogne Franche-Comte, UTBM, FEMTO-ST UMR CNRS 6174, 25000 Belfort, France
Authors to whom correspondence should be addressed.
Sensors 2022, 22(20), 7978;
Submission received: 29 September 2022 / Revised: 11 October 2022 / Accepted: 13 October 2022 / Published: 19 October 2022
(This article belongs to the Topic IoT for Energy Management Systems and Smart Cities)


In this work, a Hardware-In-the-Loop (HIL) framework is introduced for the implementation and the assessment of predictive control approaches in smart buildings. The framework combines recent Internet of Things (IoT) and big data platforms together with machine-learning algorithms and MATLAB-based Model Predictive Control (MPC) programs in order to enable HIL simulations. As a case study, the MPC algorithm was deployed for control of a standalone ventilation system (VS). The objective is to maintain the indoor Carbon Dioxide (CO2) concentration at the standard comfort range while enhancing energy efficiency in the building. The proposed framework has been tested and deployed in a real-case scenario of the EEBLab test site. The MPC controller has been implemented on MATLAB/Simulink and deployed in a Raspberry Pi (RPi) hardware. Contextual data are collected using the deployed IoT/big data platform and injected into the MPC and LSTM machine learning models. Occupants’ numbers were first forecasted and then sent to the MPC to predict the optimal ventilation flow rates. The performance of the MPC control over the HIL framework has been assessed and compared to an ON/OFF strategy. Results show the usefulness of the proposed approach and its effectiveness in reducing energy consumption by approximately 16%, while maintaining good indoor air quality.

1. Introduction

Heating, ventilation, and air-conditioning (HVAC) systems are considered among the main building’s energy consumers. They account for approximately 50% of the global energy usage in buildings and 36% of all energy-related CO2 emissions worldwide [1,2]. Therefore, HVAC systems need to be efficiently designed and controlled, in reference to international standards, to ensure optimal trade-off between the occupants’ comfort and energy efficiency in buildings [3,4]. On the other hand, to assess the energy performance in the design of HVAC management services in buildings, four main comfort metrics need to be considered, which are the visual comfort, acoustic comfort, thermal comfort, and the Indoor Air Quality (IAQ) [5]. This latter has been identified as one of the most important metrics influencing the indoor environmental comfort of the occupants as well as one of the main sources of energy consumption in buildings [4,6], which depends mainly on standalone ventilation management systems.
On the other hand, the indoor concentration of CO2 is considered among the most important parameters for developing efficient control strategies of VSs [7]. The aim is to minimize their electrical energy consumption, while providing good IAQ to the occupants. The objective is to keep the CO2 concentrations within the comfort range by providing the required fresh air from outside to the inside of the building using optimal ventilation flow rates. Basically, the majority of conventional building’s VSs are operated by simple rules-based controllers (e.g., intuitive ON/OFF controllers or simple PID controllers). Most of them are based on predefined operating parameters, which use normal ventilation rates, to provide the amount of outside air demanded by the building. However, their control mechanism is still inefficient regarding the performance decrease in frequent system context changes as well as dealing with the time-delay [8]. Typically, the ventilators acts automatically on behalf of many buildings’ context-awareness parameters, such as the indoor temperature (based on the envelope characteristics), control modes of the VSs, and occupants’ presence [9]. This can affect the energy operation flexibility, indoor environmental comfort, and occupants’ productivity due to uncontrollable ventilation rates, resulting in wasted energy [10].
Recent studies highlighted that weather conditions and occupants’ behavior are the most important information that can help to improve a building’s services (e.g., VSs) [7]. Occupancy detection systems in buildings are mostly involved in extracting meaningful occupancy information, which could be used for setting up different control strategies. Different occupancy parameters can be collected from the building’s environment including occupants’ presence, number, activity, identity, location, and tracks. All of these metrics can be integrated in Building Energy Management Systems (BEMS) as a primary input for controlling active/passive systems, such as HVAC, standalone ventilation, and lighting [11,12,13,14]. Most recent research work investigated the development of intelligent methods by integrating machine learning, deep learning, and reinforcement learning [15,16]. In addition, advanced techniques from automation, system modeling and optimization, Internet of Things (IoT) for real-time systems monitoring, data processing and context-aware computing techniques could be combined for the development of BEMS [17].
As is commonly known, new innovative designs of equipment and system components need to be tested while going through extensive essays [18]. The aim is to validate and properly ensure their reliability before deploying them in real-sitting scenarios. The tests can either be run in a laboratory (small scale), using only pure simulations, or by combining both ways, resulting in HIL simulations [19]. Unlike conventional simulations, concrete testing in laboratories may be seen as the most accurate and is a sure indicator of performance. However, it has some limitations. First, it can generate high costs and is subject to many constraints. For instance, the number of tests that can be run over a period of time and under the same conditions are very limited. Hence, comparing different control approaches or different products providing the same function becomes challenging. On the other hand, numerical simulation is another used method among engineers and researchers to properly evaluate the performances of control methods of many applications, which can be deployed in buildings or other sectors. Numerical models could capture the dynamic of the equipment and the building while considering real weather conditions (if available), the combined internal loads (gains, lighting, occupancy, etc.), and other stimuli. Furthermore, once the numerical model is mature enough, it can be used repetitively to evaluate equipment’s control at lower costs. For this, the model should prove its fidelity and accuracy in mimicking the real system’s behavior and the related building. As can be noticed, a variety of validated models and toolkits are available for a variety of domains using different simulation tools [20]. It is worth mentioning that, during the recent decades, co-simulation capabilities expanded the modeling scope further to other domain systems at a very precise resolution [21]. However, some problems cannot be tackled easily through simulations, especially if numerical models cannot capture all necessary details [22].
In parallel, recent advances in IoT and big data technologies allow for real time data monitoring and processing, while enabling predictive analytics and advanced systems’ control. In fact, IoT is considered the most important emerging technology, allowing for the development of advanced and smart connected solutions varying from eHealth, industry and transportation to energy management and smart control [23,24,25,26,27,28,29,30,31]. Any system or device having the capability to connect to a network and communicate over the Internet is considered a thing in an IoT infrastructure [32]. This latter provides required tools to manage, control, monitor, visualize and process the things’ data (e.g., embedded devices, smartphones, smart actuator, sensors). In parallel to this progress, the integration of smart energy grids with IoT and big data techniques has recently emerged into what is named the Internet of Energy or Energy Internet [19,20]. In fact, with the emergence of smart power meters and smart electrical appliances, it is now possible for users to closely monitor energy consumption while having the ability to plan and manage their consumption. The IoT infrastructure makes it possible to capture and analyze sensor data in real time, allowing consumers to interact with data and decision making [33].
The main aim behind the framework proposed in this paper is to fill the gap between simulations and real case experimental validation of control approaches and mechanisms. The framework could be used not only to control buildings systems but also for other use cases in which the experimental validation of a developed control model is needed. A flexible architecture of the platform has been introduced and its components are detailed to provide an easy to implement solution for similar applications. The work presented in this paper focuses on the integration of IoT/big data techniques with simulation tools in order to enable HILS. The aim is to join both field testing and numerical modeling by combining hardware and software to form HILS frameworks. These latter make it easy to assess multiple tests under the same conditions and, eventually, to accommodate for dangerous operations. As a case study, to show the usefulness of the HILS framework, a Model Predictive Control approach (MPC) was deployed on standalone VS. The framework integrates recent IoT and big data platforms together with machine-learning algorithms and MATLAB-based MPC model.
In summary, the objective of the work is twofold, first to show the usefulness of the proposed IoT based HIL framework together with the integrated machine learning model and smart control technique of MPC, and second, to study the performance of the MPC model combined with forecasted occupancy number and real-time test site’s contextual data. The goal of the experimentation is to maintain the indoor CO2 concentration at the standard comfort range while enhancing the energy efficiency. Setting up a field operational testing predictive control techniques is a very challenging and time consuming task. This work could leverage the gap between simulations and real application of predictive control in smart buildings.
The remainder of this paper is structured as follows. Section 2 presents recent work related to advanced strategies for smart control and IoT-HIL based approaches. In Section 3 and Section 4, the description of the used materials as well as the architectures of the proposed control strategies and the IoT-HIL platform will be presented. In Section 5, results are presented to demonstrate the accuracy of the proposed models as well as the developed framework. Conclusions and perspectives are presented in Section 6.

2. Related Work

Recent research work showed that reducing energy consumption in buildings, especially those related to HVAC systems, can be attained through the usage of advanced control strategies. In this regard, two main approaches of rule-based control algorithms have recently emerged in the field of advanced HVAC control: Learning based approaches (e.g., fuzzy logic, Artificial Neural Networks (ANNs), fuzzy and adaptive fuzzy neural networks and genetic algorithms) and MPC [34]. Among these control algorithms, MPC has been introduced as one of the most powerful control techniques used to manage complex processes, such as in HVAC systems [35] studies. This control technique can handle nonlinear processes and their dynamics according to different objectives functions, such as those related to indoor air quality and thermal comfort improvement [36,37].
On the other hand, one of the most efficient ways of conducting field operational testing appears to be the HIL simulations seeing its various advantages (low cost, accurate results, etc.) [38]. This new concept is becoming widely used in developing and testing complex real-time embedded systems [39]. This is mainly done by adding, through mathematical representations (also referred to as “plant simulation”), the complexity of the plant to be controlled into the test bed [40]. To perform HIL simulations, electrical emulation of sensors and actuators is used to interface between the “plant simulation” and the “system under test”. In fact, the plant simulation controls the value of the emulated sensor, which is then read by the embedded system under test. In HIL simulations for system synthesis, major physical equipment and their associated controllers are integrated with simulated devices or building spaces to investigate behaviors under realistic dynamic conditions.
In the last decade, researchers focused their interest on the HIL approach and used it not only in automotive and spatial systems but also in buildings’ equipment testing and control. For instance, Missaoui et al. [41] proposed new BEMS strategies to support demand side management and to validate them using a Power-Hardware-in-the Loop (PHIL) test bench. However, the proposed solution can be used to validate control algorithms in a reasonable time. Schneider et al. in [42] focused their work on investigating the interaction of a real circulating pump with the hydronic network of a virtual building energy and control system. The presented model, using Modelica for building simulation, is used to bridge the gap between the design and commissioning stage of a control algorithm for HVAC components. The used model is a single-family dwelling with limited complexity. The comparison between simulation results and measured data proved the accuracy of the model with a mean relative error less than 4%. De la Cruz et al. in [43] presented, in their paper, the implementation of an HIL real time simulation test bunch for Air-to-Water-Heat-Pumps (AWHP). This will allow HVAC manufacturers to optimize the control of their systems and to improve their efficiency. A real AWHP was tested under real climate conditions, as for the thermal loads, they were calculated through the connection of the AWHP and a virtual building, simulated using Modelica software, via HIL real time simulation. Seifried et al. in [44] proposed a new model, based on the interconnection of a prominent building automation protocol, namely BACnet, and the PowerDEVS simulator to facilitate HIL testability of new and existing building automation system components. Huang et al. in [22] presented an agent-based framework for HIL simulations, which could either be used for investigating the controller performance or HIL for system synthesis. In other words, it is possible to involve controllers as well as other major equipment in the test to ensure that their dynamic behavior is being correctly captured. Zahari et al. [45] developed a control algorithm to bring the HIBORO helicopter prototype into equilibrium. The developed algorithm is a combination of the MPC and the black box nonlinear autoregressive model. Using the Xpc Target rapid prototype under Simulink, HIL simulations have been run for different set points to evaluate the performances of the proposed model. This latter contains inertial measurement unit sensor software, the MPC, and C/T blocks for capturing and generating Pulse Width Modulation (PWM) signals. The controller proved its efficiency in terms of stabilizing the prototype under all disturbances.
Samano-Ortega et al. [46] developed a platform for the validation of photovoltaics (PVs) system controllers using IoT and HIL concept. The platform englobes five main parts: (i) a control emulator based on HIL, producing the behavior of PVs’ arrays, a converter, and Alternating-Current (AC) loads, (ii) Cloud database, (iii) smart sensors for load monitoring, (iv) residential PVs (RPVs) connected to the Internet, and (v) a mobile application for tracking and monitoring. The main principle is that measured voltage and current of the AC loads (using smart sensors) and the production of RPVs are downloaded to the HIL, which reproduces the behavior of the PVs and loads in real-time. The platform proved its efficiency in emulating the behavior of the installed PVs with a mean relative error of 0.42% and the AC load with a mean absolute error of 10 mA. Conti et al. [47] showed the relevance of the dynamic coupling between an air-source heat pump and a building apartment, located in Pisa (Italy), in winter in terms of energy performances under three different operational modes. The adopted HIL extensive experimental campaign proved its potential in properly estimating the energy consumption as well as developing advanced operational strategies. Frison et al. [48] developed a simple low cost MPC controller, which has been evaluated using HIL experiments, for assessing, under realistic conditions, the energy performances of a heat pump system.
Furthermore, due to the large availability of smart low-cost embedded devices (e.g., Arduinos, Raspberry pi, NVidia Nano, actuators, and distributed sensors), and data streaming processing tools, such as Storm/SAMOA and Kaa applications [49], and generally, the advances of information and communication of IoT technologies [50], the implementation of optimal control strategies for improving the energy efficiency as well as indoor air quality and thermal comfort is becoming immediate and more viable [51]. Their application has been widely studied for the development and deployment of intelligent context-aware services and applications, such as occupancy prediction [52], healthcare [31], transportation and logistics [53], smart grids [54,55], and smart homes [56]. For example, Huchuk et al. [16] evaluated numerous classification machine learning algorithms and models for predicting occupants’ presence in smart buildings using thermal data. Further, Zhang et al. [57] presented a literature review about the integration of machine learning for predicting occupancy patterns to improve indoor air quality, while optimizing energy use. In addition, online machine learning techniques (e.g., vertical Hoeffding tree and self-adjusting memory for KNN) can be included for predicting occupants’ number and presence using environmental data, such as CO2 temperature and humidity [58,59]. IoT and HIL concepts could provide an integrated solution to cover the important aspects of BEMS by enabling the collection, monitoring, and processing of stream data together with machine-learning techniques. These latter are, for instance, used to compute accurate forecasts, which are required for the MPC to compute accurate predictions, i.e., forecast optimal actions for real-time control of a building’s services.
In this work, a case study that focuses on a standalone VS, is worked out to assess the usefulness and effectiveness of the proposed HIL framework. In fact, data that has been collected from a set of sensors, such as temperature, motion, and CO2 concentration, is used to predict occupancy patterns [30]. These latter are then fed to the MPC to control indoor CO2 dynamics by forecasting the optimal ventilation rates.

3. Materials and Methods

In this section, an HIL experiment of a closed-loop VS driven by the MPC is performed. The MPC ventilation controller model, which has been previously designed, developed, and validated using simulations [28,29], has been physically deployed to the Raspberry Pi (RPi) located at the EEBLab test site. The RPi-in-the-loop experiment has been run under realistic conditions to dynamically actuate the fans of the VS and to assess the controller’s performance in terms of energy efficiency and indoor CO2 improvement. In fact, the deployed VS is made of two standalone controlled fans, which are respectively responsible for bringing the fresh outdoor air to the indoor and draining the CO2 out of the building. More precisely, these two fans are installed in both side walls and operate instantaneously under the same control signals. The VS can provide a maximum airflow rate of 440 m3/h, which is equivalent to a rated speed of 3800 rpm and is powered by a photovoltaic solar system. The occupancy information was used as a disturbance as well as a forecast input for the MPC.

3.1. Description of the Case Study Building: EEBLab

The considered specimen, named Energy Efficient Building Laboratory (EEBLab), is a rectangular cavity, which is part of a set of two identical prefabricated structures (Figure 1), located at the International University of Rabat. Each test bed is 12 m2 of occupied surface and 30 m3 of volume. Additionally, each prefabricated has one single glazed window on its south façade. The laboratory has been made essentially for implementing and testing different scenarios related to eHealth, Energy efficiency, ICT, and renewable energies integration and control. The main aim is to investigate the integration of recent IoT, big Data technologies, and advance real-time machine learning algorithms for developing context-aware services and applications.

3.2. The HOLSYS Internet of Things Platform Setup

The HOLSYS platform has been in development and passed from many stages namely, the use of Kaa project IoT platform and the upgrade to the ThingsBoard open source IoT platform. It allows configuring, supervising, and acquiring connected sensing and actuating nodes. Its aim is to allow the development and deployment of IoT based scenarios related to smart energy efficient buildings as well as eHealth and Smart Mobility. The HOLSYS platform follows the general architecture presented in Figure 2. The four layers define the different general sections/aspects of an IoT platform, namely, Sensing/actuating, Data Acquisition, Processing, and Visualization.

3.2.1. Sensing and Actuation Layer

Sensors and actuators represent all embedded sensors and actuators together with control units considered as one device and presented to the platform as an IoT node. This latter is capable of receiving and sending stream data while ensuring the execution of all control strategies sent by the platform. The communication between deployed nodes and the HOLSYS platform may pass through wired or wireless protocols. In this paper, only MQTT, REQUEST and REST have been used as the EEBLab is accessible in the campus network either wirelessly or through an ethernet connection.
The deployed IoT devices (nodes) are built using low-cost microcontrollers (e.g., NodeMCU, Arduino, STM32S) and presented to the platform using Raspberry Pi 3 and 4 B+ (RPi). A set of nodes can be connected in serial mode (USB), Serial Peripheral Interface (SPI), Inter-Integrated Circuit (I2C) or Bluetooth to the RPi gateway where NodeRed controls the inputs and the outputs of the set. NodeRed is a flow-based platform, developed originally by IBM, for facilitating the process of wiring hardware devices together with Application Programming Interfaces (APIs) and online services as part of the Internet of Things. A NodeRed flow is a set of connected logical NodeRed nodes linked together to form a processing logic with inputs and outputs. The resulting logic flow ensures gathering input data from wired or wireless IoT nodes, pre-processing and aggregating them to finally output structured data into local or remote storage systems.
Figure 3 presents the deployed sensors and actuators used in this study. (a) represents the Indoor air quality node connected to an RPi via a USB cable. It gathers the indoor CO2 concentration in Part Per Million (PPM) using an MH-Z14A sensor with an accuracy of ±50 PPM +3% reading value; (b) shows the control node of both inlet and outlet fans used to ventilate the EEBLab. The 12 V and 440 m3/h fans are controlled with PWM generated from an Arduino nano. Speed can be controlled from 0, for OFF mode, to 255 PWM for max speed (ON mode). However, a relay has been added to completely turn OFF the fans if 0 PWM has been triggered to save energy; (c) presents the deployed RPi based weather station with wind speed and direction, solar irradiance, ambient temperature and relative humidity sensors for outdoor environmental data. Used sensors are, respectively, an analog anemometer and magnetic direction sensors, SR20 pyranometer and DHT22 together with DS18B20; (d) depicts gate door motion sensors to determine the true occupants’ number inside the EEBLab. They are based on infrared emitters and receivers, which are aligned together at the door entrance, to detect the exact occupants’ number.

3.2.2. Data Acquisition Layer

Data collected at the first layer (Sensing and Actuation), using the deployed sensors, are sent via HTTP requests and MQTT by the RPi gateways to the HOLSYS platform, which is deployed in the remote server, as depicted in Figure 4. The HOLSYS platform is based on the open source Thingsboard IoT platform in its community edition. Services and packages together with all connectors enabling the acquisition of all the deployed IoT devices are installed and configured in the cluster composed of one performant master and three slaves. They are HP computers with Intel core i3 and i5 with 4 Gbytes of RAM and 500 Gbytes of storage each.
The HOLSYS acquisition layer is a set of RPis representing the deployed nodes to the platform. A RPi is a tiny credit-card sized computer using the Raspbian operating system, a free version based on Debian and optimized for its limited power. The three gateways that have been deployed are a 4 Gbyte RAM RPi 4 B+ and two 1 Gbyte RAM RPi 3 B+. NodeRed is used in these RPis to acquire data from the serial connected nodes to pre-process and store them locally in files for a backup. Each node is represented to the platform by a unique token and identifier, which is used to secure the communication and to identify the streamed data. HTTP requests have been used as a backup transfer protocol in case the MQTT broker becomes unfunctional. However, the HTTP protocol is not suitable for IoT architectures as it is more energy consuming and has a bigger data packet size. On the other hand, MQTT has been designed to provide a lightweight messaging technique enabling small packet size for faster transfer. The MQTT is an IoT data transfer protocol having publish/subscribe architecture. It is based on a broker to which all clients, either subscribers, publishers, or both at the same time, should be connected to (see Figure 5).
The installed broker is the central communication point where data is exchanged between clients based on a topic. This latter is a category in which a given client has published data. From the other side, the subscriber will get the data from the given topic.

3.2.3. Data Processing Layer

The processing of data can be performed in real-time or batch manners in the HOLSYS platform servers or by third-party applications deployed elsewhere. The local processing can be a simple aggregation of each received tuple of data or a complex processing using the rule-based engine. It is a customizable and configurable system for complex event processing. It allows for filtering, enriching, and transforming incoming data and triggering various actions, for example, notifications or communication with external systems. In the current study, a rule chain has been implemented to save received data to the HOLSYS database (NoSQL Cassandra) after applying filters on them according to each data source (e.g., Temperatures, Humidity and CO2 ranges; null values, missing data) and forward, via MQTT and Kafka, the filtered data to external sources for other applications. This latter plays a key role for integrating machine learning applications. For instance, the occupancy forecast, an important input to the MPC algorithm, is performed as an external application while using the filtered data coming from the platform. In fact, Apache Kafka, a high-performance real-time data streaming technology capable of handling large amounts of events, is used as a pipeline to transmit stream data between the platform and other applications (e.g., machine learning algorithms). This part shall be detailed in the next section. Furthermore, MQTT has been used to send data to the consumers in the MATLAB MPC control as it is supported by default as a communication method implemented by MATLAB. Figure 6 depicts the communication between the platform and the processing layer. Kafka and MQTT are the main tools used to allow the processing layer to receive data for occupancy forecasts and MPC control. For instance, the forecast model receives the indoor CO2 concentration and the real occupancy number, respectively over MQTT and Kafka, to forecast 10 steps ahead. Real-time forecasted values are fed as an input to the MPC controller in order to predict the required control actions, which are sent back to the HOLSYS platform for execution.

3.2.4. Data Storage, Visualization, and Applications Layer

This layer presents all external services that can be connected to the platform by means of supported data transfer protocols and technologies. Mainly, Kafka, MQTT, and HTTP requests are used to allow external third-party applications to connect, produce data, and consume available resources of the HOLSYS platform. In addition to the local NoSQL Cassandra database, which is deployed by default for storing data at the platform level, Mongodb is also used to store backup data for batch processing, serving other applications, such as training the forecast model of occupancy. The main reason behind using Mongodb is its architecture based on storing data as JSON format but with a special syntax called BSON. Each set of data is stored as a document into a collection while its content can be unstructured and different from other documents, resulting in the NoSQL principle, which does not need a tabular and relational concept. Furthermore, the collected data is broadcasted on MQTT using adequate topics for all other applications, mainly those requiring shared resources, such as weather data. As for data visualization, Grafana tool is being integrated with Cassandra and the Mongodb database for real-time visualization of data streams.

3.3. Data Measurement/Preparation for Occupancy Prediction

Occupancy information, as stated above, is one of the most important inputs to context-driven control approaches for efficient control of building equipment. Several studies show the effectiveness of integrating occupancy in MPC for HVAC, ventilation and lighting systems control [60,61]. In order to collect accurate occupancy prediction, different techniques can be used, including PIR sensors, cameras, RFID, Wi-Fi, Bluetooth-low-energy (BLE), and environmental data (e.g., CO2, temperature, and humidity) [62,63,64].
In this work a data set containing almost 28,000 instances for one day from 8:30 until 19:00 has been used. Data are collected from EEBLab using the occupancy number node and stored into a Mongodb data (see Figure 7). The occupancy profile varied between one and seven occupants during the day.
Deep learning-based occupancy forecasting techniques have been investigated [65]. The first two recurrent neural network (RNN) based methods, long short-term memory (LSTM) and gated recurrent unit (GRU), have been evaluated and compared in terms of accuracy and root mean square error. These algorithms are classified as extensions of RNN by integrating internal gates which help in deciding whether to keep or throw out the past relevant information compared to traditional RNN. The idea is to evaluate the first generated model and then decide which could be deployed in the EEBLab. Therefore, in this study, LSTM model performs well and has been selected to be exploited in the experiment, due to its effectiveness in terms of accuracy (LSTM 98.7%, GRU 97.5%) and root mean square error (RMSE) (LTSM 3.34, GRU 3.73) parameters. In fact, Apache Kafka has been used, in this case study, to consume the actual number of the occupancy, coming from the HOLSYS platform, to forecast the next 10 steps ahead, serving as a real time input for the MPC controller model.

3.4. MPC for Predective Control

The work presented in [29], presents the developed dynamic model for CO2-based MPC of a building’s VS. The model, describing this system, is a state-space model, which is based on the relationship between the input/output airflow rates and indoor CO2 concentrations. The MPC controller model was tuned to be deployed in a real case scenario, considering the real context of the EEBLab, in particular, the building space and occupancy number profile as well as the characteristics of the VS. Simulations have been conducted to the following highlights during the tuning of the MPC controller input parameters:
  • The controller output provides a slow response to CO2 set point and occupancy changes if the prediction horizon is short (i.e., 2 ≤ P ≤ 5 steps ahead);
  • The output of the controller acts faster on changes, which means that the controller’s prediction ability increases if the prediction horizon is long (i.e., P ≥ 10 steps ahead);
  • A longer control horizon (i.e., M ≥ 10 steps ahead), the response of the controller output becomes too aggressive and therefore overshoots, which does not occur when using a small control horizon.
In fact, the control horizon M and the prediction horizon P inputs are the key design parameters of the MPC. They have a significant impact on its performance (i.e., settling/rise time and stability), especially in the presence of disturbances.
In this experimental study, as schematized in Figure 8, the optimal control problem (OCP) of the MPC is solved for every time interval (30 s) in which its optimal control output is calculated for the entire horizon P. The inputs to the OCP are the forecasted occupancy number, the outdoor CO2 concentration, and the previous measurement of indoor CO2 concentration (k−1), along with the system constraints (i.e., indoor CO2 set point and airflow limits).
The prediction and control horizons used in the MPC framework are respectively P = 10 (i.e., 300 s) and M = 5 (i.e., 150 s) steps ahead. For occupancy, the forecasted number is used to control the indoor CO2 dynamics, including the CO2 generated by the occupants over the horizon P. The forecast of the occupants’ number and measurements of the indoor/outdoor CO2 are forwarded to the OCP. The optimized control output (i.e., minimal required airflow) is fed back to the dynamic model to calculate the future predictions of indoor CO2 concentrations for the entire prediction horizon P. This calculation is repeated every time interval. At each time interval, the future occupancy and prediction of the indoor CO2 concentrations along with the constraints are updated and passed to the OCP to plan the next sequence of control inputs to be applied at that time. Only the first optimal input of the control sequence is implemented, and the remaining input values are discarded.
To solve the OCP, the following quadratic cost function is used, which reduces the future error e ^ between the CO2 set point references y r e f and predicted indoor CO2 concentration y ^ through the prediction Horizon P . This is mainly achieved by applying the optimal control increment action Δ u ^ in which the minimum of airflow u is delivered and the indoor CO2 concentration y is maintained within comfort bounds. Q and R represent weighting matrices. The set point of indoor CO2 concentration is defined at 550 PPM, whereas the outdoor CO2 is kept at a constant value of 400 PPM.
M i n i m i z e Δ u J = 1 2 K = 0 k = P y ^ y r e f Q y ^ y r e f T + Δ u ^ R Δ u ^ T ,
Subject to, y < 550   PPM and 0 < u < 440   m 3 / h   ~ 0.12   m 3 / s   ~   122.22   L / s   ~   259   scfm .

4. Real-Time Implementation

This section presents the implementation of the MPC framework for controlling the VS with the aim to improve both the indoor air quality and energy saving. An HIL experiment in which the MPC model controller is physically implemented in an RPi development board is conducted. Figure 9 shows the blocks that have been integrated to enable the communication between the MPC VS model, which is carried out with the MPC toolbox of MATLAB/Simulink environment and the HOLSYS platform.
To enable the use of MQTT in the MATLAB/Simulink model, the Raspberry Pi support package for MATLAB and Simulink have been installed using MATLAB Add-ons.
Many blocks are available in the Simulink libraries under “Simulink Support Package for Raspberry Pi Hardware”. The two used blocks are “MQTT subscribe” and “MQTT publish”. The former subscribes to the topics “MPC/IN/OCC” and “MPC/IN/CO2” to get, respectively, the forecasted occupant’s number and CO2 measurements from the forecast model and the HOLSYS platform. The latter publishes the required flow rate into the “MPC/OUT” topic to control the ventilation speed. As shown in Figure 3b, the ventilation control node is wired to the inlet and outlet fans and controls them using PWM. In fact, the node receives the required flow rate from the platform through MQTT and transforms it to the corresponding PWM signal. The general architecture of the experimental setup from sensing till the control execution is illustrated in Figure 10.
The MPC controller, which is run from MATLAB/Simulink simulator, is emulated and embedded into the RPi as an independent hardware in the network.
However, Simulink is able to keep monitoring the simulation run time as well as the inputs and outputs of the MPC model. Using an MQTT publisher and subscriber tool, it is possible to inject test data into the model or monitor any variable from all over the experimental setup and its system entities.

5. Results and Discussions

In this section, the results obtained from the experimental setup of the different deployed systems are presented. In fact, after connecting everything together, the simulations have been run and data are collected during the experiment’s time. The experimentation started at 13:36 at the EEBLab test site. All the windows were closed and the only source of fresh air was the ventilation inlet. The HVAC was set to off. The weather station readings at the time were 23 °C for the ambient temperature and 56% for the relative humidity. The behavior of two employees at an office of 12 m2 was simulated. Other staff joined the team from time to time. While the occupants were performing moderate activities (e.g., using their personal computers and reading several articles while conversing), CO2 was changing its levels and increasing with more people inside the test site. At each new visit, the door was opened and closed in approximately 5 to 8 s. However, the influence of the door openings and the air exchanged during this time has not been taken into consideration. In fact, the objective behind the experimental setup is to show the usefulness of the proposed framework with all its components. It is a proof of concept of the intercommunication of different entities that form the entire concept. The idea is to integrate control strategies and modern technologies into a holistic framework for enabling real time monitoring and control of buildings’ systems.
First, advanced methods for forecasting indoor occupancy are implemented. Real occupancy data is sent to the server to be processed and exploited by the deployed forecasting model. It is implemented to read 10 instances and forecast 10 values ahead. The model gets new data every 1 min. It means that the model is able to forecast 10 min ahead. the forecasted occupancy data is sent to the MPC model to measure the flow rate needed to adjust optimal operation of the VS. The calculated accuracy and root mean square error (RMSE) parameters of the LSTM forecasting are respectively, 3.34% and 98.7%. Secondly, an MPC control strategy is integrated for VS’s control. All together, these systems have been inter-communicated via the deployed IoT platform. The simulation model of the MPC controller has been compiled via MATLAB/Simulink and embedded into the RPi 4 B+ installed into the test site. Afterwards, the installed sensors began to inject input data to the forecasting and MPC models and outputs (controls) were executed by the ventilators.
In order to assess the performance of the MPC against the ON/OFF, three metrics have been generated: (i) the regulation of indoor CO2 concentration, (ii) the ventilation flow rate evolution, and (iii) the instantaneous power consumption, which are calculated using the smart metering platform [26]. Experiments have been conducted using the above-mentioned set-up and the three metrics have been evaluated for the ON/OFF and MPC controllers during five hours and a half from 13:30 to 19:00. The occupants’ number together with the behavior of indoor CO2 concentration, ventilation flow rate, and power consumption of two controllers can be observed in Figure 11, Figure 12, Figure 13 and Figure 14.
As can be seen from Figure 11, the forecasted occupants’ number seems to be close and to correlate well with the collected real occupants’ number. A minor difference is seen at the peak points of the real occupancy.
The ON/OFF approach has been chosen for comparison as it is the most used control approach in VSs. It is a simple control mechanism which triggers full On or full Off in case of CO2 variation from the fixed setpoint. The ON/OFF control was deployed using the above-mentioned approach the next day.
In terms of CO2 regulation, both controllers provide good performance in maintaining the CO2 concentration with faster settling/rise responses for the ON/OFF to achieve and maintain the desired level, which is fixed to 550 PPM setpoint. Unlike the ON/OFF, the MPC was able to provide a better transient response to refresh the air inside the EEBLab using the optimal ventilation rate, as can be observed from Figure 12 and Figure 13.
For energy consumption, the obtained results presented in Figure 14, showed that the MPC outperforms the ON/OFF and allowed higher performance in improving energy savings. This performance can be explained by the predictive mechanism of the MPC, which includes the optimized criterion Δ u ^ that predict the effective ventilation flow rate according to the indoor CO2 dynamics, including the CO2 generated by occupants.
Regarding the total energy consumption of the VS during this experiment time period, the MPC outperformed the ON/OFF control and allowed a significant energy reduction by 16.44%. It can be noticed from Figure 14, that the peak energy consumed by the ventilators is reached only a few times by the MPC control unlike the ON/OFF method. The total energy consumed by MPC control is 119.4 Wh while the ON/OFF consumed a total of 142.88 Wh.

6. Conclusions and Perspectives

In this work, an HIL based framework was introduced for standalone VSs using MPC control method. The objective was to assess the effectiveness of the proposed framework in terms of indoor air quality improvement and energy efficiency in real-setting scenario. In fact, a Simulink based HIL model was proposed and implemented in the EEBLab to assess the effectiveness of MPC control. Contextual data are collected using the HOLSYS IoT platform and LSTM machine learning models have been integrated for real time occupants’ number forecasting. Resulting forecast data have been exploited by the MPC for optimal regulation of the ventilation flow rate. The performance of the MPC over the HIL framework has been assessed and compared to the ON/OFF strategy. Experimental results showed that both controllers provide acceptable performance in regulating the indoor CO2 concentration. However, the MPC allowed significant energy reduction by approximately 16% compared to ON/OFF.
As a perspective of this work, the framework will be applied and experimented for the HVAC system’s control using MPC. This latter has already been validated by simulations [66]. Furthermore, additional experiments will be conducted to shed more light on the integration of IoT and machine learning algorithms for setting up context-driven control approaches of different building services, including lighting, shading, and HVAC systems. Additionally, the perspective includes integrating the proposed framework for developing other buildings services, such as renewable energy production forecasting and predictive control of power systems [24].

Author Contributions

Conceptualization, A.K., A.B. and H.E.; methodology, A.K.; software, A.K., A.B. and H.E.; validation, A.K., A.B., H.E., S.B., M.B. and D.E.O.; formal analysis, A.K., A.B. and H.E.; investigation, M.B.; resources, M.B. and J.G.; data curation, A.K.; writing—original draft preparation, A.K., A.B., H.E. and S.B.; writing—review and editing, M.B., J.G. and D.E.O.; visualization, D.E.O.; supervision, M.B. and D.E.O.; project administration, M.B.; funding acquisition, M.B. and J.G. All authors have read and agreed to the published version of the manuscript.


This research was supported by IRESEN under the HOLSYS project (2020–2022), Green Inno-PROJECT-2018.

Institutional Review Board Statement

Not applicable.

Data Availability Statement

Not applicable.

Conflicts of Interest

The authors declare no conflict of interest. The funders had no role in the design of the study; in the collection, analyses, or interpretation of data; in the writing of the manuscript; or in the decision to publish the results.


  1. Nejat, P.; Jomehzadeh, F.; Taheri, M.M.; Gohari, M.; Majid, M.Z.A. A global review of energy consumption, CO2 emissions and policy in the residential sector (with an overview of the top ten CO2 emitting countries). Renew. Sustain. Energy Rev. 2015, 43, 843–862. [Google Scholar] [CrossRef]
  2. Del Mar Castilla, M.; Álvarez, J.D.; Normey-Rico, J.E.; Rodríguez, F.; Berenguel, M. A multivariable nonlinear MPC control strategy for thermal comfort and indoor-air quality. In Proceedings of the IECON 2013—39th Annual Conference of the IEEE Industrial Electronics Society, Vienna, Austria, 10–13 November 2013; pp. 7908–7913. [Google Scholar] [CrossRef]
  3. Addendum n to ANSI/ASHRAE Standard 62-2001, Ventilation for Acceptable Indoor Air Quality. Available online: (accessed on 25 September 2022).
  4. EN 13779:2007; Ventilation for non-Residential Buildings—Performance Requirements for Ventilation and room-Conditioning Systems. 2007. Available online: (accessed on 23 September 2022).
  5. Marzouk, M.; Atef, M. Assessment of Indoor Air Quality in Academic Buildings Using IoT and Deep Learning. Sustainability 2022, 14, 7015. [Google Scholar] [CrossRef]
  6. EN 15251:2007; Indoor Environmental Input Parameters for Design and Assessment of Energy Performance of Buildings Addressing Indoor Air Quality, Thermal Environment, Lighting and Acoustics. 2007. Available online: (accessed on 23 September 2022).
  7. Scislo, L.; Szczepanik-Scislo, N. Air Quality Sensor Data Collection and Analytics with IoT for an Apartment with Mechanical Ventilation. In Proceedings of the 2021 11th IEEE International Conference on Intelligent Data Acquisition and Advanced Computing Systems: Technology and Applications (IDAACS), Cracow, Poland, 22–25 September 2021; Volume 2, pp. 932–936. [Google Scholar] [CrossRef]
  8. Afram, A.; Janabi-Sharifi, F. Theory and applications of HVAC control systems—A review of model predictive control (MPC). Build. Environ. 2014, 72, 343–355. [Google Scholar] [CrossRef]
  9. Kukadia, V.; Palmer, J. The effect of external atmospheric pollution on indoor air quality: A pilot study. Energy Build. 1998, 27, 223–230. [Google Scholar] [CrossRef]
  10. Redlich, C.A.; Sparer, J.; Cullen, M.R. Sick-building syndrome. Lancet 1997, 349, 1013–1016. [Google Scholar] [CrossRef]
  11. Rueda, L.; Agbossou, K.; Cardenas, A.; Henao, N.; Kelouwani, S. A comprehensive review of approaches to building occupancy detection. Build. Environ. 2020, 180, 106966. [Google Scholar] [CrossRef]
  12. Tekler, Z.D.; Low, R.; Yuen, C.; Blessing, L. Plug-Mate: An IoT-based occupancy-driven plug load management system in smart buildings. Build. Environ. 2022, 223, 109472. [Google Scholar] [CrossRef]
  13. Zou, H.; Zhou, Y.; Jiang, H.; Chien, S.-C.; Xie, L.; Spanos, C.J. WinLight: A WiFi-based occupancy-driven lighting control system for smart building. Energy Build. 2018, 158, 924–938. [Google Scholar] [CrossRef]
  14. Balaji, B.; Xu, J.; Nwokafor, A.; Gupta, R.; Agarwal, Y. Sentinel: Occupancy based HVAC actuation using existing WiFi infrastructure within commercial buildings. In Proceedings of the 11th ACM Conference on Embedded Networked Sensor Systems, Roma, Italy, 11–15 November 2013; Association for Computing Machinery: New York, NY, USA, 2013; pp. 1–14. [Google Scholar] [CrossRef]
  15. Zanon, M.; Gros, S.; Bemporad, A. Practical Reinforcement Learning of Stabilizing Economic MPC. In Proceedings of the 2019 18th European Control Conference (ECC), Naples, Italy, 25–28 June 2019; pp. 2258–2263. [Google Scholar] [CrossRef] [Green Version]
  16. Huchuk, B.; Sanner, S.; O’Brien, W. Comparison of machine learning models for occupancy prediction in residential buildings using connected thermostat data. Build. Environ. 2019, 160, 106177. [Google Scholar] [CrossRef]
  17. Lohani, D.; Acharya, D. SmartVent: A Context Aware IoT System to Measure Indoor Air Quality and Ventilation Rate. In Proceedings of the 2016 17th IEEE International Conference on Mobile Data Management (MDM), Porto, Portugal, 13–16 June 2016; Volume 2, pp. 64–69. [Google Scholar] [CrossRef]
  18. Ma, Z.; Wang, S.; Xiao, F. Online performance evaluation of alternative control strategies for building cooling water systems prior to in situ implementation. Appl. Energy 2009, 86, 712–721. [Google Scholar] [CrossRef] [Green Version]
  19. Fathy, H.K.; Filipi, Z.S.; Hagena, J.; Stein, J.L. Review of hardware-in-the-loop simulation and its prospects in the automotive area. Proc. SPIE 2006, 6228, 117–136. [Google Scholar] [CrossRef]
  20. Crawley, D.B.; Hand, J.W.; Kummert, M.; Griffith, B.T. Contrasting the capabilities of building energy performance simulation programs. Build. Environ. 2008, 43, 661–673. [Google Scholar] [CrossRef] [Green Version]
  21. Wetter, M. Co-simulation of building energy and control systems with the Building Controls Virtual Test Bed. J. Build. Perform. Simul. 2011, 4, 185–203. [Google Scholar] [CrossRef] [Green Version]
  22. Huang, S.; Wang, W.; Brambley, M.R.; Goyal, S.; Zuo, W. An agent-based hardware-in-the-loop simulation framework for building controls. Energy Build. 2018, 181, 26–37. [Google Scholar] [CrossRef]
  23. Malek, Y.N.; Kharbouch, A.; Khoukhi, H.E.; Bakhouya, M.; Florio, V.D.; Ouadghiri, D.E.; Latre, S.; Blondia, C. On the use of IoT and Big Data Technologies for Real-time Monitoring and Data Processing. Procedia Comput. Sci. 2017, 113, 429–434. [Google Scholar] [CrossRef]
  24. Elmouatamid, A.; Ouladsine, R.; Bakhouya, M.; Elkamoun, N.; Zine-Dine, K.; Khaidar, M. MAPCAST: An Adaptive Control Approach using Predictive Analytics for Energy Balance in Micro-Grid Systems. Int. J. Renew. Energy Res. 2020, 10, 945–954. [Google Scholar]
  25. Bakhouya, M.; NaitMalek, Y.; Elmouatamid, A.; Lachhab, F.; Berouine, A.; Boulmrharj, S.; Ouladsine, R.; Felix, V.; Zinedine, K.; Khaidar, M.; et al. Towards a context-driven platform using IoT and big data technologies for energy efficient buildings. In Proceedings of the 2017 3rd International Conference of Cloud Computing Technologies and Applications (CloudTech), Rabat, Morocco, 24–26 October 2017; pp. 1–5. [Google Scholar] [CrossRef]
  26. Berouine, A.; Lachhab, F.; Malek, Y.N.; Bakhouya, M.; Ouladsine, R. A smart metering platform using big data and IoT technologies. In Proceedings of the 2017 3rd International Conference of Cloud Computing Technologies and Applications (CloudTech), Rabat, Morocco, 24–26 October 2017; pp. 1–6. [Google Scholar] [CrossRef]
  27. Berouine, A.; Akssas, E.; Naitmalek, Y.; Lachhab, F.; Bakhouya, M.; Ouladsine, R.; Essaaidi, M. A fuzzy logic-based approach for HVAC systems control. In Proceedings of the 2019 6th international conference on control, decision and information technologies (CoDIT), Paris, France, 23–26 April 2019; pp. 1510–1515. [Google Scholar]
  28. Berouine, A.; Ouladsine, R.; Bakhouya, M.; Lachhab, F.; Essaaidi, M. A Model Predictive Approach for Ventilation System Control in Energy Efficient Buildings. In Proceedings of the 2019 4th World Conference on Complex Systems (WCCS), Ouarzazate, Morocco, 22–25 April 2019; pp. 1–6. [Google Scholar] [CrossRef]
  29. Berouine, A.; Ouladsine, R.; Bakhouya, M.; Essaaidi, M. Towards a Real-Time Predictive Management Approach of Indoor Air Quality in Energy-Efficient Buildings. Energies 2020, 13, 3246. [Google Scholar] [CrossRef]
  30. Elkhoukhi, H.; NaitMalek, Y.; Berouine, A.; Bakhouya, M.; Elouadghiri, D.; Essaaidi, M. Towards a Real-time Occupancy Detection Approach for Smart Buildings. Procedia Comput. Sci. 2018, 134, 114–120. [Google Scholar] [CrossRef]
  31. Kharbouch, A.; Naitmalek, Y.; Elkhoukhi, H.; Bakhouya, M.; Florio, V.D.; Ouadghiri, M.D.E.; Latre, S.; Blondia, C. IoT and Big Data Technologies for Monitoring and Processing Real-Time Healthcare Data. IJDST 2019, 10, 17–30. [Google Scholar] [CrossRef]
  32. Nord, J.H.; Koohang, A.; Paliszkiewicz, J. The Internet of Things: Review and theoretical framework. Expert Syst. Appl. 2019, 133, 97–108. [Google Scholar] [CrossRef]
  33. Khan, N.S.; Ghani, S.; Haider, S. Real-Time Analysis of a Sensor’s Data for Automated Decision Making in an IoT-Based Smart Home. Sensors 2018, 18, 1711. [Google Scholar] [CrossRef] [PubMed] [Green Version]
  34. Behrooz, F.; Mariun, N.; Marhaban, M.H.; Mohd Radzi, M.A.; Ramli, A.R. Review of Control Techniques for HVAC Systems—Nonlinearity Approaches Based on Fuzzy Cognitive Maps. Energies 2018, 11, 495. [Google Scholar] [CrossRef] [Green Version]
  35. Godina, R.; Rodrigues, E.M.G.; Pouresmaeil, E.; Matias, J.C.O.; Catalão, J.P.S. Model Predictive Control Home Energy Management and Optimization Strategy with Demand Response. Appl. Sci. 2018, 8, 408. [Google Scholar] [CrossRef]
  36. Prívara, S.; Široký, J.; Ferkl, L.; Cigler, J. Model predictive control of a building heating system: The first experience. Energy Build. 2011, 43, 564–572. [Google Scholar] [CrossRef]
  37. Yuan, S.; Perez, R. Multiple-zone ventilation and temperature control of a single-duct VAV system using model predictive strategy. Energy Build. 2006, 38, 1248–1261. [Google Scholar] [CrossRef]
  38. Ellis, G. Chapter 13—Model Development and Verification. In Control System Design Guide, 4th ed.; Ellis, G., Ed.; Butterworth-Heinemann: Boston, MA, USA, 2012; pp. 261–282. ISBN 978-0-12-385920-4. [Google Scholar]
  39. Bacic, M. On hardware-in-the-loop simulation. In Proceedings of the 44th IEEE Conference on Decision and Control, Seville, Spain, 15 December 2005; pp. 3194–3198. [Google Scholar] [CrossRef]
  40. HIL SimulationOPAL-RT. OPAL-RT. 2022. Available online: (accessed on 10 October 2022).
  41. Missaoui, R.; Warkozek, G.; Bacha, S.; Ploix, S. Real time validation of an optimization Building Energy Management strategy based on Power-Hardware-in-the-loop tool. In Proceedings of the 2012 3rd IEEE PES Innovative Smart Grid Technologies Europe (ISGT Europe), Berlin, Germany, 14–17 October 2012; pp. 1–7. [Google Scholar] [CrossRef]
  42. Schneider, G.F.; Oppermann, J.; Constantin, A.; Streblow, R.; Müller, D. Hardware-in-the-Loop-Simulation of a Building Energy and Control System to Investigate Circulating Pump Control Using Modelica. In Proceedings of the 11th International Modelica Conference, Versailles, France, 21–23 September 2015; Available online: (accessed on 25 September 2022).
  43. Tejeda De La Cruz, A.; Riviere, P.; Marchio, D.; Cauret, O.; Milu, A. Hardware in the loop test bench using Modelica: A platform to test and improve the control of heating systems. Appl. Energy 2017, 188, 107–120. [Google Scholar] [CrossRef]
  44. Seifried, S.; Preyser, F.J.; Kastner, W. Enabling hardware-in-the-loop for building automation networks: A case study for BACnet and PowerDEVS. In Proceedings of the IECON 2017—43rd Annual Conference of the IEEE Industrial Electronics Society, Beijing, China, 29 October 2017–1 November 2017; pp. 8119–8125. [Google Scholar] [CrossRef]
  45. Taha, Z.; Deboucha, A.; Kinsheel, A.; Ghazilla, R.A.B.R. Development of Real-Time Hardware in the Loop Based MPC for Small-Scale Helicopter. In Frontiers of Model Predictive Control; IntechOpen: London, UK, 2012; Available online: (accessed on 10 October 2022).
  46. Sámano-Ortega, V.; Méndez-Guzmán, H.M.-G.; Padilla-Medina, J.; Aguilera-álvarez, J.; Martínez-Nolasco, C.; Martínez-Nolasco, J. Control Hardware in the Loop and IoT Integration: A Testbed for Residential Photovoltaic System Evaluation. IEEE Access 2022, 10, 71814–71829. [Google Scholar] [CrossRef]
  47. Conti, P.; Bartoli, C.; Franco, A.; Testi, D. Experimental Analysis of an Air Heat Pump for Heating Service Using a “Hardware-In-The-Loop” System. Energies 2020, 13, 4498. [Google Scholar] [CrossRef]
  48. Frison, L.; Kleinstück, M.; Engelmann, P. Model-predictive control for testing energy flexible heat pump operation within a Hardware-in-the-Loop setting. J. Phys. Conf. Ser. 2019, 1343, 012068. [Google Scholar] [CrossRef]
  49. Apache Storm. Available online: (accessed on 25 September 2022).
  50. Wen, J.T.; Mishra, S. (Eds.) Intelligent Building Control Systems; Advances in Industrial Control; Springer International Publishing: Cham, Switzerland, 2018; ISBN 978-3-319-68461-1. [Google Scholar]
  51. Serale, G.; Fiorentini, M.; Capozzoli, A.; Bernardini, D.; Bemporad, A. Model Predictive Control (MPC) for Enhancing Building and HVAC System Energy Efficiency: Problem Formulation, Applications and Opportunities. Energies 2018, 11, 631. [Google Scholar] [CrossRef]
  52. Jeon, Y.; Cho, C.; Seo, J.; Kwon, K.; Park, H.; Oh, S.; Chung, I.-J. IoT-based occupancy detection system in indoor residential environments. Build. Environ. 2018, 132, 181–204. [Google Scholar] [CrossRef]
  53. Zantalis, F.; Koulouras, G.; Karabetsos, S.; Kandris, D. A Review of Machine Learning and IoT in Smart Transportation. Future Internet 2019, 11, 94. [Google Scholar] [CrossRef] [Green Version]
  54. Ghasempour, A. Internet of Things in Smart Grid: Architecture, Applications, Services, Key Technologies, and Challenges. Inventions 2019, 4, 22. [Google Scholar] [CrossRef] [Green Version]
  55. Elmouatamid, A.; NaitMalek, Y.; Bakhouya, M.; Ouladsine, R.; Elkamoun, N.; Zine-Dine, K.; Khaidar, M. An energy management platform for micro-grid systems using Internet of Things and Big-data technologies. Proc. Inst. Mech. Eng. Part I J. Syst. Control Eng. 2019, 233, 904–917. [Google Scholar] [CrossRef]
  56. Alaa, M.; Zaidan, A.A.; Zaidan, B.B.; Talal, M.; Kiah, M.L.M. A review of smart home applications based on Internet of Things. J. Netw. Comput. Appl. 2017, 97, 48–65. [Google Scholar] [CrossRef]
  57. Zhang, W.; Wu, Y.; Calautit, J.K. A review on occupancy prediction through machine learning for enhancing energy efficiency, air quality and thermal comfort in the built environment. Renew. Sustain. Energy Rev. 2022, 167, 112704. [Google Scholar] [CrossRef]
  58. Elkhoukhi, H.; Bakhouya, M.; El Ouadghiri, D.; Hanifi, M. Using Stream Data Processing for Real-Time Occupancy Detection in Smart Buildings. Sensors 2022, 22, 2371. [Google Scholar] [CrossRef]
  59. Elkhoukhi, H.; NaitMalek, Y.; Bakhouya, M.; Berouine, A.; Kharbouch, A.; Lachhab, F.; Hanifi, M.; El Ouadghiri, D.; Essaaidi, M. A platform architecture for occupancy detection using stream processing and machine learning approaches. Concurr. Comput. Pract. Exp. 2020, 32, e5651. [Google Scholar] [CrossRef]
  60. Jin, Y.; Yan, D.; Zhang, X.; An, J.; Han, M. A data-driven model predictive control for lighting system based on historical occupancy in an office building: Methodology development. Build. Simul. 2021, 14, 219–235. [Google Scholar] [CrossRef]
  61. Esrafilian-Najafabadi, M.; Haghighat, F. Occupancy-based HVAC control systems in buildings: A state-of-the-art review. Build. Environ. 2021, 197, 107810. [Google Scholar] [CrossRef]
  62. Depatla, S.; Muralidharan, A.; Mostofi, Y. Occupancy Estimation Using Only WiFi Power Measurements. IEEE J. Sel. Areas Commun. 2015, 33, 1381–1393. [Google Scholar] [CrossRef]
  63. Tekler, Z.D.; Low, R.; Gunay, B.; Andersen, R.K.; Blessing, L. A scalable Bluetooth Low Energy approach to identify occupancy patterns and profiles in office spaces. Build. Environ. 2020, 171, 106681. [Google Scholar] [CrossRef]
  64. Hahnel, D.; Burgard, W.; Fox, D.; Fishkin, K.; Philipose, M. Mapping and localization with RFID technology. In Proceedings of the IEEE International Conference on Robotics and Automation, 2004. Proceedings. ICRA ’04. 2004, New Orleans, LA, USA, 26 April 2004–1 May 2004; Volume 1, pp. 1015–1020. [Google Scholar] [CrossRef]
  65. Elkhoukhi, H.; Bakhouya, M.; Hanifi, M.; El Ouadghiri, D. On the use of Deep Learning Approaches for Occupancy prediction in Energy Efficient Buildings. In Proceedings of the 2019 7th International Renewable and Sustainable Energy Conference (IRSEC), Agadir, Morocco, 27–30 November 2019; pp. 1–6. [Google Scholar] [CrossRef]
  66. Berouine, A.; Ouladsine, R.; Bakhouya, M.; Essaaidi, M. A predictive control approach for thermal energy management in buildings. Energy Rep. 2022, 8, 9127–9141. [Google Scholar] [CrossRef]
Figure 1. (a) Energy Efficient Building Lab (EEBLab) test site; (b) Interior side wall of EEBLab with ventilation fan and a set of sensors and other equipment.
Figure 1. (a) Energy Efficient Building Lab (EEBLab) test site; (b) Interior side wall of EEBLab with ventilation fan and a set of sensors and other equipment.
Sensors 22 07978 g001
Figure 2. General architecture of an Internet of Things platform.
Figure 2. General architecture of an Internet of Things platform.
Sensors 22 07978 g002
Figure 3. The deployed IoT devices; (a) Indoor CO2, temperature and humidity node; (b) Inlet and outlet ventilator speed control node; (c) Weather station node for outdoor air quality; (d) Occupants’ number node.
Figure 3. The deployed IoT devices; (a) Indoor CO2, temperature and humidity node; (b) Inlet and outlet ventilator speed control node; (c) Weather station node for outdoor air quality; (d) Occupants’ number node.
Sensors 22 07978 g003
Figure 4. Data transfer from IoT nodes to the HOLSYS platform via RPi gateways over MQTT and HTTP.
Figure 4. Data transfer from IoT nodes to the HOLSYS platform via RPi gateways over MQTT and HTTP.
Sensors 22 07978 g004
Figure 5. MQTT stream data flow from/to sensor/actuator/controller.
Figure 5. MQTT stream data flow from/to sensor/actuator/controller.
Sensors 22 07978 g005
Figure 6. General architecture platform for controlling ventilation system based on occupancy forecast and CO2 measurement.
Figure 6. General architecture platform for controlling ventilation system based on occupancy forecast and CO2 measurement.
Sensors 22 07978 g006
Figure 7. Occupants’ numbers over the day in EEBLab.
Figure 7. Occupants’ numbers over the day in EEBLab.
Sensors 22 07978 g007
Figure 8. The general structure of the MPC framework for the EEBLab ventilation control system.
Figure 8. The general structure of the MPC framework for the EEBLab ventilation control system.
Sensors 22 07978 g008
Figure 9. MATLAB/Simulink model for ventilation system’s control using MPC.
Figure 9. MATLAB/Simulink model for ventilation system’s control using MPC.
Sensors 22 07978 g009
Figure 10. The experimental setup architecture of HIL implementation of the MPC for EEBLab ventilation system control enabled by the HOLSYS IoT platform.
Figure 10. The experimental setup architecture of HIL implementation of the MPC for EEBLab ventilation system control enabled by the HOLSYS IoT platform.
Sensors 22 07978 g010
Figure 11. Occupancy forecasting results using LSTM.
Figure 11. Occupancy forecasting results using LSTM.
Sensors 22 07978 g011
Figure 12. The MPC flow rate output together with the CO2 concentration variation.
Figure 12. The MPC flow rate output together with the CO2 concentration variation.
Sensors 22 07978 g012
Figure 13. The ON/OFF flow rate output together with the CO2 concentration variation.
Figure 13. The ON/OFF flow rate output together with the CO2 concentration variation.
Sensors 22 07978 g013
Figure 14. Energy consumption variation of the ventilation system during control for both ON/OFF and MPC controllers.
Figure 14. Energy consumption variation of the ventilation system during control for both ON/OFF and MPC controllers.
Sensors 22 07978 g014
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Share and Cite

MDPI and ACS Style

Kharbouch, A.; Berouine, A.; Elkhoukhi, H.; Berrabah, S.; Bakhouya, M.; El Ouadghiri, D.; Gaber, J. Internet-of-Things Based Hardware-in-the-Loop Framework for Model-Predictive-Control of Smart Building Ventilation. Sensors 2022, 22, 7978.

AMA Style

Kharbouch A, Berouine A, Elkhoukhi H, Berrabah S, Bakhouya M, El Ouadghiri D, Gaber J. Internet-of-Things Based Hardware-in-the-Loop Framework for Model-Predictive-Control of Smart Building Ventilation. Sensors. 2022; 22(20):7978.

Chicago/Turabian Style

Kharbouch, Abdelhak, Anass Berouine, Hamza Elkhoukhi, Soukayna Berrabah, Mohamed Bakhouya, Driss El Ouadghiri, and Jaafar Gaber. 2022. "Internet-of-Things Based Hardware-in-the-Loop Framework for Model-Predictive-Control of Smart Building Ventilation" Sensors 22, no. 20: 7978.

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop