Keywords

1 Introduction

Currently the energy consumption in home is high, this consequence of a very low energy efficiency, which translates into a high impact on the environment, this makes necessary to have a greater degree of control over the electrical devices used in the home. In the beginning, domotic was restricted to be a tool at the hand of the user, providing the ability to make some adjustments on the house like turning lights on or off, or setting timers, however, the technology has advanced very quickly and domotic has been assigned more complex tasks over the years.

In the current market you can find different advances in terms of safety, energy and comfort, like intelligent cameras that brings the opportunity of access their images in real time from anywhere in the world, another of the great aspects in which domotic has evolved in terms of security, is being able to control the doors, windows and blinds of the home through an Internet connection [1, 2]. One of the most important features of home automation and one of its main characteristics is the ability to control different appliances in the home that directly influence energy consumption, in areas such as air conditioning and lighting, all this in order to generate energy savings and have a better use of the resources [3, 4]. One of the major trends in terms of home automation is the use of personal assistants such as Google Home, or Amazon Alexa, this type of devices have the ability to recognize voice commands from the user and receive direct commands from it, although one of its main features is the ability to control different devices on home [5, 6].

The objective of this paper is present the implementation of an artificial neural network in an embedded system for the characterization of electrical loads for the management of electrical demand in a domotic system and present the algorithms necessary to carry out the control of a house for a traditional family.

2 State of the Art

Studies related to domotic systems based on demand management or load connection/disconnection control systems are presented. Widely used systems share similar characteristics such as hardware definition for communication protocols, load control system (contactors or solid state), temporization for the connection/disconnection of the different electrical devices.

In the first instance [7] addresses the problem of excessive consumption of electrical resources in the home and raises the need to implement automation systems on a massive scale.

The most basic aspect of home automation is the ability to control one or more aspects of the home, such as turning on/off lights or devices connected to the electrical network, [8] and to be able to provide information on basic aspects such as temperature, humidity [9] and in some cases more detailed information such as light intensity, motion detection and magnetic fields to detect the opening of doors or windows [10]. In the research work of [11] the implementation of a traditional domotic system using KNX technology is carried out in a 67 m2 house. This system, although reliable, becomes obsolete when compared to technological proposals such as the one carried out by [12]. In its research work, the implementation of a decentralized on/off system is carried out, using ESP8266 modules connected through a wireless network, which allows a greater level of flexibility and ease of implementation, all this together with a lower total cost of the system.

One of the areas where domotic has greater capacity for evolution, is in automatic decision making, providing the domotic the ability to decide which electrical devices are connected to the electrical grid, allows a more precise control over the electricity consumption of the home. Different approaches to this idea have been made in the literature and proposals have been found that have the capacity to generate electricity savings, [13] in this work, he carries out a system of scheduling of electrical charges, with which he manages to make the appropriate use of the photovoltaic resource that a home has, making use to a lesser extent of the home electrical network, however, a variety of works have been found in which the objective is to carry out a system that can classify electrical charges on the basis of their voltage and current signals, [14] makes an approach to this idea, making use of Artificial Neural Networks achieves the identification of fundamental characteristics in a radio signal, for its part, [15] develop a system with the ability to correctly identify a cooler using an ANN trained solely from the power data of the device, [16] makes a similar system, however in its development are used the general consumption data of the house and with the use of the transformed Hilbert-Huang achieves a correct characterization of elements with high energy consumption such as the washing machine, clothes dryer and refrigerator.

The proposed home automation system will characterize and identify electrical loads, which can identify an appliance and its mode of operation (full load or low consumption). The characterization uses electrical parameters that model the different loads from their characteristics in power, harmonic distortion among others. The demand management uses the information of the appliances connected to the network and establishes their mode of operation, those in low consumption are disconnected after their identification. The ecosystem is made up of outlet modules, switch modules and a master module where the actions that depend on the identified appliance are defined. The activation of the loads will be carried out with solid state power electronic devices.

3 Materials and Methods/Methodology

3.1 Embedded System

An embedded system was development, which allowed the acquisition of voltage and current data of each one of the most common household appliances, and then these data were used to extract the electrical parameters that allowed differences between the several appliances and their states of consumption.

Hardware.

The selection of the platform carries out to meet the needs of the development phase and that could be used as a final product. The requirements were raised, an embedded system that can have readings on voltage and alternating current (AC), that counts on different means of wireless communication, for its later implementation in a domotic system, that count with great capacities of memory and a high power of compute for the implementation of the system of characterization. Having as main objective a low-cost platform, easy in the implementation of a wireless communication network with a high level of processing and enough memory capacity. The development platform selected was the ESP32, given that its low price, has a powerful dual core processor Xtensa LX6 32 Bits at 240 MHz, 4 MB flash memory for the program and 540 KB of integrated RAM, WI-FI b/g/n and Bluetooth 4.2 Low Energy integrated and the ability to perform analog voltage reading with a resolution of 12 Bits. Other platforms with similar characteristics have the disadvantage of being more expensive, making it impossible to develop a low-cost system.

