Toward an Intelligent Campus: IoT Platform for Remote Monitoring and Control of Smart Buildings

With the growing need to obtain information about power consumption in buildings, it is necessary to investigate how to collect, store, and visualize such information using low-cost solutions. Currently, the available building management solutions are expensive and challenging to support small and medium-sized buildings. Unfortunately, not all buildings are intelligent, making it difficult to obtain such data from energy measurement devices and appliances or access such information. The internet of things (IoT) opens new opportunities to support real-time monitoring and control to achieve future smart buildings. This work proposes an IoT platform for remote monitoring and control of smart buildings, which consists of four-layer architecture: power layer, data acquisition layer, communication network layer, and application layer. The proposed platform allows data collection for energy consumption, data storage, and visualization. Various sensor nodes and measurement devices are considered to collect information on energy use from different building spaces. The proposed solution has been designed, implemented, and tested on a university campus considering three scenarios: an office, a classroom, and a laboratory. This work provides a guideline for future implementation of intelligent buildings using low-cost open-source solutions to enable building automation, minimize power consumption costs, and guarantee end-user comfort.


Introduction
The Chilean new energy efficiency law No. 21,305 was published on 13 February 2021, establishing Chile's national energy efficiency plan. Among the main aspects of energy efficiency that the new law targets are the national energy efficiency plan, energy management of large consumers, energy labeling/rating for buildings, and efficiency standards for vehicles [1]. Considering that buildings are responsible for about 60% of the total global electricity consumption [2], information on energy usage is fundamental for the development of different energy management system (EMS) solutions . In particular, such solutions are critical for those users in charge of buildings administration. Knowing the different equipment power consumptions is vital for controlling the expenses associated with building operations.
However, most of the research is based on assumptions or simulations which ignore the practical issues from the real implementation. Examples of real implementation can be found in [3,4,9,12,19]. Furthermore, the condition of the electricity system differs between countries and regions, which then requires identifying the specific requirements and needs for each design. This work aims to fill the gap related to technical implementation in a realistic environment. The main objective of this work is to design and implement an IoT platform that integrates information from various smart sensor nodes and measuring devices connected to buildings for obtaining information related to power consumption in order to support energy management solutions. All collected data will be processed to deliver the relevant information to the end user, who can then perform remote actions accordingly. The main activities required to achieve the proposed objective are:

•
Define the system requirements for intelligent buildings and prioritize these requirements for developing the solution, including data collection from different sensor nodes and measurement devices. • Build the IoT platform for smart buildings, which includes four main layers: power layer, data acquisition layer, communication network layer, and application layer. • Implement the back-end and front-end systems. The proposed solution involves the development of a network of sensors and measurement devices and the integration of the processing unit and the databases. The front-end implementation phase consists of developing a user interface for interaction, visualization, and data analysis. • Implementation of the testbed and validation, where the designed prototype will be installed and tested in the context of a real application (Department of Electronic Engineering, Universidad Técnica Federico Santa María (UTFSM), Valparaíso, Chile), including an office, a laboratory, and a classroom to assess the functionality and usability of the proposed solution.
This paper is structured as follows: Section 2 presents a review of related work for smart buildings. Section 3 introduces the hierarchical energy management architecture for the intelligent campus. Section 4 presents the proposed IoT architecture for smart buildings. Section 5 discusses and analyses the proposed solution and the results. Section 6 presents the conclusion and future work.

