AI and IoT-Based Prediction and Optimization for Energy Efficiency in Campus Buildings
Abstract:
The increasing energy demand in buildings and global warming issues have become a critical challenge that needs to be addressed. An energy management system (EMS) aims to manage energy efficiency and reduce environmental impact. This paper proposes the implementation of an EMS in a campus building by integrating artificial intelligence (AI) and Internet of Things (IoT) technology for prediction and energy optimization. A long short-term memory (LSTM) network is employed to predict the room environment conditions, including the concentration of carbon dioxide (CO$_2$), room temperature and humidity, outdoor temperature and humidity, and room occupancy. A genetic algorithm (GA)-based optimization method is employed to minimize energy consumption while maintaining user comfort by adjusting the room set-point temperature. The IoT-based monitoring system is used to monitor environmental parameters and power consumption in the room. The experimental results show that the proposed LSTM-based prediction achieves a low root mean square error of 50.69 ppm, 0.77°C, 1.08°C, 3.50%, 6.27% for the CO$_2$, room and outdoor temperature, room and outdoor humidity, respectively; and a high Accuracy of 0.93 for room occupancy. Additionally, machine learning techniques are proposed for occupancy modeling with high Accuracy of 0.98 and F1 score of 0.97. Furthermore, the algorithm is tested on an embedded device with a fast execution time (below two minutes), making it suitable for real-time implementation of the application.
1. Introduction
In most countries, building energy consumption accounts for 40% of the total national energy consumption [1]. Therefore, improving building energy efficiency is essential, particularly in addressing issues such as global warming and the energy crisis. Campus buildings consume 45% more energy than residential buildings [1]. The energy consumption reduction in campus buildings by the passive building construction strategies was studied by Al-Hadeethi and Hacham [2]. Campus buildings have different occupancy patterns compared to other buildings, as these are affected by teaching and research activities that are not strictly regular, as in offices or industries [3].
Campus building energy management based on occupancy is a challenging and interesting research topic. Motion detection and room management systems reduced daily electricity usage by 77.6%, 32.4%, 28.2%, and 27.9% in underground parking lots, lecture rooms, dormitory rooms, and air conditioning (AC) units, respectively [4]. An occupancy sensor was used to control heating, ventilation, and air conditioning (HVAC) scheduling in an academic office building, which reduced energy usage by 20% [5]. Efficient dual-passive infrared (PIR) sensors have been employed to detect occupancy in classrooms for smart lighting and control [6]. An occupancy model based on embedded devices was proposed by Soetedjo and Sotyohadi [7] for the real-time simulation of occupancy-based energy consumption in a campus building. The occupants’ awareness of energy efficiency in a campus building was studied by Prafitasiwi et al. [8], where the first, second, and third highest awareness performances were achieved by the lecturer, staff, and students, respectively.
Artificial intelligence (AI) techniques are typically used to address various problems in energy management systems (EMSs) [9]. A reinforcement learning algorithm was adopted by Friansa et al. [10] to control a flexible load (HVAC) in a university building. Deep-learning-based algorithms have also been used to predict the energy consumption and demand of university buildings [11]. The temperature, humidity, solar irradiation, and wind speed were used as parameters to predict energy consumption using a moving average and artificial neural networks (ANNs) [12]. The reactive energy consumption of the buildings was predicted using long short-term memory (LSTM), gated recurrent unit (GRU), and recurrent neural network (RNN) [13].
Owing to the rapid development of Internet of Things (IoT) technology, the integration of EMS and IoT has become a standard approach. The adoption of IoT technology in an EMS may reduce energy consumption by 30% and operational costs by 20% [14]. The integration of IoT and AI in an EMS offers both economic and environmental benefits [15]. An IoT-based photovoltaic (PV) power-monitoring system was developed by Rao et al. [16], which provided two-way control and monitoring for effective energy management. IoT sensors and clouds were adopted for HVAC energy management in a campus building [17]. An IoT platform integrated with machine learning was used to reduce the energy consumption of a building with legacy equipment, such as HVAC and water boilers [18]. The IoT platform has been employed to monitor and control several applications on university campuses, such as temperature, humidity, occupancy, carbon dioxide (CO$_2$) concentration, energy efficiency of HVAC and water heaters, PV, and grid energy monitoring [19]. A low-cost and secure IoT network was employed for occupancy monitoring in a university room to optimize HVAC usage [20].
As previously discussed, the integration of AI and IoT into an EMS is a promising approach. Most existing studies used a simulation or hardware testbed to evaluate their proposed approaches. Simulations are typically utilized owing to their ease of implementation, particularly for complex problems. However, they do not reflect real-time scenarios. In contrast, a hardware testbed enables a better evaluation of real-time implementation, even though evaluating complex scenarios is difficult.
Several studies have addressed the real-time implementation and evaluation of EMSs, such as energy consumption prediction [18] and intelligent monitoring [19], [20]. However, they do not integrate both prediction and optimization in a real-time EMS platform. The lack of such integration leads to the inability of the algorithm to adapt the dynamic environmental changes.
To bridge this gap, this paper proposes the integration of AI and IoT-based EMS that performs real-time prediction and optimization for energy efficiency monitoring in campus buildings. Compared with existing works, the proposed work addresses the real-time implementation of both prediction and optimization methods. Furthermore, it extends the work by Soetedjo et al. [21] by introducing energy optimization for a typical campus building powered by an electricity grid only (without PV) and by incorporating environmental parameter prediction.
The remainder of this paper is organized as follows. Section 2 presents the literature review. Section 3 describes the methodology used in the study. Section 4 discusses the results. Finally, Section 5 presents our conclusions.
2. Literature Review
An experimental testbed of the campus building EMS was implemented on the embedded platform [21]. It adopted the LSTM technique for PV power prediction and the GA-based optimization technique for energy optimization. Both LSTM and GA algorithms were implemented using Python programming on a Raspberry Pi 5 embedded module for real-time prediction and optimization. The GA-based optimization was employed to optimize the set-point temperature of AC, where the objective is to minimize energy usage while maintaining user comfort. The experimental results showed that the occupancy and temperature control reduced power consumption in a campus building by 40.29%, whereas occupancy without temperature control was reduced by 32.76%.
An optimization technique utilizing deep learning was employed to maximize user comfort (temperature, illumination, and air quality) while minimizing energy consumption [22]. The user's comfort is maximized when the optimal values of temperature, illumination, and air quality are equal to their respective desired values. Meanwhile, the energy consumption was correlated with the difference between the actual environmental parameters and their respective desired values. The optimization algorithm was implemented using MATLAB software.
A method that utilizes the LSTM algorithm has been used to predict energy consumption based on occupancy and meteorological data (outdoor temperature, relative humidity, and solar radiation) [23]. The simulation results showed that the prediction accuracy increased by 7% when the occupancy was taken into account.
A fog-based building EMS was proposed by Na and Lee [24], in which the fog layer was divided according to location: campus, building, and zone fogs. The zone fog manages the IoT devices. This architecture addresses the limitations of cloud-based systems when dealing with an increasing number of IoT devices. The testbed consisted of seven fogs: one campus fog implemented on a desktop PC, one building fog running on a computer equipped with a small screen display, and five zone fogs implemented on the Raspberry Pi. The zone fog interacts with end devices, including smart lights, smart plugs, and thermostats. The work focused on the feasibility of the collaboration between fog nodes and the service provision.
A building energy consumption monitoring system based on edge computing was proposed by Romero et al. [25]. It adopted open-source IoT technologies for both hardware and software implementation. The architecture of the energy monitoring system was divided into three levels: cloud, edge, and device. The cloud level enabled reporting and remote access to the dashboard via the internet. The edge level was utilized for visualization purposes through the Node-RED program, for hosting the Message Queuing Telemetry Transport (MQTT) broker using the Mosquitto Eclipse broker, and for data storage via a SQLite database. The device level handled the data collection of the electrical parameters. It supports various open-source hardware platforms, such as Raspberry Pi, Arduino, ESP32, and Particle Photon.
Back-end and front-end systems for energy consumption monitoring in lectures, offices, and laboratory rooms were implemented using a cost-effective IoT platform [26]. The front-end system enables user interface interaction, data visualization, and data analysis. The system architecture consisted of four layers: power, data acquisition, communication network, and application. The power layer consisted of power generation (grid and PV), battery, and loads (HVAC, lighting, and vehicle charging stations). The data acquisition layer was used to measure and collect data from the power layer, including smart plugs, smart meters, air quality sensors, and weather sensors. The communication layer received data from the data acquisition layer and forwarded it to the application layer. It utilized various communication technologies, including WiFi, Bluetooth, ZigBee, and LoRa, along with communication protocols such as MQTT, CoAP, and WebSocket. The application layer was used to store and visualize the data. It adopted the cloud service and Node-RED programming.
The main contributions of the proposed work are summarized as follows:
(1) Integration of prediction and optimization: It integrates environmental parameter prediction using the LSTM network with the GA-based optimization strategy for energy efficiency in a campus building.
(2) IoT-based SCADA implementation: It employs an IoT-based supervisory control and data acquisition (SCADA) system to monitor and collect the environmental parameters and power consumption of campus buildings.
(3) Occupancy-driven modeling: It proposes an occupancy model using machine learning techniques based on IoT data.
(4) Embedded system deployment: The proposed algorithms are implemented on an embedded device for a real-time evaluation.
3. Methodology
The system architecture is illustrated in Figure 1. It consists of human–machine interface (HMI) SCADA devices, a prediction and optimization unit, sensor modules, and communication networks. In this study, five rooms in the campus building of the Department of Electrical Engineering at the National Institute of Technology (ITN) Malang were considered. The rooms included a lecturer’s room, a laboratory room, an administration room, a meeting room, and a lecture room. Each room was equipped with occupancy, temperature, humidity, CO$_2$, and load-power sensors. In addition, outdoor temperature and humidity sensors were installed.

