Abstract
With the growth in power demand, energy management is an important issue in the 21st century. This article proposes a smart power management framework system, which comprises three parts. Part 1: a smart plug. Controlling the switching power supply, different sensors can be mounted for different application environments. The power supply can be switched on/off automatically according to environmental changes. Added to this, it can measure voltage and current for analysis. Part 2: a smart gateway. This can act as the mediation module for communication and implement the concept of fog computing. The local inference model is built and deployed by deep learning, and the model is learned, updated, and improved continuously to increase the intelligent control efficiency. Part 3: a management platform and mobile app. This allows for data visualization and a remote control for a user interface medium for scheduling. The smart plug and smart gateway are integrated into the overall distributed sensor network, analyzing and improving the power consumption effectively. Finally, the feasibility and practicability of the overall power management framework system are described experimentally.
Keywords
Introduction
Green energy is a new trend in the world, as well as the inevitable evolutionary process for human society. Energy is the most important matter in our society; it is a key factor supporting our future life and quality. With the expanding economy, power demand increases steadily, and the shortage of power resources becomes more severe. In order to avoid a power crisis, besides developing high-efficiency power generation technologies, how to design energy-saving systems effectively becomes an important subject. The smart plug is convenient for monitoring and controlling electrical equipment. It is one of the solutions to energy-saving system design.
With the rapid development of the Internet of Things (IoT), increased attention is being paid to the smart plug in the present consumer market. Many household appliances have become intelligent; their on/off switches can be timed for saving energy to meet the users’ requirements. However, many household appliances cannot meet these requirements, so the smart plug emerges accordingly.1–9
All of the studies regarding smart plugs have two important components, hardware and a management platform. For hardware, the measured data of voltage and current are collected and sent via communication modules, such as Wi-Fi, Zigbee and Bluetooth, to the management platform for subsequent data analysis. The user employs smart devices (mobile phones/pads) or webpage apps for remote control use or scheduling to implement effective energy management. Our paper proposes a smart power management framework system. Besides the hardware and management platform, the concept of a smart gateway or fog computing, which is in Bonomi et al., 10 is imported. The data are collected using a gateway device and fed back for the adjustment of different building power consumption characteristics by the learning mechanism or deep learning of an artificial intelligence neural network, such as Mocanu et al. 11 In the concept of the IoT, there is a fog computing function with location awareness. Adjusting the data analysis in the IoT on the local side according to the actual situation is a trend. Each piece of equipment has a different state and ability; the ability of a local inference model can be built and deployed by a smart gateway. The model is learned, updated, and improved continuously for the service condition of local equipment so that the smart power management framework system is more efficient.
The contribution of this article is a power management framework system with continuous learning. The smart plug is equipped with a sensor that can be switched on/off automatically according to the environment, and the sensor can be changed at any time for different environments. Added to this, the deep learning model is imported into the gateway with location awareness which is the concept of fog computing. Fog computing and cloud computing are integrated, and the data are analyzed and fed back effectively, performing the spirit of distributed sensor networks.
The remaining parts of the article are organized as follows. In section “Related works,” related works are discussed. Then, an intelligent power monitoring and analysis system is proposed in section “Power management framework system.” In section “Experimental results,” we demonstrate our experimental results. Finally, we state our conclusion and future works.
Related works
Smart plug
In the consumer market, the DSP-W215 Wi-Fi smart plug released by DLink 1 has functions such as turning devices on/off with a mobile app, creating on/off schedules for devices, helping prevent devices from overheating, and monitoring energy use. Similar products are the Wi-Fi smart plug, 2 smart Wi-Fi socket, 3 and home monitor plug. 4 The advanced smart plug is integrated with voice control functions, such as the TP-Link smart plug 5 and Belkin Switch, 6 which are integrated with Amazon Echo Voice Control. 7
Communication protocol on smart plug
Shajahan and Anand 8 proposed a smart plug, a power monitoring system providing real-time updates. The smart plug uses an Arduino microcontroller board, an ENC28J60 Ethernet module, and a current transformer (CT) sensor. The equipment data are uploaded to the server via Ethernet. The power consumption can be monitored remotely by an Android. However, the communication component of smart plugs is wired, which is not ideal in an increasingly wireless world.
Zigbee is a short-range wireless network technique laying stress on low power consumption. The transmission rate is 20 k–250 kpbs. Zigbee is used extensively, usually in smart home integration. Elma et al. 12 used Zigbee protocol in a smart plug as the communication bridge. It can monitor the voltage, current, power, and the power consumption record of electrical appliances, and it sends data to a home energy management (HEM) system reducing peak demand at home. However, the Zigbee communication protocol cannot communicate with a tablet or a smart phone directly and cannot be linked to the management platform directly. A gateway is required for connection and control.
Bluetooth low energy (BLE) technology has been a component of Bluetooth core specifications since Bluetooth v4.0. The Bluetooth low energy enables the Bluetooth wireless connection to be used at a low cost with low capacity batteries and equipment requiring the battery to keep working for several months or even several years. BLE can allow for a lot of new extended application benefits from Bluetooth wireless technology, including a smart watch, proximity smart card, sports and exercise sensor, medical care sensor, and remote controller. The smart plug also uses the communication capability and low power consumption of BLE to integrate a tablet or a smart phone effectively without any requirements for additional gateways. Horvat et al. 13 used BLE to implement a smart plug function and provided a complete solution for controlling and monitoring household products. The equipment can be controlled directly by BLE via a tablet or a smart phone. Added to this, the smart plug provides application interface (API) control and power consumption measurement based on the Generic Attribute Profile (GATT). This solution enables the user to monitor different power consumption parameters and implements a delay control built-in timer and power limitation by use. Choi et al. 14 used BLE beacons to integrate the smart plug with a mobile app, providing location-aware energy-saving service and implementing an intelligent office energy management system. This system can save on the energy consumption of PCs, displays, and lamps effectively. For integrating a tablet or a smart phone, BLE is a good option. However, the data payload and data rate of BLE are limited.
To integrate the whole building network, the Wi-Fi solution is another technology to be considered. Sanchez et al. 15 proposed a modular system for remote monitoring and control of energy consumption. Multiple smart plugs and a centralized application server are connected using Wi-Fi communication technology. Real-time monitoring of energy consumption is implemented by remote monitoring and controlling of the schedule. This monitoring and control lead to a significant cost reduction and to a sustainable management of energy resources beneficial for the environment. In this article, we select a Wi-Fi solution to connect the overall power management system. Sustainable energy management can be expected.
Energy management system
Considering the power demand and energy-saving concept, another topic is how to increase power utilization efficiency. Energy use can be controlled by the latest technical development. Morsali et al. 9 proposed a smart plug device and a building energy management system (BEMS). These smart plugs can recognize different household appliances and measure power consumption more accurately according to the different equipments. A framework is proposed to control the building system by a monitor and effectively save energy.
In the home application, this system is known as the HEM system.12,16–19 Thongkhao and Pora 20 proposed a smart plug, which could control electrical products and monitor energy consumption remotely via Wi-Fi. With the developed webpage app, the user has knowledge of the conditions and can easily control electrical appliances. A bi-stable (latching) relay is used in the smart plug for zero consumption of the relay coil when it is stable. Wi-Fi is a suitable communication for HEM.
Cho et al. 21 proposed an intelligent office energy management system by analysis in hyper-connected-IoT environments. The system includes a server, gateway, and smart plug through Ethernet and Zigbee communication protocols. The authors use the Pearson correlation coefficient formula and normal characteristics/indicators to measure the user-device intimacy. The experimental results show that more energy can be saved than from existing scheduling-based energy management system. The concept of this system is that it links data, IoT, and space. However, the information from the data focuses on the users and devices, with no consideration of the environmental effects of other factors (such as light, thermal values, humidity).
Data analysis of smart plugs
It is impossible to collect the types and energy consumption characteristics of all electric appliances in the world. The appliance consumption signatures (ACS-F2) database provided by Ridi et al. 22 includes different brands and/or models of electric appliances for 450 electric signatures derived from smart plugs. The database provides two evaluation protocols for the benchmark test for the system which can recognize electric appliances according to the electronic signatures. Ridi et al. 23 proposed two additional evaluation protocols to analyze the effect of the window length. The machine learning method is used to display current optimal results on the four protocols. These data are analyzed in the background; they cannot be immediately fed back to the user. However, the analysis results aim at global data; they do not analyze specific buildings or places.
This article uses a gateway device to collect data. The model is learned, updated, and improved continuously for local equipment service conditions by deep learning, so that the smart power management framework system is more efficient. The data feedback to the management platform is a global analysis, reasoning the major direction of decision making. The power consumption characteristics of different buildings are trimmed by smart gateway. Thus, a continuously learning power management framework system is formed.
Power management framework system
This article proposes a smart power management framework system, which comprises three parts: a smart plug, smart gateway, and management platform with a mobile application.
System overview
This article demonstrates the design of a smart plug module, which is different from general ones because of its sensors, such as a thermal sensor, light sensor, PM2.5 sensor, and humidity sensor. Any energy-saving decision can be controlled by the smart gateway or remote management platform receiving the user’s command, and the smart plug implements an energy-saving decision mechanism automatically according to the real environment conditions without human intervention. This is more economical and practical than the scheduling-based energy-saving control on the open market. Added to this, the smart plug has a voltage and current monitoring function. Effective popularization sets up a network for the overall building, replacing the function of a smart meter and reducing the deployment cost. This allows the power consumption data to be recorded more effectively.
The smart gateway is in charge of communication and data collection. It is different from the general gateway by a GPU, where the collected data are used for deep learning model training. This architectural design can implement HPC coupling with background management platform Big Data analysis. The local side smart gateway pre-processes data and uses the deep learning technique for pre-training data. The results are fed back to the management platform, effectively increasing the overall computational efficiency. The smart gateway analyzes data and discovers the power consumption characteristics of the building. As long as the objective set by the management platform is satisfied or attained, the smart gateway can make effective energy-saving decisions on smart plug.
The management platform receives the data from the smart gateway and visualizes the data for the user. The management platform receives all data, analyzes the data, and corrects the decision criteria, which are fed back to the user. A mobile application is provided for the user to control and monitor data and to receive any unusual event notice. The overall architecture is shown in Figure 1.