In the data acquisition phase, voltage and electrical current samples were taken from the most common household appliances in the home. To perform this task, circuits were implemented to couple these physical magnitudes to the working ranges of the ESP32 platform, and a storage system was implemented through an external SD memory connected to one of the SPI modules available on the development platform.

The last requirement of the embedded system was to provide it with the ability to control on and off on the load that was connected to it, for this was designed and implemented a control system, using a triac BTA20 semiconductor device.

Software.

The first stage of the project consisted of collecting voltage and current data from the most commonly used appliances in the home, to fulfill this purpose the necessary hardware was developed and an algorithm was developed, which was intended to perform the storage of this information in an SD memory using parameters previously specified, these parameters are, have the ability to generate a text file for each appliance analyzed, the data was taken at a fixed frequency of 1 kHz.

Data Acquisition.

The acquisition of voltage and current data of the most commonly used household appliances and their characteristics as model, manufacturers and type are presented in the Table 4.

3.2 Electrical Characteristics

Taking as information the voltage and current data collected from household electrical devices, a correct differentiation must be made between the different types of devices recorded, but just analyzing this information is not possible to give a correct analysis, it is necessary to have electrical features from these signals that provide information, allowing the classification of different household devices. The following features were used: Instantaneous Power (P), Maximum Power (PMax), Distorted Power (D), Power Factor (Fp), Reactive Power (Q), Apparent Power (S), Offset Angle (\( \phi \)), Total Harmonic Distortion (TDH), Current Variance (\( \sigma_{n}^{2} \)), Root Mean Square (IRMS) [17].

3.3 Learning Machines

The learning machines are computational techniques used to develop prediction algorithms based on data samples, there are different classification techniques which are divided into two classes, unsupervised learning machines and supervised learning machines [18].

In the training process of all classification methods used, (Cross-Validation) was performed, defined by [19] As the process of making a random separation of the input data and their corresponding outputs to make use of part of the data for system training and with the remaining data to perform its validation. In the implementation three types of learning machines were analyzed, which will present ease in their development in an embedded system, the types of machines used were: Neural networks, decision trees and K nearest neighbors.

An artificial Neural Network (ANN) is a mathematical abstraction of the process of communication and information generation of physical neural networks. One type of implementation of artificial neural networks widely used are the multilayer perceptron MLP (Multi-Layer Perceptron), this are an evolution of the single-layer neural network, its operation is based on the use of a series of hidden layers, which is ideal for solving non-linear problems [20] a MLP is formed by at least 3 layers, the first is the input layer, this is where the data is received to be used by the ANN, the second layer is part of the group of hidden layers being necessary to have at least one layer of that type and finally has the output layer which delivers the data generated by the ANN [21]. Equation 1 is a mathematical representation of a neural network, where x are the inputs to the neuron, w is the matrix of synaptic weights and b is the value of the tracks [22].

$$ y = f\left( {x \cdot w + b} \right) $$
(1)

3.4 Implementation of the Load Characterization System on the Embedded Platform

The implementation of the load characterization system consists of providing the embedded system with the ability to take voltage and current data to perform the electrical feature extraction, making use of these electrical features in the process of generate a result using the ANN previously trained, the training is done on a desktop computer. When the training process ends, the information of the synaptic weight matrix, bias value, network topology and characteristic normalization values are transferred.

To execute the neural network, a series of for cycles are used to realize the calculation of the output of each one of the neurons, in total 3 for cycles was used, the first one to go through all the layers, the second one used to go through all the neurons on a layer and the last one to do the calculations for all the inputs on a neuron. The output of each one of the neurons is evaluated on the activation function.

3.5 Implementation of Control Algorithms

Considering the capabilities of the hardware used, algorithms are implemented that can control the lights and outlets of the house.

To make the control of the lights it is used as base the information of a sensor of presence by radio frequency and the hour of the day, if the hour is between the 6 PM and the 6 AM and the sensor detects movement it makes the ignition of the light by a short period of time. On the other hand, if an acoustic signature (applause) is detected and the light conditions warrant it, the light is switched on for a slightly longer period. Finally, if the touch sensor is used and the light conditions warrant it, it is switched on for a period of 30 min, in this way the light can be precisely controlled according to the user’s needs and allowing the maximum possible savings to be generated.

The algorithm to control the lights is quite simple, because having the ability to know precisely which device is connected to each socket gives the freedom to make a very fine control without the need for a complicated algorithm. If the connected device charges a battery (cell phone, laptop computer), the system can recognize when the device is fully charged and can disconnect the device to not generate consumption per standby.

Because the system can recognize when a device is in standby mode, it can disconnect those elements that are not being used but generate a parasite charge, such as computers and televisions, which generally remain connected 24 h a day and generate a high electrical consumption.

Finally, the system can recognize certain heavy loads that should not be on for long periods of time such as blenders and irons and this in the ability to generate an alarm to the user or disconnect the load in order to keep the consumption low.

4 Results and Discussion