The HMI SCADA device is the main unit of the SCADA system. It operates as a data server and provides a user-friendly graphical interface. In this work, because an IoT-based HMI SCADA is used, it can be accessed remotely via the Internet. Three HMI SCADA devices are used: HMI SCADA-1 for communicating with the load power sensors in the lecturer and laboratory rooms; HMI SCADA-2 for communicating with the load power sensor in the administration, meeting, and lecture rooms; and HMI SCADA-3 for communicating with the occupancy, temperature, humidity, and CO$_2$ sensors in all rooms.
As shown in Figure 1, three different wireless communication protocols were adopted: WiFi (blue), LoRa (orange), and ZigBee (green). This selection was based on the location of the sensors and HMI SCADA. For example, because the distance between the lecturer and laboratory rooms to the HMI SCADA is short, Wi-Fi communication was adopted. ZigBee was adopted for a medium distance (administration room). Meanwhile, LoRa communication was adopted for long-distance communication (lecture and meeting rooms).
A Raspberry Pi-embedded device was used as the central unit of the EMS to implement prediction and optimization tasks. It was connected with the HMI SCADA devices to exchange data. Owing to its small size and limited resources, Raspberry Pi is suitable for installation in campus buildings for actual implementation without requiring a special computer server room.
Figure 2 and Figure 3 show the configuration of the lamp and outlet power monitoring system in the lecturer and laboratory rooms and the administration, meeting, and lecture rooms, respectively. As shown in the figures, the lights are controlled by a programmable logic controller (PLC) that communicates with the HMI SCADA via LoRa communication. The lamp and outlet power sensors were used to measure their respective powers and send the data to the HMI SCADA via LoRa communication. Notably, since the outlet power panel of the laboratory room is located in the same panel as the HMI SCADA-1, the RS485 communication interface was employed.