The overview of a power management framework system.
The design of smart plug
The Arduino UNO 24 is used as the main control module for the hardware design in this article. It is connected to the relay board to control the power switch. The current sensor 25 and voltage sensor are connected to monitor the voltage and current and record energy consumption data. The Wi-Fi module 26 is used as a communication module. Added to this, a control module is provided with I2C, Analog-to-Digital Converter, and Universal Asynchronous Receiver/Transmitter interfaces connecting different sensors. The sensor types include a motion sensor, 27 PM2.5 sensor, 28 humidity sensor, 29 and temperature sensor. 30 Different sensors are used in different scenarios. For example, the dehumidifier is switched on/off automatically using a humidity sensor that can perceive environmental change. Any movement of the object is detected by a motion sensor, and the lighting function is controlled automatically. The hardware block diagram is shown in Figure 2. The control module records the scheduling information according to the users setting. The equipment can be switched on/off automatically according to script. This design is different from that in the general consumer market where the smart plug is embedded with a sensor to intelligently perceive environmental conditions, increasing the energy-saving efficiency.

The hardware block diagram of the smart plug.
The design of smart gateway
In terms of the hardware selection for a smart gateway, an NVidia Jetson TK1 31 is combined with an NVidia Kepler arithmetic core adopted by a global supercomputer. There are four-core ARM Cortex-A15 CPU and 192 CUDA cores. In addition, there is sufficient arithmetic capability, implementing complex data analysis and inference decisions directly on the local side. The data collected by smart plugs are sent to the gateway. The data are compiled on the local side and sent to the management platform. In order to effectively manage network usage scenarios, Jetson TK1 is provided with a Wi-Fi module for smart plugs to build an local area network (LAN) environment. The security is enhanced, and the management and data transfer are efficient. Figure 3 shows the hardware planning and design.

