1. Introduction
The rapid development of technology improves the quality of life, enabling convenient and intelligent lifestyles. However, environmental problems such as global warming, climate change, energy crises, and the greenhouse effect have become increasingly significant at the same time. Therefore, sustainable development is a global issue requiring concrete implementation.
The Bureau of Energy, the Ministry of Economic Affairs, and the Industrial Technology Research Institute suggested that the top five electrical appliances consuming electricity in Taiwan are “air conditioners” (27.64%), “refrigerators” (12.49%), “lighting” (10.43%), “electric water heaters” (10.37%), and “televisions” (6.98%) [
1,
2]. Considering that schools generally have equipment for air conditioning and lighting, an adaptive smart energy-saving campus system is required to reduce electricity consumption and transform campuses into energy-saving ones.
Therefore, we developed an adaptive smart energy-saving campus system by using a random forest (RF) classifier to categorize and predict users’ habits of electricity usage. Expert system rules were adopted to control air conditioning, lighting, temperature, and humidity according to the class schedule. According to the predicted user habits by the system, a responsive web design method was employed to develop an Internet of Things (IoT) control interface to reduce costs and enhance convenience. Gamification elements were introduced to create an “achievement system” to motivate users to continuously engage in energy-saving practices.
2. Literature Review
2.1. Web Technology
The website of the system was developed using the ReactJS framework, Next.js, Tailwind CSS, and TypeScript. Responsive web design (RWD) was used for rendering web pages on various devices, enhancing portability and convenience.
2.1.1. ReactJS Framework and Next.js
This component-based management approach enhances code readability for the individual management of component states and improves the developer experience. In addition, ReactJS supports TypeScript for the detection of most errors at the compilation stage and thus increases code maintainability. Next.js, based on React, also supports server-side rendering (SSR). In contrast to client-side rendering (CSR) in ReactJS, which must run JavaScript to generate the HTML content, the SSR technique displays webpages immediately after a browser receives HTML webpages from the server. This provides better performance than ReactJS. However, when JavaScript is not executed, the initial display is not interactive. This allows users to see the web page first, and a human perception delay time is applied to execute the JS code. These applications significantly reduce the user bounce rate so we used Next.js as the front-end framework.
2.1.2. Tailwind CSS
Tailwind CSS is a utility-first CSS framework consisting of small, composable CSS classes with the following three advantages:
Rapid web development: Since there is no need to write extensive CSS files outside of the HTML document, the development speed is typically faster.
Highly customizable layouts: Unlike other CSS frameworks that come with a variety of UI components, utility-first frameworks provide various common utility classes to accommodate different interface scenarios.
No naming conflicts: This allows developers to focus more on layout and style design, resulting in a significantly improved overall development experience compared to traditional CSS.
2.2. Expert System [3]
An expert system is designed to create artificial intelligence (AI) programs based on specialized knowledge and experience in specific fields. It represents a particular area of expertise, performs reasoning to solve problems, and provides recommendations. Generally, an expert system consists of a knowledge base and inference engines, referred to as a knowledge-based system.
Due to its ability to continuously learn, correct, and update existing knowledge, the expert system was used in the developed system. By utilizing the knowledge stored in the knowledge base regarding the usage habits of air conditioning and lighting based on the energy-saving rules embedded in the inference engine, the system offers optimal energy-saving recommendations while ensuring user comfort and achieving energy-saving goals (
Figure 1).
2.3. Machine Learning (ML) [4,5]
ML is used to develop algorithms and statistical models to train models to learn from data and continuously improve based on experience, rather than simply execute fixed actions based on an existing code. Its advantage is the ability to train algorithms from large datasets to identify patterns and automate tasks without human intervention. Using ML, the developed system learns a vast amount of user habits and incorporates this information into the knowledge base of the expert system for the decision making of the expert system regarding energy-saving judgments.
The system employs the RF model [
6], which is a type of ensemble learning in ML. RF combines multiple independent regression trees, known as classification and regression trees (CARTs), and then averages their classification results or uses a majority vote to produce the final model prediction. RF combines several “weak learners” to create a “strong learner”.
The architecture of the RF model consists of the following key components.
2.3.1. Random Sampling of Instances
In total, 63.2% of the samples were randomly selected from the training data using a bootstrap method, where sampling with replacements. The data points that were not selected were referred to as out-of-bag (OOB) samples.
2.3.2. Random Feature Selection
For categorical features, a random selection of √K features were chosen to build the CART model, where K is the total number of features.
2.3.3. Setting Number of CART Models
RF was used to construct a CART model based on the randomly selected samples and features, and this process was repeated N times to create N-independent CART models. N is a user-defined value. Finally, the classification results of these N models were averaged (or decided by majority voting) to obtain the final prediction value.
2.4. Unity [7]
Unity, similar to other “game engines”, is a “software framework” or a set of tools that facilitates rendering, physics, and input by developers, freeing them from having to construct virtual spaces from the ground up. The engine provides the building blocks for both three-dimensional (3D) and two-dimensional (2D) virtual worlds. Unity contains features compatible with other platforms.
2.4.1. Interoperability
Unity is used to develop a “build and run” protocol, which requires the tap of a button to load and start playing content on different devices. The code is continuously updated to accommodate builds for emerging formats.
2.4.2. Asset Store
This permits amateurs and professionals to upload homemade scenes, code, addons, and avatars for other users to download (for free or for a fee) and populate virtual spaces. Unity “packages” are employed by developers and hardware manufacturers. Packages usually include custom “scenes” or virtual world setups where the capabilities of hardware and software are modeled and assessed. If a new device is added, such as the hand-tracking controller, images are downloaded through the engine so that developers can test the hardware and use it to build games and applications.
2.5. Behavioral Psychology [8,9,10]
Behavioral psychology focuses on people’s behavior patterns and the reasons behind these patterns. There are two important concepts in behavioral psychology.
2.5.1. Operant Conditioning (Rewards and Punishments)
When a behavior is repeated and rewarded, it becomes more frequent. Conversely, when a behavior is punished, it tends to occur less often.
2.5.2. Social Learning Theory
Social learning theory assumes that people learn by observing and imitating the behaviors of others. In this theory, individuals are likely to model the behaviors of those they perceive as authority figures. A design to encourage behavioral change is based on behavioral psychology and incorporates psychological theories such as self-efficacy and self-determination theory.
2.5.3. Self-Efficacy
Self-efficacy refers to an individual’s belief in their own ability to successfully complete a task or achieve a goal. In simple terms, it is a subjective assessment of one’s capabilities, which does not necessarily correlate with actual ability. People often choose different behavior patterns and levels of effort based on their self-efficacy beliefs rather than their actual abilities.
2.5.4. Self-Determination Theory (SDT)
SDT is a cognitive–motivational framework developed in the context of positive psychology. This theory assumes that individuals are inherently proactive and have needs for self-actualization and personal growth. Human development and change arise from the fulfillment of the following three basic psychological needs.
Autonomy: People desire to make decisions based on their preferences when engaging in activities. They want to have a sense of control and feel unrestricted in their actions.
Competence: Individuals want to feel capable and effective while participating in activities. The clearer they are about their ability to solve problems, the greater their sense of achievement and motivation to engage in those activities.
Relatedness: People seek a sense of care and love from others in their environment to foster feelings of belonging and acceptance.
Therefore, in this study, we employed “gamification” to behavior change design to continuously enhance users’ self-efficacy in using the platform. Then, the three basic psychological needs outlined in SDT were satisfied to significantly increase users’ motivation for energy conservation.
3. Research Methods
System Architecture
The developed system comprises indoor temperature sensors, wind speed sensors, indoor humidity sensors, air conditioner controllers, and light controllers. The first three were used to collect environmental sensing data needed for the perceived temperature formula, while the latter two were responsible for controlling the hardware devices. The backend of the system uses SQLite, a lightweight database for data storage. In the front end, a responsive web design model was employed to ensure a consistent and high-quality user experience across various mobile device sizes. Additionally, a mobile game was designed as an achievement system to stimulate users’ motivation for energy conservation. The API between the web interface and the database was written in tRPC, while the API between the mobile game and the database in C#. The API between the RF Classifier and the knowledge base was written in Python (version 3.12.0). The system architecture is illustrated in
Figure 2.
4. System Workflow
The process consists of (1) data collection and preprocessing, (2) model training and testing, and (3) integration with the expert system (
Figure 3).
Data Collection and Preprocessing
Environmental data were collected every 10 min from temperature, humidity, and wind speed sensors. These data were imported into the system according to the curricular schedule as “features” and used to control the current air conditioner status (on/off), temperature setting, and light status as “labels”. The collected data for one week were included in a dataset for the RF model after being preprocessed. Since the collected time format included the date and time, they were converted to a week format to assess how the day of the week affected behaviors during the learning process of the RF model. Using Python’s ML library and scikit-learn, which require the feature values in the dataset to be floats or integers, we converted the time into minutes, divided it by 10,000, and then added the integer representation of the day of the week to it. This completed the time “encoding” process, as illustrated in
Figure 4.
5. Model Training and Testing
The training of the RF model was conducted as follows:
We prepare the training data.
We use GridSearchCV to explore various hyperparameter selections and determine the hyperparameters with the highest accuracy through cross-validation, as shown in
Figure 5.
Once the hyperparameters are set, the model is trained. Air conditioners and light switches are trained separately, as their results are independent of each other.
After training, the out-of-bag (OOB) score is used to test the model’s generalization ability (
Figure 6). The classification reports for air conditioners and light switches are shown in
Figure 7.
The training dataset consisted of 1320 entries, which were collected every 10 min between 8:00 AM and 7:00 PM for a month.
Figure 7 displays the learning results for one month. The model was retrained every month to prevent overfitting to the user’s habits, ensuring effective energy conservation.
6. Integration with the Expert System
The user habits inferred by the RF model were imported into the knowledge base of the expert system to influence the inference engine. Meanwhile, IoT sensors transmitted real-time data on temperature, humidity, and wind speed to the inference engine via an API. The inference engine used the perceived temperature formula following predefined rules to determine the most suitable appliance behavior. It then adjusted the recommendations based on the user habits stored in the knowledge base, which were delivered to the final actions to control air conditioners and light switches. These actions were subsequently executed corresponding to IoT controllers.
The rules of the inference engine consisted of the following three principles:
Principle 1: Determine whether to turn air conditioners and light switches on or off based on the settings in the knowledge base:
Rule 1: If the ACStatus is 0, do not turn on the air conditioner. If the ACStatus is 1, proceed to Principle 2.
Rule 2: If the LightStatus is 0, do not turn on the lights. If the LightStatus is 1, turn on the lights.
Principle 2: Calculate the optimal temperature for the air conditioner using the perceived temperature formula:
Rule 1: If there is no suitable temperature between 26 and 28°, fall back to the range of 20 to 25°.
Rule 2: If there is a suitable temperature within 26 to 28°, calculate the optimal temperature from this range.
Principle 3: Selection of air conditioner functions:
Rule 1: If the current mode is cooling and the indoor temperature is not comfortable, stay in the cooling mode.
Rule 2: If the current mode is cooling and the indoor temperature is comfortable, switch to the fan mode.
The perceived temperature can be calculated according to the following formulas, where AT = Perceived temperature (°C), T = Temperature (°C), e = Vapor pressure (hPa), v = wind speed (m/sec), RH = Humidity (%):
7. Responsive Web Design
The website required users to log in using their school Gmail accounts. Only teaching assistants and teachers with scheduled classes during that time could log in, preventing too many individuals from having control and thereby avoiding potential conflicts of opinion. After logging into the website, users selected the device control page (
Figure 8a), which served as the IoT control interface. The dropdown menu at the top allowed users to choose the control location, limited to the classroom. Below the menu, interfaces were located for controlling the air conditioner and lights, enabling users to perform the corresponding device control operations. Users accessed the history data page (
Figure 8b,c), which offered two types of information: historical data and electricity consumption statistics. Users selected the desired date and retrieved the data results. The game page (
Figure 8d) showed rankings in the energy-saving game.
8. Mobile Game Design
Users must log into the website to play the game (
Figure 9a). After logging in, they are awarded daily rewards (
Figure 9b). On the main game screen (
Figure 9c), a button was chosen to view daily shared energy-saving tips (
Figure 9f). Users used the money they earned from daily logins to purchase decorative items for their penguin (
Figure 9e) and diamonds earned through gameplay to buy real-world products (
Figure 9d) (e.g., discount vouchers, parking tickets, etc.). This energy-saving game automatically detected the air conditioner’s on/off status and temperature. If the air conditioner was on, hearts were deducted depending on the temperature; if it was off, no actions occurred. Therefore, the game encouraged users to minimize the number of hearts deducted and save the penguin (
Figure 9g). At 7:00 PM, the game calculated experience points and level promotion in a day (
Figure 9h,i) and stopped.
Figure 10 shows the relationship between these game interfaces and corresponding psychological theories.
9. Conclusions
The developed adaptive smart energy-saving campus system effectively reduced the costs using interesting user interaction with hardware devices through IoT technology and control interfaces. An expert system was used to automatically and systematically manage hardware operations, allowing users to engage in energy-saving behaviors without manual intervention, thereby contributing to environmental sustainability. While promoting energy conservation, the system enabled user comfort. The system encouraged users to maintain consistent energy-saving practices. ML was employed to analyze users’ electricity consumption habits and adjust the energy-saving rules of the expert system, thereby balancing comfort and energy efficiency. The system allowed users to gradually adopt energy-saving behaviors at their own pace. Finally, the system leveraged psychological theories to design a gamified interface and motivate users to enhance their energy-saving performance and boost their motivation for conservation.
Author Contributions
Conceptualization: Z.C., R.-I.C. and Q.W.; methodology: Z.C.; software: Z.C.; validation: R.-I.C. and Q.W.; writing: Z.C., R.-I.C. and Q.W. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
The original contributions presented in the study are included in the article, further inquiries can be directed to the corresponding author.
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Bureau of Energy, Ministry of Economic Affairs. The Household Energy-Saving Guidelines. Available online: https://general.ctcn.edu.tw/general-2009/Downloads/%E5%AE%B6%E5%BA%AD%E7%AF%80%E8%83%BD%E6%89%8B%E5%86%8A.pdf (accessed on 22 April 2025).
- Industrial Technology Research Institute. 2023 Household Electricity Information Encyclopedia. Available online: https://energypark.org.tw/upload/propaganda/202408131715095.pdf (accessed on 22 April 2025).
- Kaisler, S. Expert systems: An overview. IEEE J. Ocean. Eng. 1986, 11, 442–448. [Google Scholar] [CrossRef]
- Apaydin, E. Introduction to ML, 4th ed.; PHI Learning: Delhi, India, 2020. [Google Scholar]
- Mahesh, B. ML Algorithms—A Review. Int. J. Sci. Res. (IJSR) 2018, 9, 381–386. [Google Scholar] [CrossRef]
- Breiman, L. Random forests. Mach. Learn 2001, 45, 5–32. [Google Scholar] [CrossRef]
- Foxman, M. United We Stand: Platforms, Tools and Innovation with the Unity Game Engine. Soc. Media+ Soc. 2019, 5, 1–10. [Google Scholar] [CrossRef]
- Casals, M.; Gangolells, M.; Macarulla, M.; Forcada, N.; Fuertes, A.; Jones, R.V. Assessing the effectiveness of gamification in reducing domestic energy consumption: Lessons learned from the EnerGAware project. Energy Build. 2020, 210, 109753, Erratum in Energy Build. 2020, 223, 110193. [Google Scholar] [CrossRef]
- Pan, S.; Shen, Y.; Sun, Z.; Mahajan, P.; Zhang, L.; Zhang, P. Demo Abstract: Saving Energy in Smart Commercial Buildings through Social Gaming. In UbiComp ’13 Adjunct, Proceeding of the 2013 ACM Conference on Pervasive and Ubiquitous Computing Adjunct Publication, Zurich, Switzerland, 8–12 September 2013; Association for Computing Machinery: New York, NY, USA, 2013; pp. 43–46. [Google Scholar]
- Bucher, A. Engaged: Designing for Behavior Change; Rosenfeld Media: Brooklyn, NY, USA, 2020. [Google Scholar]
| Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).