The configuration of the room environmental parameter monitoring system in the lecturer, administration, and lecture rooms is shown in Figure 4. The figure shows that there are four sensors in each room: A temperature and humidity sensor, a CO$_2$ sensor, a low-resolution (8 $\times$ 8 pixels) thermal camera sensor, and a PIR sensor. Because of the different placements in a room, the temperature, humidity, and CO$_2$ sensors were installed separately from the thermal camera and PIR sensors, where two ESP32 microcontrollers were required for processing the data from the sensors and sending it to the HMI SCADA. As described previously, three communication protocols were adopted: WiFi, LoRa, and ZigBee.

In addition to the PIR sensor, which is sensitive to noise, a low-resolution thermal camera sensor (AMG8883) was employed to detect the presence of humans in the room. The thermal camera consists of an 8 $\times$ 8 array of thermal sensors. The thermal camera sensor was equipped with an I$_2$C interface, which was easily interfaced with the ESP32 microcontroller. In the current experiment, for simplicity, occupancy (human presence) was detected by calculating the deviation of the values of the 64 pixels, where a high deviation represents a high probability of human presence. Occupancy detection was modeled using machine learning techniques, as described in the next section.
Figure 5 shows a block diagram of the occupancy model. It has four inputs, namely, thermal camera, room temperature, room humidity, and room CO$_2$, and one output, occupancy. A machine learning technique was used to predict the occupancy. Because occupancy is a binary value (on/off), prediction is a classification task.