The hardware design of the smart gateway.
Network communication between smart plug and gateway
The devices can be connected by a Wi-Fi module on the smart plug and UPnP-like mechanism. 32 The Wi-Fi module on gateway is used for communication in LAN. The Ethernet interface is used for connecting the management platform. When a smart plug accesses a network, it sends a message “ssdp:discover” by the M-SEARCH (Simple Service Discovery Protocol) 33 port of a specific multicast address. When the gateway listens to the message from the smart plug at the reserved multicast address, the gateway checks the service requested by the smart plug. The gateway responds to the request of the smart plug directly by unicast. If the connection is successful, then the smart plug and gateway can transmit messages to each other. As the communication medium is Wi-Fi, the size of the packets transferred is very flexible. The design of the smart plug transferred data packet format is shown in Figure 4. The length of data transferred is 32 bytes. The identification code is 4 bytes, and the type field is 4 bytes. The sequence number is 4 bytes. A check code field is used to check the packet security at 2 bytes. The current, voltage, duration, and timestamp are 2 bytes, respectively. The device status is 4 bytes. Finally, the reserved field is 4 bytes, reserving flexibility for subsequent changes.

The packet format for communication between smart plug and gateway.
The protocol design of management platform
When the data are collected by gateway, the data are transferred via Ethernet to the management platform. The management platform defines RESTful API, 34 providing an interface for the gateway to send data. In order to enhance the manageability and secure the privacy service quality of the overall platform, this article uses the token-oriented based data transfer mechanism. 35 The data are transferred in the form of a token, effectively guaranteeing the privacy of the data. The management platform is shown in Figure 5. The power management platform shows the information of all registered smart plugs and is only for administrators. Only the users can request their own smart plugs through the token. The management platform records the electricity information, device status (on or off), and sensor data of the smart plug. Administrators can also use the graphic user interface to query information by time period settings. In addition, the power management system can push the collected data from the smart gateway to the training server. Then, the training server can retrain the deep neural network to update the smart gateway.