Related Work
Smart buildings and building energy management systems (BEMS) are active research areas with different application domains such as demand response programs, optimizing building power consumption, integrating renewable energy systems, etc. In [2], the authors highlighted that IoT provides a new opportunity to integrate intelligence into building management systems. Such IoT solutions are cost-effective, enabling monitoring and managing the energy consumption of the buildings. The work summarized the application of IoT in buildings, including lighting, heating, ventilation, air conditioning (HVAC), flexible loads, human detection and diagnostics, and prognostics. A case study was discussed on how to use low-cost IoT devices to provide building management with key insights into human activity and occupancy detection.
In [3], the authors presented the design and implementation of an IoT gateway for a cloud-based building energy management system. The work focused on the software architecture and the software design of the gateway device, which acts as a master device, polling devices on the network and pushing the received data to the cloud. The gateway device was designed to support legacy protocols such as Modbus, BACnet, and HTTP RESTful interface devices. The developed software was evaluated with respect to RAM consumption under various stress tests and bandwidth utilization.
In [4], the authors proposed a fog-based IoT platform for smart building, which consists of five layers: end devices, network connectivity, fog processing, cloud processing, and security and privacy layer. The end devices include sensor nodes (temperature and humidity sensor, light sensor, PIR sensor, and accelerometer sensor) and actuator nodes (feedback action). The work focused on indoor ambience monitoring and occupancy monitoring. A prototype has been deployed and tested in a testbed room for door/window state detection, room occupancy detection, and room lighting sense and control. In [5], the authors proposed an IoT architecture for hybrid wind/PV/diesel/battery on a university campus. The proposed architecture consists of four layers: power layer, data acquisition layer, communication network layer, and application layer. The work is considered a case study on a university campus. However, the work focused on network modeling and simulation of the communication network layer for the hybrid energy system with respect to network topology, link capacity, and latency.
In [6], the authors presented a review of the concept of IoT and its potential application in smart buildings where the major components of the IoT system consist of devices/sensors, networks, cloud, analytics, and actuators/user interfaces. The conventional architecture for the smart building consists of three layers: the perception layer, network layer and application layer. The work discussed the challenges and recommendations for future research, including (1) security and privacy issues, (2) data acquisition, processing and storage issues, (3) feasibility and practicality issues, and (4) collaboration between IoT developers and the building industry. In [7], the authors presented a survey for different types of applications in smart buildings, including security control, energy management, monitoring and control of HVAC, water management, lighting system, fire detection, and health system for elders.
In [8], the authors proposed IoT based thermal model learning framework for a smart building based on low-cost IoT devices (smart thermostats). The data collected from the IoT platform installed inside the building has been used for validating the learning framework. In [9], the authors presented a low-cost solution for non-smart residential load appliances using smart load nodes. The integration of this solution does not require any change in the electric infrastructure of the house, as well as no modifications to the load appliances. The system considered wireless communication using WiFi in HAN, where the main measurements include voltage, current, power, and power factor.
In [10], the authors presented a comprehensive survey on the intersection of IoT and smart grid systems (IoT-aided smart grid systems), which includes architectures, applications, and prototypes. The work also presented different challenges and future research directions. In [11], the authors reviewed the architectures and functions of IoTenabled smart energy grid systems. Special focus was given to IoT technologies such as sensing, communication, and computing. The work also reviewed security vulnerability, attack models, and existing threat summarizing mitigation techniques for such security vulnerabilities. In [12], the authors reviewed recent activities related to IoT-based energy systems. The work highlighted the potential areas to improve at different layers and reviewed communication technologies and standards related to energy systems. Some examples were discussed, including smart homes, smart power grids, and smart cities.
In [13], the authors presented a hierarchical IoT-based microgrid for energy-aware buildings. The proposed framework consists of the physical layer, information layer, control layer, and dispatch layer. The IoT microgrid laboratory at Aalborg university was introduced to explain how to implement the proposed scheme in a building. In [18], the authors presented a comprehensive review of thermal comfort in hospitals, identifying the current status of research and future research directions. The main research themes were influencing factors, field surveys, measures to improve and energy saving.
In [19], the authors proposed an IoT-based occupancy-driven plug load management system with the objective of reducing the energy consumption of plug loads and plug load automation. Six different strategies for plug load control, such as manual control, predefined schedule, occupancy-driven control, and hybrid control, were evaluated during a field study of 5-months within a university office space. In [22], the authors introduced the application of deep learning and IoT to control the operation of air conditioners to reduce energy consumption in a smart building. In order to count the number of persons in a certain area, the work considered the YOLOv3 algorithm. In [23], the authors provided architectural elements of connected indoor lighting systems within a building. In particular, application programming interfaces (APIs) were presented to support data access and lighting system control. Table 1 summarizes the discussed related work highlighting the presence or absence of the different smart building IoT layers. The work proposed here aims to develop a hardware/software solution to enable gathering the information from smart sensors and energy monitoring devices and display it to the end users so they can take the necessary actions for the proper functioning of the building.