In this study, five popular machine learning techniques were evaluated: ANN, decision tree (DT), k-nearest neighbors (k-NN), random forest (RF), and extreme gradient boosting (XGB). To evaluate the classification performance of the machine learning techniques, four metrics were used: Accuracy, Precision, Recall, and F1 score [27], which are expressed in Eqs. (1) to (4).
where, $TP$, $TN$, $FP$, and $FN$ indicate true positive, true negative, false positive, and false negative results, respectively.
The machine learning techniques were implemented using Python programming with the following machine learning libraries: scikit-learn [28] and XGBoost [29]. To evaluate the real-time application, the algorithm was implemented on a Raspberry Pi 5-embedded device.
Figure 6 shows a block diagram of the room’s environmental parameters and occupancy prediction. It includes six inputs: room temperature, room humidity, room CO$_2$ concentration, outdoor temperature, outdoor humidity, and occupancy. These parameters represent historical data from the previous 24 h. Based on these historical data, the LSTM predicted these six parameters for the next 10 min.

The reasons for incorporating the prediction and optimization techniques are explained as follows. Suppose that at time $T$, the optimization algorithm is computed to optimize the room set-point temperature based on the room and outdoor temperatures at time $T$. However, owing to the time response of the AC, the set-point temperature is reached at time $T$ + $\Delta T$, during which the environmental parameters may change from the previous parameters. This suggests that the optimization algorithm can use the predicted data at time $T$ + $\Delta T$ for more accurate optimization instead of using the obtained data at time $T$.
The LSTM was implemented on a Raspberry Pi 5-embedded system, which is suitable for actual applications in buildings. The algorithm was written using Python programming and the TensorFlow platform [30]. To evaluate the prediction performance, the root mean squared error (RMSE) [13], expressed in Eq. (5), was calculated.
where, $y$, $\hat{y}_i$, $n$, represent the actual value, predicted value, and number of samples.
The objective of the optimization is to maximize user temperature comfort while minimizing energy consumption. The optimization task was performed using the objective functions expressed in Eqs. (6) to (13), which is inspired by Verma et al. [22].
Subject to constraints
where, $TLC_{ref}$, $TLB_{ref}$, $TAD_{ref}$, $TMT_{ref}$, and $TCL_{ref}$ are the reference/desired temperatures in the lecturer, laboratory, administration, meeting, and lecture rooms, respectively; $TLC_{opt}$, $TLB_{opt}$, $TAD_{opt}$, $TMT_{opt}$, and $TCL_{opt}$ are the optimal temperatures in the lecturer, laboratory, administration, meeting, and lecture rooms, respectively; and $TLC_{out}$, $TLB_{out}$, $TAD_{out}$, $TMT_{out}$, and $TCL_{out}$ are the outdoor temperatures in the lecturer, laboratory, administration, meeting, and lecture rooms, respectively. Notably, the optimal temperature is the set-point temperature needed to operate the AC in each room, while the reference temperature is the desired temperature set by the user; in this work, it is set to 25°C.
Eq. (7) expresses the difference between the reference/desired temperature and optimal temperature in all rooms. This represents the objective of maximizing user temperature comfort, which is achieved by minimizing this difference. Eq. (8) expresses the difference between the outdoor and optimal temperatures in all the rooms. This represents the objective of minimizing energy consumption; because the AC power is affected by this difference, the AC power is minimized by minimizing this difference. The objective function in Eq. (6) minimizes both the components by introducing a weighting factor. In this work, weights of 0.2 and 0.8 were assigned to user comfort and energy consumption, respectively. Notably, the weights can be selected according to user preference.
4. Results and Discussion
The dataset for evaluating the occupancy model was collected using an IoT-based SCADA monitoring system, as described in the previous section. The data is collected from the lecturer, laboratory, administration, meeting, and lecture rooms from 17/07/2025 to 08/08/2025 at 1-minute intervals. A description of the dataset is presented in Table 1.
Room | Collection Time | Number of Data Point | Data Feature |
|---|---|---|---|
Lecturer room | 17/07/2025–08/08/2025 | 31,812 | Thermal camera, Room temperature, Room humidity, Room CO$_2$, Occupancy |
Laboratory room | 17/07/2025–08/08/2025 | 31,812 | |
Administration room | 25/07/2025–08/08/2025 | 20,424 | |
Meeting room | 17/07/2025–08/08/2025 | 31,812 | |
Lecture room | 28/07/2025–08/08/2025 | 15,776 |
The dataset for each room listed in Table 1 contains environmental parameters, such as temperature, humidity, CO$_2$ concentration, and thermal camera data, along with corresponding occupancy labels. Due to the different installation times of the instruments, the collection periods for the lecturer, laboratory, and meeting rooms commence on July 17, 2025. In contrast, the administration and lecture rooms start on July 25, 2025, and July 28, 2025, respectively. To ensure the data quality and consistency, the data pre-processing is conducted. It involves removing missing or corrupted data and outliers caused by sensor drift, communication errors, or failed data acquisition modules.
Table 2 lists the parameters used by the machine learning techniques in the occupancy model. Machine learning uses 80% of the datasets listed in Table 1 for training and 20% for testing. The evaluation results of the occupancy models in the lecturer, laboratory, administration, meeting, and lecture rooms using the five machine learning techniques are presented in Table 3, Table 4, Table 5, Table 6, and Table 7.
Machine Learning Technique | Parameter |
|---|---|
ANN | No. of hidden layers = 2; No. of neurons = 32 (each hidden layer); Activation function = “Relu”; Optimizer = “Adam”; No. of epochs = 100 |
DT | Split criterion = “squared error”; Max. depth = 20; |
KNN | No. of neighbors = 5; Metric = “minkowski” |
RF | No. of estimators = 150; Split criterion = "gini” |
XGB | Learning objective = “squared error”; No. of estimators = 100; Learning rate = 0.1; Max. depth = 5 |
Metric | Machine Learning Technique | ||||
|---|---|---|---|---|---|
ANN | DT | k-NN | RF | XGB | |
Accuracy | 0.91 | 0.94 | 0.96 | 0.98 | 0.95 |
Precision | 0.74 | 0.82 | 0.88 | 0.93 | 0.85 |
Recall | 0.51 | 0.71 | 0.88 | 0.91 | 0.79 |
F1 score | 0.61 | 0.77 | 0.88 | 0.92 | 0.82 |
Execution time (ms) | 348.2 | 0.9 | 107.1 | 109.3 | 9.7 |
Metric | ANN | DT | k-NN | RF | XGB |
|---|---|---|---|---|---|
Accuracy | 0.92 | 0.96 | 0.96 | 0.98 | 0.97 |
Precision | 0.80 | 0.93 | 0.89 | 0.96 | 0.94 |
Recall | 0.68 | 0.80 | 0.85 | 0.92 | 0.86 |
F1 score | 0.74 | 0.86 | 0.87 | 0.94 | 0.90 |
Execution time (ms) | 344.4 | 0.9 | 49.6 | 101.0 | 9.4 |
Metric | ANN | DT | k-NN | RF | XGB |
|---|---|---|---|---|---|
Accuracy | 0.916 | 0.949 | 0.964 | 0.974 | 0.965 |
Precision | 0.82 | 0.89 | 0.94 | 0.96 | 0.93 |
Recall | 0.74 | 0.85 | 0.90 | 0.91 | 0.90 |
F1 score | 0.78 | 0.87 | 0.92 | 0.93 | 0.92 |
Execution time (ms) | 269.3 | 0.9 | 43.5 | 65.6 | 7.2 |
Metric | ANN | DT | k-NN | RF | XGB |
|---|---|---|---|---|---|
Accuracy | 0.92 | 0.97 | 0.98 | 0.98 | 0.98 |
Precision | 0.81 | 0.96 | 0.96 | 0.97 | 0.95 |
Recall | 0.79 | 0.93 | 0.95 | 0.96 | 0.94 |
F1 score | 0.80 | 0.94 | 0.95 | 0.97 | 0.94 |
Execution time (ms) | 350.0 | 0.9 | 56.7 | 96.9 | 9.7 |
Metric | ANN | DT | k-NN | RF | XGB |
|---|---|---|---|---|---|
Accuracy | 0.95 | 0.96 | 0.98 | 0.98 | 0.98 |
Precision | 0.83 | 0.90 | 0.89 | 0.94 | 0.93 |
Recall | 0.46 | 0.56 | 0.86 | 0.87 | 0.79 |
F1 score | 0.59 | 0.70 | 0.87 | 0.90 | 0.85 |
Execution time (ms) | 233.1 | 0.5 | 27.7 | 50.7 | 5.7 |
Table 3, Table 4, Table 5, Table 6, and Table 7 show that RF exhibited the best performance for all rooms; that is, it achieved the highest Accuracy, Precision, Recall, and F1 scores. The ANN achieved high Accuracy and Precision but low Recall and F1 scores. k-NN and XGB also exhibited good performance, which was slightly lower than that of RF. By observing each room, five machine learning models were determined to exhibit high performance in the administration and meeting rooms. Considering the performance and execution time, RF was the best model, with an average F1 score of 0.98 and an average execution time of 84.7 ms, which is sufficiently fast for this application.
The datasets used for the evaluation of room environmental parameters and occupancy prediction are similar to the ones given in Table 1. However, the features used in the prediction are room CO$_2$, room temperature, room humidity, outdoor temperature, outdoor humidity, and occupancy. Prior to processing the dataset, the data pre-processing, similar to the previous occupancy modeling, is also performed. Additionally, since the prediction uses a 10-minute time interval, the datasets are resampled accordingly. The LSTM parameters used for the room environmental parameters and occupancy prediction are listed in Table 8. The parameters are optimized through random search hyperparameter tuning [31] and calculated for each room. As occupancy prediction is a classification task, the output layer comprises both regression and classification components. A time step of 144 represents 24 h of historical data with a 10-minute time interval.
Parameter | Lecturer Room | Laboratory Room | Admin Room | Meeting Room | Lecture Room |
|---|---|---|---|---|---|
No. of input features | 6 | ||||
No. of output features | 6 (5 regression, 1 classification) | ||||
Time step | 144 | ||||
Loss function | Regression = Mean squared error | ||||
Classification = Binary cross entropy | |||||
No. of units | 64 | 32 | 32 | 32 | 64 |
Learning rate | 0.01 | 0.01 | 0.01 | 0.0005 | 0.01 |
Optimizer | RMSprop | RMSprop | RMSprop | Adam | RMSprop |
No. of epoch | 12 | 8 | 12 | 8 | 8 |
Batch size | 32 | 16 | 64 | 64 | 64 |
Figure 7, Figures 8, Figures 9, Figures 10, and Figures 11 depict the true data, training, and prediction profiles of the CO$_2$ concentration, room temperature, outdoor temperature, room humidity, and outdoor humidity in the lecturer room. The profiles in the other rooms showed similar behaviors. In each figure, the blue, orange, and green graphs represent the true data, training prediction, and test prediction, respectively. As shown in the figure, the training prediction used the first 80% of the data (left), and the test prediction used the last 20% of the data (right).