The management platform.
Continuously learning power management system
A power management learning system consists of two parts: training and inference. When new data are received, continuous learning allows the parameters to be retained and updated according to the content of the data. The gateway receives a new model parameter combined with a local model for fine tuning, so that the decision mechanism is more accurate. Our deep network contains one input layer, three hidden layers, and one output layer for H1 with hidden layers consisting of 20, 20, and 5 nodes, respectively, as shown in Figure 6. The input of these classification models are the five feature vectors (current, voltage, duration, timestamp, sensor data). The activation function adopts ReLU, 36 and the activation function of the former layer of the output layer adopts Softmax. 36 The loss function adopts cross-entropy. 36 The optimizer selects stochastic gradient descent. 36

Deep belief network for decision rule of smart plug.
The management platform implements training according to the existing data and sends the trained model parameter to the gateway. The gateway makes inference decisions according to a pretrained deep neural network model and outputs the table of controlling rules to the smart plug, as shown in Table 1. As the data collected by the management platform are global, the data are not destined to meet local power consumption characteristics. Therefore, the gateway implements fine tuning according to data received, so that the decision model of gateway is more coincident with local power consumption characteristics, making better energy-saving decisions. The data collected by the gateway are sent to the management platform to implement the continuous learning effect for a more robust pretrained model. Figure 7 shows the framework system proposed in this article.
The table of controlling rules for smart plug.

The continuously learning power management system.
Mobile application
This article designs a mobile application based on easy connection, easy monitoring, easy control, and instant notification. The user can implement a simple pairing process via Wi-Fi, easily connecting the smart gateway. When the connection is successful, the devices in service at that time can be seen in the menu, as shown in Figure 8. The data drawing lists can be monitored by clicking one device, as shown in Figure 9. Figure 10 shows a simple control device page for convenient control. Added to this, a message notification service is provided when the device is switched on/off or other events occur, as shown in Figure 10.

The connection flow of mobile application.

The monitoring information on a mobile device.

The demonstration of controlling and notification service.
Experimental results
In this article, the smart plug is used in a dehumidifier to describe the intelligent control concept. First, the humidity changes during a day in Taiwan were surveyed, as shown in Figure 11. The average relative humidity is about 74%. The most comfortable relative humidity for the human body is 50%–60%, meaning a dehumidifier is necessary.