Hierarchical Energy Management Architecture for Intelligent Campus
A university campus generally consists of a group of buildings connected to the main power grid. The energy management approach can be classified into different levels: campus energy management system (CEMS), building energy management system (BEMS), • Campus energy management system (CEMS): The CEMS monitors the power generation (renewable energy), energy storage, and consumption of university buildings and interacts with each BEMS to optimize energy usage. In addition, the CEMS receives the energy consumption data of each building, stores it in a database, and estimates the consumption and future generation based on historical data. • Building energy management system (BEMS): In general, university buildings consist of a group of offices, laboratories, and classrooms. The BEMS collects the energy data and other weather information collected by different smart meters and sensors located in the building and interacts with the building loads. The CEMS provides large-scale data acquisition, communication, and data processing for energy management in buildings which requires cooperation among each BEMS in order to meet the operator requirements for minimizing power consumption and costs. However, as the number of energy management units increases, many challenges are related to cost, latency and reliability. This work target one building (Building B) of the UTFSM Campus, Valparaiso, Chile.
The university campus (Casa Central, Valparaíso, Chile) was inaugurated in 1931. Nowadays, there is a lack of monitoring and control for energy consumption in university buildings. There is still a high cost for building automation systems for small and medium-sized buildings, which prohibits purchasing such solutions. Furthermore, there is still a limitation for compatibility with different vendors, devices, and communication technologies in case of relying on using a particular platform. The proposed IoT platform aims to develop a custom solution using cost-effective off-the-shelf sensors/devices for real-time monitoring and control of building energy consumption through a web interface. Three case studies are considered: an office, a laboratory, and a classroom. Three case studies are considered: an office, a laboratory, and a classroom. The CEMS provides large-scale data acquisition, communication, and data processing for energy management in buildings which requires cooperation among each BEMS in order to meet the operator requirements for minimizing power consumption and costs. However, as the number of energy management units increases, many challenges are related to cost, latency and reliability. This work target one building (Building B) of the UTFSM Campus, Valparaiso, Chile.

IoT-Based Architecture for Smart Buildings
The university campus (Casa Central, Valparaíso, Chile) was inaugurated in 1931. Nowadays, there is a lack of monitoring and control for energy consumption in university buildings. There is still a high cost for building automation systems for small and medium-sized buildings, which prohibits purchasing such solutions. Furthermore, there is still a limitation for compatibility with different vendors, devices, and communication technologies in case of relying on using a particular platform. The proposed IoT platform aims to develop a custom solution using cost-effective off-the-shelf sensors/devices for real-time monitoring and control of building energy consumption through a web interface.
Three case studies are considered: an office, a laboratory, and a classroom. Three case studies are considered: an office, a laboratory, and a classroom.