Most of the prediction profiles followed the true data patterns. However, some discrepancies were observed between the peaks and valleys. The discrepancy is likely caused by the fact that the LSTM tends to minimize the loss function (mean squared error) across the dataset, thus it tends to smooth or generalize the data, especially in the high outliers. Notably, the LSTM can predict high fluctuations in the true data, as shown in Figure 7 (room CO$_2$), Figure 9 (outdoor temperature), Figure 10 (room humidity), and Figure 11 (outdoor humidity). Notably, even though the prediction profile in Figure 8 (room temperature) shows a significant discrepancy, the vertical axis scale is very small (about 0.5°C), indicating that the RMSE is also small.
Table 9 presents the evaluation results of the environmental parameter prediction. The average RMSE of CO$_2$ prediction was 50.69 ppm. As the CO$_2$ concentration can reach approximately 900 ppm (see Figure 7), the error (RMSE) was approximately 5.6% of the maximum value, which is still within the reasonable range.
Room | RMSE | ||||
|---|---|---|---|---|---|
CO$_{\textbf{2}}$ (ppm) | Room Temp. (${ }^{\circ}$C) | Out Temp. (${ }^{\circ}$C) | Room Humid. (%) | Out Humid. (%) | |
Lecturer | 30.78 | 0.87 | 1.18 | 3.92 | 6.87 |
Laboratory | 34.92 | 1.01 | 0.86 | 3.62 | 6.46 |
Administration | 65.80 | 0.48 | 0.59 | 3.17 | 3.87 |
Meeting | 87.60 | 0.70 | 1.46 | 2.36 | 7.75 |
Lecture | 34.37 | 0.79 | 1.31 | 4.45 | 6.40 |
Average | 50.69 | 0.77 | 1.08 | 3.50 | 6.27 |
The average RMSE of the room and outdoor temperatures are 0.77°C and 1.08°C, respectively. Since the typical accuracy of the temperature sensor, as used in this experiment, is 0.5°C, these error values are acceptable.
The average RMSE of the room and outdoor humidity were 3.50% and 6.27%, respectively. Assuming that the humidity may reach approximately 90%, the percentages of errors were 3.9% and 6.9% from the maximum values for the room and outdoor temperatures, respectively. These values were still within a reasonable range.
The evaluation results of occupancy prediction are listed in Table 10. The highest performance was achieved in the lecture room, with Accuracy, Precision, Recall, and F1 score of 0.98, 0.91, 0.86, and 0.88, respectively. The average values indicated high Accuracy (0.93) and moderate Precision (0.80), Recall (0.81), and F1 scores (0.80). Based on these values, it can be interpreted that the overall prediction accuracy is high; however, owing to moderate Recall, some false negatives were obtained. In other words, the actual occupied room was not detected; thus, it was considered an empty room. Based on this finding, it saves energy, which follows the objective of this work. In short, a moderate Recall is allowable in this application.
Room | Metric | |||
|---|---|---|---|---|
Accuracy | Precision | Recall | F1 Score | |
Lecturer | 0.91 | 0.68 | 0.69 | 0.68 |
Laboratory | 0.91 | 0.72 | 0.77 | 0.75 |
Administration | 0.93 | 0.81 | 0.90 | 0.85 |
Meeting | 0.95 | 0.89 | 0.86 | 0.87 |
Lecture | 0.98 | 0.91 | 0.86 | 0.88 |
Average | 0.93 | 0.80 | 0.81 | 0.80 |
Table 11 lists the training and prediction times of the LSTM network. The average training and prediction times were 115.43 s and 3.7 ms, respectively. Because the time interval used in the experiment was 10 min, the LSTM training and prediction tasks could be performed in real time. Notably, the fast training and prediction times suggest that it can be applied for smaller time intervals, such as 2 min.
Room | Execution Time (s) | |
|---|---|---|
Training | Prediction | |
Lecturer | 118.81 | 0.0038 |
Laboratory | 65.37 | 0.0036 |
Administration | 143.57 | 0.0039 |
Meeting | 105.37 | 0.0036 |
Lecture | 144.07 | 0.0040 |
Average | 115.43 | 0.0037 |
The proposed energy optimization was evaluated using the datasets collected from 04/08/2025 (Monday) to 08/08/2025 (Friday). These datasets represent campus activities based on weekly schedules. The objective was to evaluate the effectiveness of the proposed GA-based optimization in adjusting the AC set-point temperature, as described in Section 3.6. The GA parameters used for the evaluation follow the ones suggested by Hassanat et al. [32], i.e., the population size is 100, the crossover probability is 0.9, and the percentage of mutation is 3%.
Figure 12, Figure 13, Figure 14, Figure 15, and Figure 16 show the outdoor and set-point temperature profiles of the lecturer, laboratory, administration, meeting, and lecture rooms, respectively. The blue and red graphs represent the outdoor and set-point temperatures, respectively. The set-point temperature is the optimal temperature generated by the GA-based optimization, as described previously.