The humidity changes during a day in Taiwan.
A dataset sampled per minute is collected by our hardware. 10,000 data inputs are used as training data. The training data are man made. We labeled each feature vector as being in an on or off state. In other words, we classified the feature vectors into binary classes (on/off). Hence, we can infer the status of the smart plug according to the input feature vectors. In addition, 2000 sets of data are used for testing. The training process runs at 50 epochs. 36 The final loss rate of the training is 0.51%, and the accuracy rate is 99.7%. Information from the training process is shown in Figure 12. The accuracy rate of the testing was 94.87%.

The result of training accuracy rate.
The dehumidifier for this experiment needs about 3 h to reduce the relative humidity from 75% to 58% in a 33 m2 space. To accommodate such a change, we use simple scheduling to set the smart plug to switch the power supply. Without the assistance of data, normal users switch on the dehumidifier when they are not in the room and switch off the dehumidifier when they are in the room or sleeping. This article assumes that the dehumidifier is switched on at 8 a.m. and switched off at 6 p.m. The humidity changes are shown in Figure 13. The effect is bad; the humidity is still high when the person is in the room. Therefore, there must be data references for scheduling, so that the user can wisely set their parameters for the best results. The power consumption of the dehumidifier for this experiment was 208 W (voltage of 110 V, current of 1.9 A), spending 2080 W in 10 h by scheduling, that is, 2.08 kWh.

The humidity changes by scheduling setting.
The ambient humidity is perceived by the humidity sensor on the smart plug so that the dehumidifier is switched on/off automatically. In this article, the dehumidifier switched on automatically when the humidity exceeded 58%, and the dehumidifier switched off automatically when the humidity was lower than 55%. The experimental results are shown in Figure 14. The dehumidifier was switched on for 8 h, spending 1664 W, that is, 1.664 kWh.

The humidity changes by the sensor controlling automatically.
According to these two experiments, for the most intelligent energy savings, the system must have additional information. For example, the optimum time for switching on/off the dehumidifier is based on whether the people are in the room or not. This article develops this system to collect more data, so as to further increase the overall energy savings efficiency. According to current data, the smart gateway sends the decision mechanism to the smart plug to switch on/off the dehumidifier automatically. As for our scenario, the user leaves home at 8 a.m. and returns home at 6 p.m. In the best case scenario, the dehumidifier is not switched on when the person is at home and the humidity is relatively low, as shown in Figure 15. The dehumidifier runs for 6 h, spending 1248 W, that is, 1.248 kWh. The energy savings are better than with a sensor control but the average humidity is worse, meaning the collected data were insufficient. The experimental data for the smart plug and smart gateway are shown in Table 2.

The humidity changes by model inference.
The experimental data of smart plug and smart gateway.
outstanding performance.
Conclusion and future work
The smart power management framework system proposed in this article can actively perceive the environment at the smart plug side for intelligent control. A new system design concept is proposed for collected data analysis and inference. A learning mechanism for fog computing and deep learning is imported. The smart gateway is different from general solutions on the market, using the embedded system with a GPU core. It is generally recognized that this gateway is very costly. In fact, artificial intelligence will be universalized in today’s society. An embedded system with a GPU arithmetic capability will be popular. It means the cost is affordable. Therefore, this system design is trending and will be implemented in the near future.
The current training data only use the humidity sensor information to control the smart plug. The deep neural network model is only used on the dehumidifier. In the future, we could collect more information and consider the effects of other factors (such as light, heat, humidity). A deep neural network could be trained for more diverse application scenarios. For example, we could integrate motion sensors and thermal sensors embedded in the user’s environment, so that the decision model could infer the on/off state of a smart plug more precisely. Added to this, we could develop a suitable mechanism for appropriate timing to update the decision models for the smart gateway, power management, and smart plug. In addition, this power management framework could be popularized to the smart grid effective in the future, from regional integration to an overall state grid, which would be exceedingly helpful for energy saving.
Footnotes
Academic Editor: Miltiadis Lytras
Declaration of conflicting interests
The author(s) declared no potential conflicts of interest with respect to the research, authorship, and/or publication of this article.
Funding
The author(s) disclosed receipt of the following financial support for the research, authorship, and/or publication of this article: This research is financially supported by the Ministry of Science and Technology of Taiwan (under grant nos 104-2221-E-006-119-MY3 and 104-3115-E-194-001).