The Table 1 shows the average values of each of the features of all household appliances, the value in brackets corresponds to the standard deviation of the value of each feature.

Table 1. Average and standard deviation of the electrical features used.

A Decision Tree classifier was trained because this algorithm has a low computational cost. It was implemented using conditionals and basic mathematical operations. Cross validation results in an error rate of 23.4%. The decision tree is implemented in the embedded system and its operation is verified, obtaining as a result, that the system does not have the capacity to carry out the correct characterization of the electrical appliances that present strong variations in their electrical features, due to the fact that this classifier uses the definition of thresholds, therefore it does not have the capacity to identify correctly elements that produce high levels of noise and cannot use features that have a high level of variation such as reactive power and current variance.

A k-Neighbor closer KNN classifier was trained. This classifier is a much more robust system than the decision tree and had an average error rate of 1.1538% and a standard deviation of 0.7278%, however, its implementation requires 38 KB of volatile memory and very long execution times which makes it impossible to implement in an embedded system.

The ANN training process was carried out and a list of values of synaptic weights, biases, values for data normalization and activation functions was generated. Different network topologies were used, which implied different capacities in the size of bytes to use number of neurons to use, the Table 2 shows the results of the different trained topologies. The topology with two hidden layers, each with 10 neurons, provides an average error level of 2.051% and a standard deviation of 1.2385%, without greatly compromising system memory and execution times. An adjustment was made to the KNN classifier, approximating the value of volatile memory that consumes to the values of use of the artificial neural network, this in order to appreciate under equal conditions which classifier presents a higher performance, it was found that the KNN presents error levels higher than the artificial neural network, this information is shown in the Table 3.

Table 2. Tests performed on different neural network topologies. Source Authors.
Table 3. Comparison between different classifiers.

The artificial neural network implemented in the embedded system made it possible to evaluate the signal establishment times of the connected appliances, the average times was 4.5 ± 2 s.

The demand management proposed for use in an intelligent home automation system, with the ability to recognize that appliances are connected to the system and to exercise control actions that ensure low electricity consumption, without making major effects on the user, requires a correct characterization and identification of the electrical loads connected to the system. To evaluate the proposed system, a simulation is carried out based on the time that the devices remain connected to the electrical network and what would be the consumption without load management actions what we call normal consumption, a load management based on traditional domotic systems and load management, where the characterization of the household appliances is used as a basis for intelligent demand management. The results of this simulation and the corresponding reduction in terms of carbon dioxide production are presented. Simulated systems include the electrical consumption of demand monitoring and management devices.

The Fig. 1 shows the result of simulating a home using a home automation system with load characterization, a traditional home automation system with finely adjusted timers and a home without any type of home automation control. From the figure it can be extracted that by means of the use of a domotic system with characterization of loads an average saving of 34% can be achieved compared to a house without any type of control and 12% compared to a traditional domotic system with a complex configuration of timers.

Fig. 1.
figure 1

Simulation of monthly consumption per system used.

Considering the consumption obtained with each of the simulations, it is possible to reflect this electricity consumption in an annual cost, which corresponds to the value in USD to be paid with each of the proposed systems. In the Fig. 2 you can see the graphical representation of the costs, for this simulation we took as a base the cost of a Kw/h in New York City, which corresponds to $0.18 USD. From this information it can be concluded that the use of a domotic system with load characterization can generate annual savings of approximately $137 USD.

Fig. 2.
figure 2

Simulation of the cost of the electric bill in one year.

Based on the results of the energy consumption it was possible to make an analysis on the generation of Co2 based on the domotic system used, it can be seen in the Fig. 3 that using the domotic system with load characterization could generate savings of approximately 280 kg of Co2 per year.

Fig. 3.
figure 3

Simulation of the amount of Co2 generated in a year

It is also necessary to carry out an analysis of how long it would take to recover the investment of a domotic system, a traditional domotic system for use in the proposed home would have an average cost of $4000 USD, considering the energy savings provided by this investment would be recovered in an average of 42 months. In comparison the domotic system with load characterization has an approximate cost of $1000 USD and thanks to its low cost and better level of energy savings the investment could be recovered in an average time of 8 months.

5 Conclusions

It is concluded that load characterization is a vital tool to develop domotic systems with a high level of automation and allow high levels of energy savings.

It is necessary to emphasize that, although with a traditional domotic system you can obtain energy savings, it is necessary that the timers of the system are configured taking into account the routines and activities of the family and although a considerable saving is achieved, the system is more rigid and affects the comfort of the users to a greater extent.

Using basic algorithms, it is possible to generate a precise control of the elements of a house, allowing to generate energy saving without affecting the level of comfort of the user and keeping the costs low.

The implementation of mathematical and statistical tools, such as learning machines for the process of characterization of electrical loads require an adequate definition and selection of technical and economic specifications for implementation in embedded systems or low-cost development systems.

Traditional domotic systems base their operation on actions taken completely by the user without any type of autonomous decision making. The characterization of electrical loads offers the opportunity to develop intelligent domotic systems that execute advanced control actions on a house.