The figures clearly show that the set-point temperature follows the outdoor temperature when the outdoor temperature is in the range of 24–28°C. However, outside this range, the set-point temperature will be near 24°C or 28°C. This behavior can be explained by the objective functions in Eqs. (6)–(13), where the algorithm will minimize the error between the outdoor temperature and the optimal (set-point) temperature, and the optimal temperature is limited in the range of 24–28°C.
To evaluate the effectiveness of the proposed energy optimization method in saving energy, the optimal temperature control was compared with the fixed temperature control. In the experiments, three fixed temperatures were considered: 24°C, 26°C, and 28°C.
Figure 17 shows a comparison of the total power consumption in the five rooms between the optimal and fixed temperatures for five days. In the figure, the blue, red, green, and purple colors represent the optimal (Opt) temperature and fixed temperatures of 24°C (SP24), 26°C (SP26), and 28°C (SP28), respectively. The figure shows that the daily power consumption at the optimal temperature was the lowest.

A comparison of the total energy consumption in the five rooms between the optimal and fixed temperatures over a period of five days is presented in Table 12. Figure 18 shows the comparison profiles of the total energy consumption. The table shows that the proposed optimal temperature control (Opt) achieved the lowest energy consumption of 69,592 Wh compared with the fixed temperature controls (SP24, SP26, and SP28).
Room | Energy Consumption (Wh) | |||
|---|---|---|---|---|
Opt | SP24 | SP26 | SP28 | |
Lecturer | 4,929 | 8,819 | 6,892 | 11,594 |
Laboratory | 34,856 | 48,577 | 45,849 | 56,253 |
Administration | 10,413 | 16,396 | 13,175 | 16,662 |
Meeting | 11,933 | 19,071 | 14,988 | 13,888 |
Lecture | 7,461 | 8,956 | 9,614 | 13,129 |
Total | 69,592 | 101,820 | 90,517 | 111,526 |