IoT-Based Architecture for Smart Buildings
The main objective of this work is to design and implement an IoT platform for realtime monitoring and control of energy consumption in buildings to achieve an intelligent campus. There are different IoT architectures., such as three-layer (perception layer, network layer, and application layer), four-layer (perception layer, network layer, service layer, and application layer), and five-layer (perception layer, network layer, service layer, application layer, and business layer) [5,[10][11][12][13][14]. Considering the various IoT-based architectures, Figure 2 shows the main components of a three-layers IoT-based architecture for smart buildings, which consist of the perception layer, network layer, and application layer. The perception layer usually emphasizes energy usage, occupant activities, and environmental condition. Different wired/wireless communication technologies could be used for data transmissions, such as WiFi, ZigBee, Bluetooth, and LoRa in the network layer. The application layer corresponds to business, application, and service management. The collected data at the application layer explains the actual building energy usage, energy management, occupant information, etc.   Figure 3 shows a detailed schematic diagram of the proposed IoT-based architecture for smart buildings. Our work aims to achieve building automation to minimize energy consumption costs and guarantee the comfort of the occupants. Our proposed architecture consists of four layers: power layer, data acquisition layer, communication network layer and application layer.

•
Power Layer: the power layer consists of power generation, power storage, and loads that are connected to the power grid. In this study, the campus buildings are connected to the power distribution network (provided by Chilquinta). Other power generation sources may include solar panels, wind turbines, and batteries for power storage. The main power consumption in buildings may consist of HVAC, lights, and vehicle charging stations. • Data Acquisition Layer: the data acquisition layer is responsible for capturing all the data coming from the power layer devices for making decisions. Examples of sensor nodes are measuring devices from light, temperature, power consumption, and meteorological station.   Figure 3 shows a detailed schematic diagram of the proposed IoT-based architecture for smart buildings. Our work aims to achieve building automation to minimize energy consumption costs and guarantee the comfort of the occupants. Our proposed architecture consists of four layers: power layer, data acquisition layer, communication network layer and application layer.

•
Power Layer: the power layer consists of power generation, power storage, and loads that are connected to the power grid. In this study, the campus buildings are connected to the power distribution network (provided by Chilquinta). Other power generation sources may include solar panels, wind turbines, and batteries for power storage.
The main power consumption in buildings may consist of HVAC, lights, and vehicle charging stations. • Data Acquisition Layer: the data acquisition layer is responsible for capturing all the data coming from the power layer devices for making decisions. Examples of

Smart Building Implementation
The proposed solution was implemented considering three locations with different needs. The details for each scenario and location are given below: • Office Room: The first scenario is office B-349. This is a representation of professors' offices distributed in Jeonju pus. Most offices include computers with one or more monitors, printers, and plugs to charge mobile devices. All offices include fixed lighting activated by a switch on the wall. Because it is a relatively small space, the energy measurement of the entire room was not considered. • Laboratory Room: The second scenario is laboratory B-110. In this laboratory, there are at least four permanent workstations where a computer can be connected and external monitors for each of these positions. In addition, there is a shared space to carry out different activities. In this case, the implementation of smart plugs is proposed to monitor computers and other equipment connected to the power network.
On the other hand, given the energy requirements of the space, it is suggested to install an energy meter in the electrical panel to monitor the total energy in the room. • Classroom: The third scenario is classroom B-213. This classroom has luminaires that can be controlled with smart switches, one projector that can be controlled with smart plugs, and several sockets that allow students and teachers to connect their personal devices. An energy meter can be used on the electric board. In addition, an environmental measuring device can be installed to monitor the air quality during the clas-

Smart Building Implementation
The proposed solution was implemented considering three locations with different needs. The details for each scenario and location are given below:

•
Office Room: The first scenario is office B-349. This is a representation of professors' offices distributed in Jeonju pus. Most offices include computers with one or more monitors, printers, and plugs to charge mobile devices. All offices include fixed lighting activated by a switch on the wall. Because it is a relatively small space, the energy measurement of the entire room was not considered. • Laboratory Room: The second scenario is laboratory B-110. In this laboratory, there are at least four permanent workstations where a computer can be connected and external monitors for each of these positions. In addition, there is a shared space to carry out different activities. In this case, the implementation of smart plugs is proposed to monitor computers and other equipment connected to the power network. On the other hand, given the energy requirements of the space, it is suggested to install an energy meter in the electrical panel to monitor the total energy in the room. • Classroom: The third scenario is classroom B-213. This classroom has luminaires that can be controlled with smart switches, one projector that can be controlled with smart plugs, and several sockets that allow students and teachers to connect their personal devices. An energy meter can be used on the electric board. In addition, an environmental measuring device can be installed to monitor the air quality during the classes. Figure 4 shows the locations of different scenarios, while Table 2 shows the list of appliances and sensors considered at each location.

Selected Alternatives Solutions for Devices, Technologies, and Services
The implementation is carried out considering the proposed 4 layers discussed in the previous section. The description of equipment and technologies used in each layer are given in Table 3 and Figure 5. Although the system is proposed and designed for the three different scenarios in different locations, we organized and assembled a testbed shown in Figure 6. The testbed will allow us to collect data from various appliances individually and/or together for later using it to validate different machine learning algorithms. Table 3. List of sensors and measuring devices used for the testbed.

Selected Alternatives Solutions for Devices, Technologies, and Services
The implementation is carried out considering the proposed 4 layers discussed in the previous section. The description of equipment and technologies used in each layer are given in Table 3 and Figure 5. Although the system is proposed and designed for the three different scenarios in different locations, we organized and assembled a testbed shown in Figure 6. The testbed will allow us to collect data from various appliances individually and/or together for later using it to validate different machine learning algorithms. Table 3. List of sensors and measuring devices used for the testbed.

Layer Details
Data Acquisition Layer Smart Plug, Air quality sensor, Smart meter for the total power consumption, Data acquisition module for photovoltaic system, Data collection module for a weather station  The testbed is powered by an external source connected directly to a small electrical panel. On the board, there is a pilot light to verify the electric power at the input, then a switch for protection in case of current overconsumption, and a tetrapolar bar to facilitate the connection of equipment on the testbed. The testbed also includes two circuits: the lighting circuit and the sockets circuit. Furthermore, other components include a small router that provides a local WiFi network for the equipment, a LoRa gateway, and a Raspberry Pi that implements the proposed architecture. Detailed characteristics, setup and comparison among different types of sensors, measuring devices, and network elements are given in Appendixes A and B.  The testbed is powered by an external source connected directly to a small electrical panel. On the board, there is a pilot light to verify the electric power at the input, then a switch for protection in case of current overconsumption, and a tetrapolar bar to facilitate the connection of equipment on the testbed. The testbed also includes two circuits: the lighting circuit and the sockets circuit. Furthermore, other components include a small router that provides a local WiFi network for the equipment, a LoRa gateway, and a Raspberry Pi that implements the proposed architecture. Detailed characteristics, setup and comparison among different types of sensors, measuring devices, and network elements are given in Appendixes A and B. The testbed is powered by an external source connected directly to a small electrical panel. On the board, there is a pilot light to verify the electric power at the input, then a switch for protection in case of current overconsumption, and a tetrapolar bar to facilitate the connection of equipment on the testbed. The testbed also includes two circuits: the lighting circuit and the sockets circuit. Furthermore, other components include a small router that provides a local WiFi network for the equipment, a LoRa gateway, and a Raspberry Pi that implements the proposed architecture. Detailed characteristics, setup and comparison among different types of sensors, measuring devices, and network elements are given in Appendices A and B.

Monitoring Power Consumption of Appliances
For monitoring the power consumption of appliances, smart plugs of the "Sonoff POW R2" type are used [24]. All smart plugs were updated with ESPurna firmware and configured for wireless data transmission using WiFi [25]. Regarding the electric connection, the smart plugs need to be connected with electric cables and installed between the electric power supply and the appliances.
Different configurations for using smart plugs type "Sonoff POW R2" are considered for the testbed:

•
Control the complete circuit: In this case, the whole lighting circuit was passing through the smart plug, which allows measuring and control of the lights (highlighted with green color in Figure 6) • Control a socket: In this case, the connection was configured, which allows obtaining data from all equipment connected to the socket (highlighted with yellow color in Figure 6) • Control a single device: This configuration allows a single device to be connected (highlighted with blue color in Figure 6)

Monitoring Total Power Consumption
The total power consumption measurement is carried out using the pzem-004t-100a module. The module measures the input voltage of the electrical panel under study and a current transformer sensor for the current. The module is connected to the ESP32 platform for subsequent data sending.

Monitoring Photovoltaic System
The main parameters considered for monitoring the photovoltaic panel include measuring the current with a current transform (CT) sensor. The sensor delivers a current proportional to the measurement current and a voltage divider for voltage measurement. Both measurements are captured with ADC pins of the Arduino nano development board. Data is sent to the NodeMCU development board Amica, which has WiFi communication and send the data by MQTT along with the date and time they were captured using a real-time clock (RTC).

Monitoring Indoor Environmental Condition
The air quality sensor type "Dragino LAQ4" was used to monitor indoor environmental conditions [26]. The main parameters measured are total volatile organic compound, CO2 equivalent, temperature, and relative humidity of the air. To obtain such indoor environmental data, the configuration of LoRa Gateway is required. In this work, we use the Dragino Gateway LG308 [27].

Monitoring Weather Station
The meteorological information was measured using Davis Advantage Pro 2 Plus weather station [28]. The weather station obtains the data from the sensors physically connected to the station, then sends data wirelessly to the Vantage Pro 2 console. If connected to the datalogger, we can connect the console with a USB cable to the computer. Please note that the weather station is a closed system that does not allow the external manipulation of the data obtained.

Network Layer
The communication protocols for data transmission are MQTT and LoRa, which have been considered for implementing the communication network layer. For the smart plugs, the communication using MQTT is activated and configured by choosing the MQTT section from the side menu displayed in the web interface of the smart plugs with ESPurna firmware installed. In the case of general measurement devices and photovoltaic panels, the integration of the MQTT protocol is carried out within the code which we were programmed with. The configurations for all devices connecting via MQTT are similar; that is, they connect to the broker running on the Raspberry Pi with the IP 192:168:2:2 through port 1883 and are differentiated by the topic in which they publish. The topics were defined as a descriptive manner of the measurement and the locations where the data are taken and displayed, as shown in Table 4. In the case of the air quality measurement device (LAQ4), a procedure should be carried out for the configurations. An account is created on the things network server at (https://www.thethingsnetwork.org (accessed on 10 January 2022)) [29]; then, when registering, you must enter the start section (which leads to the address https://console. cloud.thethings.network/ (accessed on 10 January 2022)) where the Cluster "Nam1" located in the state of Carolina in United States was chosen, and once selected you enter the Gateways tab where you press the + add gateway button, filling in all the requested data, in particular, the Gateway ID which is the unique number associated with each gateway LoRa. For the case of this work, the names used are GatewayOfBuilding, and the gateway ID is gatewaylorabuilding01. Once the registration of the LoRa gateway is completed, one can return to the gateways tab and select the registered gateway to see information about this connection with the network server.
Once the gateway connection has been verified, we go to the applications tab and press the button + add application. Only 3 parameters must be filled, namely "Application ID", "Application Name" and "Description" that, for this case is filled with the data of smart-"buildingslora-sensors-usmcc" in Application ID and "lora sensors in usmcc" in Application Name. Once the application has been created and when entering it, press the button + add end device and enter the data for the desired sensor, which in this case is the LAQ4. Then, data can be entered corresponding to the manufacturer and model of the device. Next, the sensor's own parameters, called Registration Key, are entered. In addition, in this case, the value of "airqualitysensorusmcc" was added to the parameter End Device ID, and Register End Device was pressed. Once registration is complete, go back to the applications tab, and in the end devices, one can enter the newly created one. Finally, being inside the added device, it is possible to enter the side menu section Integrations and then MQTT, where the subscription data to the broker of the things network, data that will be used in the application layer to visualize the data.

Cloud Service
There are different service providers for the cloud layer (middleware). The major public service providers include Amazon, Microsoft, and Google [30,31]. Being leaders in the market, it is observed that the services are similar in almost all the services they provide. Due to the difficulty in calculating the costs associated with the service (the charge is made per hour of use and depends on the capabilities contracted), particularly when the project starts and the requirements can change; therefore, it was decided to use the service of virtual machines of Digital Ocean [32].
For this layer, a Raspberry Pi with the Raspberry Pi OS operating system is used, which is loaded into a micro-SD memory by downloading the installation software from (https://www.raspberrypi.com/software/ (accessed on 10 January 2022)), choosing the procedure to install and selecting the memory micro SD to use in the aforementioned Raspberry Pi. For later configuration, the system is accessed using a display with HDMI input and a mouse to activate the option to allow the connection by the SSH protocol. After doing this, it simply connects to the local network via the Ethernet cable. Then, on a computer within the same network, the connection is made via SSH (considering that the IP of the Raspberry Pi is 192.168.2.2).
Once the computer is connected to the Raspberry Pi via SSH, Mosquitto is installed as the selected MQTT broker [33]. Then, Node-RED is installed, with which the data is managed locally, following the official page's recommendation (nodered.org). To access the node-red programming palette, it is enough to be within the same local network of the Raspberry Pi and go to http://192.168.2.2:1880. Then, once inside the programming palette, the division is made into 3 flows that correspond to smart plugs (see Figure 7a), the metering device alternating current (see Figure 7b) and the direct current measuring device (see Figure 7c). In the 3 flows, MQTT data is received from each device and forwarded using the same protocol (MQTT) to the server hosted at Digital Ocean. the project starts and the requirements can change; therefore, it was decided to use the service of virtual machines of Digital Ocean [32]. For this layer, a Raspberry Pi with the Raspberry Pi OS operating system is used, which is loaded into a micro-SD memory by downloading the installation software from (https://www.raspberrypi.com/software/ (accessed on 10 January 2022)), choosing the procedure to install and selecting the memory micro SD to use in the aforementioned Raspberry Pi. For later configuration, the system is accessed using a display with HDMI input and a mouse to activate the option to allow the connection by the SSH protocol. After doing this, it simply connects to the local network via the Ethernet cable. Then, on a computer within the same network, the connection is made via SSH (considering that the IP of the Raspberry Pi is 192.168.2.2).
Once the computer is connected to the Raspberry Pi via SSH, Mosquitto is installed as the selected MQTT broker [33]. Then, Node-RED is installed, with which the data is managed locally, following the official page's recommendation (nodered.org). To access the node-red programming palette, it is enough to be within the same local network of the Raspberry Pi and go to http://192.168.2.2:1880. Then, once inside the programming palette, the division is made into 3 flows that correspond to smart plugs (see Figure 7a), the metering device alternating current (see Figure 7b) and the direct current measuring device (see Figure 7c). In the 3 flows, MQTT data is received from each device and forwarded using the same protocol (MQTT) to the server hosted at Digital Ocean.

Application Layer
The application layer is entirely supported on a virtual machine contracted with the services of Digital Ocean. The system supports a machine with 2 Gb of RAM and 50 Gb of hard disk. To acquire these services, one must enter the provider's page https: //www.digitalocean.com/go/developer-brand (accessed on 10 January 2022) AND must be registered (considering that a valid credit card must be included during the registration process). After logging in to the page, a new project is generated, which, in this case, is called IoTPlatform4ManageEnergy and then the create button is pressed to create a new Droplet which is the way that Digital Ocean calls virtual machines, and this is created with 2 Gb of RAM, 50 Gb of hard disk and the Ubuntu 20.04 operating system is installed (LTS) x64. Once the Droplet has been created, it can be accessed with the fixed IP provided by the provider (165.232.139.50) via SSH. The Mosquitto broker was installed on this server to define communication via MQTT. In addition, Node-RED is installed to manipulate the data, and MySQL is installed to allow data storage. Figures 8 and 9 show the configuration for Node-RED for control and data visualization, respectively.

Application Layer
The application layer is entirely supported on a virtual machine contracted with the services of Digital Ocean. The system supports a machine with 2 Gb of RAM and 50 Gb of hard disk. To acquire these services, one must enter the provider's page https://www.digitalocean.com/go/developer-brand (accessed on 10 January 2022) AND must be registered (considering that a valid credit card must be included during the registration process). After logging in to the page, a new project is generated, which, in this case, is called IoT-Platform4ManageEnergy and then the create button is pressed to create a new Droplet which is the way that Digital Ocean calls virtual machines, and this is created with 2 Gb of RAM, 50 Gb of hard disk and the Ubuntu 20.04 operating system is installed (LTS) x64. Once the Droplet has been created, it can be accessed with the fixed IP provided by the provider (165.232.139.50) via SSH. The Mosquitto broker was installed on this server to define communication via MQTT. In addition, Node-RED is installed to manipulate the data, and MySQL is installed to allow data storage. Figures 8 and 9 show the configuration for Node-RED for control and data visualization, respectively.  The schematic diagram for the complete system is shown in Figure 10. The experiments were carried out on 11 November 2022. Different electric appliances in the laboratory were connected to validate the operation of the platform (Plug01: Hair Drayer-SiEGEN-Model SG-3049, Illumination: Led bulb-9W, Desktop Computer: TV Monitor-LG-24TL520S-PS). The dashboard, shown in Figures 11-13, shows an example for those observed from a computer; since Node-red is responsive, the visualization can adapt according to the display device, such as a smartphone or a tablet. Furthermore, with the implementation of the MYSQL database interaction block, the data is saved in the cloud.   Figures 11-13, shows an example for those observed from a computer; since Node-red is responsive, the visualization can adapt according to the display device, such as a smartphone or a tablet. Furthermore, with the implementation of the MYSQL database interaction block, the data is saved in the cloud.   Figures 11-13, shows an example for those observed from a computer; since Node-red is responsive, the visualization can adapt according to the display device, such as a smartphone or a tablet. Furthermore, with the implementation of the MYSQL database interaction block, the data is saved in the cloud.

Discussion
This section provides a detailed analysis of the proposed IoT platform for building implementation and the future extension for large-scale performance on the university campus.

Analysis
The advances in IoT technologies will play a vital role in the development of different smart building solutions, such as smart lighting to minimize light load, smart HVAC to improve indoor comfort, smart plug loads to monitor and control usage, and smart energy management systems, toward achieving an intelligent campus. Among the key technologies which have been investigated in this work are smart plug loads to monitor and control various types of appliances (located in offices, labs, and classrooms), distributed energy resources including a PV system, outdoor data using a meteorological station, and indoor air quality monitoring. Detailed technical hardware/software configuration and implementations have been discussed, as well as the network connectivity among different subsystems. As real-time data monitoring is the first step toward transforming conventional buildings into smart buildings, the proposed solution will enable the building operator to view, analyze, and predict different appliance profiles and the occupancy of the buildings using a dashboard to visualize such real-time/historical data and alerts.
With respect to the cost, the proposed solution uses off-the-shelf components. The main electronic components used were Sonoff POW R2, PZEN-004T-100A, Raspberry Pi 4B, and Dragino LAQ4, which cost about CLP 20.900, CLP 26.812, CLP 78.390, and CLP 51.899, respectively. The total hardware cost of the proposed solution can be adapted for the university campus to support real-time data monitoring for power consumption from different buildings and environmental data with the objective of improving energy performance and building operation.
Given the experience gained during the development of the proposed IoT platform, the following are the guidelines that need to be considered for developing such a solution (in Chile or another region) that fits the user's requirements.

•
Definition of requirements and services: This allows knowing the main problems and defining the objectives to be achieved during the full development of the proposed solution following the requirements: • Define a network architecture for smart sensors and meters. Structure a network architecture that connects nodes, gateways, and servers seamlessly and efficiently to measure real-time electricity consumption and transmit the information obtained for the end-user. • Develop a cloud storage server. This allows data storage and access to the information stored from anywhere through an API. • Develop a platform for visualization. This platform enables the visualization of realtime data from each device/appliance connected to the platform.

Technology Adoption
The way toward an intelligent campus requires the acceptance of new technologies and the opportunities they provide. User perceptions on the acceptance and adoption of smart energy management in the workplace is an essential aspect that needs to be investigated [20,21,34]. In this regard, the work in Ref. [20] identified different types of behavior change interventions that are successful in saving energy in the workplace, such as education, persuasion, incentivization, and training. Another study in Ref. [21] proposed seven design implications that guide the future design of smart energy management systems in the workplace, including internal and external influence, user appeal, user control, ease of use, reliability, personalized and contextualized information, and data privacy. Among the open research topics are conducting a large-scale study in multiple countries (different geographical contexts and cultures) to identify overlaps in user perceptions. In addition, expanding the scope for other workplaces such as hotels, retail stores, and industrial sites [21].

Future Direction
There are different directions to extend the current work. From the power layer point of view, we aim to extend the current prototype to support an electric vehicle charging station, a battery storage system, smart lighting (dimmer lights and lights coupled with motion sensors), sensors for motion detection, and magnetic sensors for the doors. From the data acquisition layer point of view, our ongoing work aims to develop a low-cost meteorological station using off-the-shelf components to be able to access and control the data obtained. From the communication network layer point of view, heterogeneous communication technologies could be integrated to support different short-/long-range communications across the campus.
As a short-term goal, we aim to demonstrate the feasibility of the proposed IoT platform in one complete building to collect power consumption data during the whole semester with everyday activities and during the vacation period. Before implementing such a system, two different dashboards need to be developed: one for the end-user, who can control their plug loads, and the other for the building administrator. There is also a need to define which control strategy should be selected, which can be a manual or predefined schedule. In this regard, the authors in Ref. [19] performed different plug load automation strategies for a university office space which could be a starting point for the office scenario.
Other challenges are related to the internal electrical wiring for the building, as each floor may share various offices and laboratories from different departments. In addition, the absence of historical power consumption data for buildings/floors/zones. Therefore, historical power consumption data will need to be collected from the main electric panels using smart meters for individual rooms/zones. This step is essential to define spaces with high energy consumption. Based on energy consumption data from different floors/areas, the performance will be evaluated before and after applying different plug load management strategies. Special attention should be given to privacy and security, which should be considered at every step during the platform design. Emerging technologies such as blockchain, machine learning, and artificial intelligence are opening new opportunities to mitigate such security vulnerabilities.

Conclusions
This work proposed a cost-effective IoT solution for smart buildings to enable remote monitoring and control of power consumption at the appliance level. The proposed architecture consists of four layers: power layer, data acquisition layer, communication network layer, and application layer. The physical layer was characterized by different subsystems such as plug circuits, lighting, and the photovoltaic system. For the acquisition layer, measurement devices were used for electrical panels, smart plugs, direct current energy metering devices, air quality monitoring, and a meteorological station. The network layer was defined to gather the information captured from the physical layer and forward it to the remote server. A fog layer was implemented on a Raspberry Pi, and the data was handled with NodeRED. The communication technologies defined to obtain the information from the installed equipment were WiFi and LoRa, and the communication protocol to the server was through the MQTT. The Digital Ocean Droplet service was used as a server where the MQTT Broker was installed. For data management, NodeRED was installed for the general management of the data messages and the visualization by the end user. MySQL was installed, which allows storing the information in tables that were defined for each data acquisition device. This project was implemented using a testbed defined to characterize equipment and conditions in three different locations in Engineering Building, Universidad Técnica Federico Santa María, Valparaíso, Chile, including an office, a classroom, and a laboratory. This testbed allowed the design, implementation, and testing of the complete system in reduced space. At the end of the development of this work, a functional platform was obtained that brings together energy consumption data that will contribute to energy awareness and conservation. For the energy measurement device, pzem-004t-100a equipment has been selected, as shown in Table A2. In the case of the temperature and humidity measurement device, significant similarities are observed in the characteristics of all the proposed alternatives. Dragino LAQ4 has been selected, which reads the most number of variables, as shown in Table A3. Table A4 shows the alternative gateway that allows obtaining the data from the LoRa sensors, where minor differences are observed between each device. Since the LG308 LORAWAN gateway is available in the laboratory, it has been selected for this work.   22 October 2022); ** https://altronics. cl/sensor-temp-hum-zigbee-sonoff (accessed on 22 October 2022); *** https://sonoff.cl/pack-interruptor-diysonoff-th16-sensor-de-temperatura-y-humedad-am2301/ (accessed on 22 October 2022); **** https://altronics.cl/ sensor-calidad-aire-laq4?search=LAQ4 (accessed on 22 October 2022). The proposed alternatives for the local computing device with its main hardware characteristics are summarized in Table A5. Considering the highest percentage of the connectivity item and the cheap cost of the device, the Raspberry Pi 4B was chosen as the local computing device.  Figure A1a shows the setup of the smart plug device, while Figure A1b shows the setup of the module pzem-004t-100a. Figure A1c shows the configuration of the solar panel measurement device. The CT sensor must be connected by wrapping the positive cable of the panel, and the terminals of voltage test (brown → ground and red → VCC) are connected in parallel to the current bus of the photovoltaic panel system. Figure A1d shows the configuration of the Dragino LAQ4 device. Figure A2 shows the data obtained using the weather station.  Figure A1a shows the setup of the smart plug device, while Figure A1b shows the setup of the module pzem-004t-100a. Figure A1c shows the configuration of the solar panel measurement device. The CT sensor must be connected by wrapping the positive cable of the panel, and the terminals of voltage test (brown → ground and red → VCC) are connected in parallel to the current bus of the photovoltaic panel system. Figure A1d shows the configuration of the Dragino LAQ4 device. Figure A2 shows the data obtained using the weather station.