Figure 18 clearly shows that the energy consumption profile of the optimal control had the lowest value over the five days.
The proposed system, evaluated on the Raspberry Pi embedded platform, demonstrates an efficient real-time implementation for predicting and optimizing the EMS in campus buildings. However, due to the limitations of memory and computation power of the embedded devices, it may pose a challenging issue when extending to large buildings or complex models and algorithms. To overcome the problem, it suggests employing powerful embedded devices, such as the NVIDIA Jetson, and adopting a multi-agent system, which provides a distributed architecture suitable for the application.
Currently, the implementation of the proposed system is limited to five rooms in a campus building, which is located in a tropical climate. It is worth noting that the proposed system offers a framework model for broader applications, such as various buildings and climates. The modular architecture of the proposed approach allows for easy adoption and development for different buildings by adjusting and retraining the prediction algorithms. Furthermore, the parameters in the objective function can be adjusted to accommodate different climates and comfort levels.
The proposed architecture adopts multiple communication protocols for providing high flexibility. However, it may introduce challenging issues, such as interoperability, latency, or data loss in a heterogeneous network. The interoperability issue may occur when many devices use different protocols, resulting in complex integration. The issue can be resolved by adding gateway devices between them. The latency caused by protocol conversion can be reduced by introducing data processing on the devices, such as summarizing or aggregating data. The buffering process can resolve data loss or utilize a message-queue mechanism like the MQTT protocol.
5. Conclusions
An LSTM-based prediction of the room environmental parameters and occupancy was proposed. The room set-point temperature was optimized using GA-based optimization to reduce the energy consumption. The proposed algorithm integrates prediction and optimization techniques for a reliable implementation in real time. An IoT-based monitoring system was employed to collect data for the system evaluation. The evaluation using real data, which was implemented on an embedded device, showed promising results.
In contrast to previous studies that focus solely on prediction or optimization techniques, the proposed work integrates both and implements them on embedded devices to enable real-time applications. The proposed system features a modular architecture and a generalization optimization algorithm, enabling the framework model to be adapted to various building types and climate conditions.
The proposed study offers the managerial implications for campus building operations. The campus facility manager can use the prediction and optimization information to improve the building performance. The real-time IoT-based monitoring and optimization of the set-point temperature provides rich information on energy consumption, enabling continuous improvement of energy efficiency.
Nevertheless, several limitations should be considered. The current implementation is limited to only five rooms on a campus building, which constrains the general conclusion for large and complex buildings. The discrepancies in the prediction algorithm suggest the need for further tuning and improvement. Moreover, the multiple communication protocols may introduce interoperability, latency, and data loss issues that should be taken into account.
Future works will focus on improving models and algorithms to achieve a balance between energy efficiency and user comfort, and extend to encompass large and complex rooms in campus buildings. Furthermore, real-time implementation of the algorithm in an actual building will be investigated.
The data used to support the findings of this study are available from the corresponding author upon request.
The authors declare that they have no conflicts of interest.
AC | Air conditioning |
HVAC | Heating, Ventilation, and Air Conditioning |
PIR | Passive infrared |
AI | Artificial Intelligent |
EMS | Energy Management System |
LSTM | Long Short-Term Memory |
ANN | Artificial Neural Networks |
IoT | Internet of Things |
PV | Photovoltaic |
CO$_2$ | Carbon dioxide |
GA | Genetic Algorithm |
SCADA | Supervisory Control and Data Acquisition |
HMI | Human Machine Interface |
ITN | National Institute of Technology |
PLC | Programmable Logic Controler |
DT | Decision Tree |
k-NN | k-Nearest Neighbor |
RF | Random Forest |
XGB | eXtreme Gradient Boosting |
TP | True positive |
TN | True negative |
FP | False positive |
FN | False negative |
T | Time |
$\Delta T$ | Time interval |
RMSE | Root mean square error |
$y$ | Actual value |
$\hat{y}$ | Predicted value |
$n$ | Number of samples |
$o b j_{ref}$ | Difference between reference and optimal temperature |
$o b j_{out}$ | Difference between outdoor and optimal temperature |
$TLC_{ref}$ | Reference temperature in Lecturer room |
$TLB_{ref}$ | Reference temperature in Laboratory room |
$TAD_{ref}$ | Reference temperature in Administration room |
$TMT_{ref}$ | Reference temperature in Meeting room |
$TCL_{ref}$ | Reference temperature in Lecture room |
$TLC_{opt}$ | Optimal temperature in Lecturer room |
$TLB_{opt}$ | Optimal temperature in Laboratory room |
$TAD_{opt}$ | Optimal temperature in Administration room |
$TMT_{opt}$ | Optimal temperature in Meeting room |
$TCL_{opt}$ | Optimal temperature in Lecture room |
$TLC_{opt}$ | Outdoor temperature in Lecturer room |
$TLB_{opt}$ | Outdoor temperature in Laboratory room |
$TAD_{out}$ | Outdoor temperature in Administration room |
$TMT_{out}$ | Outdoor temperature in Meeting room |
$TCL_{out}$ | Outdoor temperature in Lecture room |
