A More Efﬁcient Technique to Power Home Monitoring Systems Using Controlled Battery Charging

: Home energy monitoring has recently become a very important issue and a means to reduce energy consumption in the residential sector. Sensors and control systems are deployed at various locations in a house and an intelligent system is used to efﬁciently manage the consumed energy. Low power communication systems are used to provide low power consumption from a smart meter. Several of these systems are battery operated. Other systems use AC/DC adapters to supply power to sensors and communication systems. However, even using low-power technology, such as ZigBee, the power consumption of a router can be high because it must always be powered on. In this work, to evaluate power consumption, a system for monitoring energy usage and indoor air quality was developed. A technique is proposed to efﬁciently supply power to the components of the system. All sensor nodes are battery operated, and relays are used to control the battery charging process. In addition, an energy harvesting system based on solar energy was developed to power the proposed system.


Introduction
Buildings are the largest consumers of energy and a more effective energy management requires real-time data analysis [1,2]. Humans spend a lot of time indoors, so that air quality has a direct impact on overall health [3]. Home monitoring is a key element of a smart house. Two systems are typically employed. The first consists of energy monitoring to control energy usage [4,5] and the other consists of indoor air quality monitoring to improve the quality of life [6,7]. Sensors are used to measure various parameters of interest, and a communications system allows information to be gathered for decision making. Sensors related to energy monitoring measure parameters such as electric current consumption, power consumption, energy consumption, luminosity, movement detection, and acoustic event detection [8][9][10][11]. The major air quality parameters to be measured are carbon dioxide (CO 2 ), carbon monoxide (CO), sulfur dioxide (SO 2 ), nitrogen dioxide (NO 2 ), ozone (O 3 ), volatile organic compounds (VOC), particulate matter (PM), ambient temperature, and relative humidity [6,[12][13][14]. Both monitoring systems can use common sensors. For instance, Lovett et al. [15] use sensors designed to measure environmental properties, such as temperature, humidity, and CO 2 , instead of measuring power consumption to predict energy usage. Several communication systems have been proposed to transmit the collected data. Many studies use Zigbee, based on the protocol IEEE802. 15.4, created to support the area of wireless sensor networks [6,9,[16][17][18][19]. Bluetooth low energy (BLE) is also proposed for the communication system [20], while Bluetooth can be applied to configure smart devices [21]. In [8], Wi-Fi is used to communicate with actuator nodes, and ZigBee is used to transmit data from sensor nodes. In [22], ESP8266 Wi-Fi modules are used in sensor nodes. Li et al. [23] propose the nRF24L01 wireless transceiver (Nordic Semiconductor, Trondheim, Norway) to transmit data.
Energy monitoring systems aim to efficiently manage the energy usage of a house. However, the system also consumes energy in its operation. In many cases, the radio is the The architecture of the proposed system is shown in Figure 1. Several sensor nodes were deployed in different rooms of a house. The number shown in each node represents the type of sensor node defined in the previous list. The communication system uses ZigBee for low power consumption. This protocol is based on the IEEE 802.15.4 standard owned by Zigbee Alliance, which defines the physical layer and the medium access layer [29]. The node "C" in Figure 1 represents the coordinator of the ZigBee network.  For data transmission, the radios used in the sensor nodes were the XBee modules Series 2 [30]. The power consumption of these radios is about 40 mA @3.3 V in transmitting or receiving modes. These sensor nodes can operate as routers or end devices. A router is always powered on, allowing data to be routed from other routers or end devices. In this case, the power consumption is high, and this is the reason why most authors propose their connection to AC power plugs. End devices are in sleep mode most of the time, requiring much less energy. This situation has led to the use of batteries and their recharging or replacement in case of battery depletion. A battery lifetime of several months has been mentioned in published studies, but the sampling frequency of measurements must be very low for this to be achieved.
The microcontroller used in the sensor nodes for data acquisition and control was the Arduino Fio. This component has a XBee compatible socket on board and includes two power inputs, one for the battery and another for the battery charge. The sink node of the ZigBee network is an XBee module operating as a coordinator. As data reception is asynchronous, this radio cannot enter sleep mode. The gateway includes a Raspberry Pi 3 Model B that also acts as a home server. This small low-cost computer provides a gateway of low-power consumption that connects to the home router for internet access. A java application was developed to manage data acquisition and data visualization. Therefore, all data received from the sensors can be viewed on any computer connected to the internet that has permission to access that information. A 10-inch LCD display connected to the Raspberry Pi allows debugging and quick access to data visualization.
A 90 W solar panel was placed on the roof of the house for energy harvesting. Energy storage is performed using a battery of 100 Ah @12 V. The objective is that all energy required by the system is provided by a renewable energy source. For this purpose, a line connected to the 12 V battery was distributed in some rooms of the house to provide a power distribution parallel to the 230 V system. This power line is represented by a blue line in Figure 1. Although this form of power distribution is not usual in buildings, it can be a good suggestion for future developments of smart homes, because several home devices operate at low voltages. Furthermore, in the context of smart grids, some homes have their own solar or wind-based power generation system [5]. In this case, there is a waste of energy in inverting 12 V DC to 230 V AC to power equipment that must convert the 230 V to DC. The home power distribution of 230 V is represented in Figure 1 by red lines. Plugs at 12 V to supply power to the sensor nodes and to the home server were created. Because it is not appropriate to deploy a line at 12 V in all rooms, some sensor nodes are connected to the 230 V plugs. Nevertheless, to maintain a balance of zero-power consumption from the home power system, some home devices can be connected to the 12 V network. The harvesting system was prepared to provide all the energy consumed by the monitoring system.

Sensors
Energy consumption was measured using the effective current. The current sensor was developed using the transducer shown in Figure 2. A magnetic core embraces the AC current line. In the secondary, a coil with 2000 turns was connected to a shunt resistor. Therefore, the current in the primary can be obtained by measuring the voltage in the secondary.
For data transmission, the radios used in the sensor nodes were the XBee modules Series 2 [30]. The power consumption of these radios is about 40 mA @3.3 V in transmitting or receiving modes. These sensor nodes can operate as routers or end devices. A router is always powered on, allowing data to be routed from other routers or end devices. In this case, the power consumption is high, and this is the reason why most authors propose their connection to AC power plugs. End devices are in sleep mode most of the time, requiring much less energy. This situation has led to the use of batteries and their recharging or replacement in case of battery depletion. A battery lifetime of several months has been mentioned in published studies, but the sampling frequency of measurements must be very low for this to be achieved.
The microcontroller used in the sensor nodes for data acquisition and control was the Arduino Fio. This component has a XBee compatible socket on board and includes two power inputs, one for the battery and another for the battery charge. The sink node of the ZigBee network is an XBee module operating as a coordinator. As data reception is asynchronous, this radio cannot enter sleep mode. The gateway includes a Raspberry Pi 3 Model B that also acts as a home server. This small low-cost computer provides a gateway of low-power consumption that connects to the home router for internet access. A java application was developed to manage data acquisition and data visualization. Therefore, all data received from the sensors can be viewed on any computer connected to the internet that has permission to access that information. A 10-inch LCD display connected to the Raspberry Pi allows debugging and quick access to data visualization.
A 90 W solar panel was placed on the roof of the house for energy harvesting. Energy storage is performed using a battery of 100 Ah @12 V. The objective is that all energy required by the system is provided by a renewable energy source. For this purpose, a line connected to the 12 V battery was distributed in some rooms of the house to provide a power distribution parallel to the 230 V system. This power line is represented by a blue line in Figure 1. Although this form of power distribution is not usual in buildings, it can be a good suggestion for future developments of smart homes, because several home devices operate at low voltages. Furthermore, in the context of smart grids, some homes have their own solar or wind-based power generation system [5]. In this case, there is a waste of energy in inverting 12 V DC to 230 V AC to power equipment that must convert the 230 V to DC. The home power distribution of 230 V is represented in Figure 1 by red lines. Plugs at 12 V to supply power to the sensor nodes and to the home server were created. Because it is not appropriate to deploy a line at 12 V in all rooms, some sensor nodes are connected to the 230 V plugs. Nevertheless, to maintain a balance of zero-power consumption from the home power system, some home devices can be connected to the 12 V network. The harvesting system was prepared to provide all the energy consumed by the monitoring system.

Sensors
Energy consumption was measured using the effective current. The current sensor was developed using the transducer shown in Figure 2. A magnetic core embraces the AC current line. In the secondary, a coil with 2000 turns was connected to a shunt resistor. Therefore, the current in the primary can be obtained by measuring the voltage in the secondary.  As the aim was to measure currents in the electrical distribution board in the range of 10 mA to 18 A, and from 2 mA to 10 A in the appliances, the output voltage was amplified using four current measurement ranges. The circuit uses four operational amplifiers connected to four ADC (Analog to Digital Converter) of the Arduino. Considering a sinusoidal current waveform, only the positive voltage of the measurements was considered. Thus, Energies 2021, 14, 3846 5 of 16 the operational amplifier operated in single supply mode, allowing direct reading by the Arduino. The effective current is given by: where N is the number of samples obtained in a half period of the waveform, M is a constant used to calibrate the sensor, and v k are the output voltage samples. The system was calibrated with resistive loads, and the measurements were compared with the results obtained through a true RMS multimeter (FLUKE, Everett, WA, USA). The relative error of the developed sensor was less than 2.5%. For resistive loads, the active power can be obtained by multiplying the effective current by the effective voltage of 230 V. For loads with a power factor below 1, the active power obtained by this procedure is just an approximation. In some cases, the error committed in this approximation may be too high. An example is measuring the power consumption of AC/DC adapters, mainly in the open load condition because, in this case, the current is far from being sinusoidal. For these cases, the voltage and current waveforms must be measured, and the active power is obtained by the average of the instantaneous power. The average power was determined by: where T is the period of the waveforms, N is the number of samples in the period, and v k and i k are the voltage and current samples, respectively. Continuous current and voltage was measured using the Adafruit INA219 sensor (Texas Instruments, Dallas, TX, USA) [31]. This sensor requires a supply voltage range between 3 V and 5.5 V, and the maximum current consumption is 1 mA. The sensor uses an ADC of 12 bit for measurements. It allows one to measure voltages up to 26 V and currents up to ±3.2 A with a resolution of 0.8 mA or up to ±400 mA with a resolution of 0.1 mA. Communication with the Arduino was performed through the serial communication protocol I2C (SDA/SCL).
The SHT15 from Sensirion (Stäfa, Switzerland) was used to measure temperature and humidity [32]. The supply voltage range of the sensor is 2.4 V to 5.5 V, and the power consumption is 80 µW at 12 bit, 3 V, 1 measurements/s [33]. This sensor provides a calibrated digital output. The connection to the Arduino was performed through two digital pins.
Carbon dioxide was measured using the COZIR-W20 sensor (Gas Sensing Solutions, Cumbernauld, UK) [34]. This sensor has a resolution of 10 ppm, a measurement range from 0 to 200,000 ppm, operates at 3.3 V, and has a power consumption of about 3.5 mW. Arduino can communicate with this sensor through serial communication RX/TX to send commands and to get sensor readings.

Power Supply of Sensor Nodes
Although they have different sensors, all nodes have a common structure. Figure 3 shows the circuit to supply power to a sensor node connected to a 230 V AC plug. A relay controls the charging process of a rechargeable lithium battery by connecting an AC/DC adapter to the 230 V power supply. The used relay was the G6BK-1114P-US from Omron Electronics (Kyoto, Japan) [35], supporting contact ratings of 250 V AC and maximum switching currents of 5 A. This relay is double-winding latching, with a coil voltage of 3 V and approximated power consumption of 280 mW. This component is low power due to its latching characteristic. The relay is controlled via two Arduino digital pins. Applying a voltage to the set or reset terminals switches the contacts. Because the nominal voltage of rechargeable lithium batteries is 3.7 V, the AC/DC adapter converts 230 V AC to 5 V Electronics (Kyoto, Japan) [35], supporting contact ratings of 250 V AC and maximum switching currents of 5 A. This relay is double-winding latching, with a coil voltage of 3 V and approximated power consumption of 280 mW. This component is low power due to its latching characteristic. The relay is controlled via two Arduino digital pins. Applying a voltage to the set or reset terminals switches the contacts. Because the nominal voltage of rechargeable lithium batteries is 3.7 V, the AC/DC adapter converts 230 V AC to 5 V DC, and a charger is used to charge the battery. Finally, a DC/DC converter can be used to aquire the required voltage of 3.3 V. The Arduino Fio already contains a linear regulator to obtain this voltage. This procedure is applied to routers and end devices. The algorithm for controlling the relay is represented by the flowchart in Figure 4. The algorithm starts by defining the start-of-charge voltage (SoCV) and the end-of-charge voltage (EoCV). The effect in power consumption of different values of the SOCV was studied, and the results will be presented in the next section. The EoCV is typically 4.2 V for lithium batteries. At each cycle, the Arduino measures the battery voltage using an ADC connected to a voltage divider. If the battery voltage is below SoCV, the code applies 3.3 V to the relay set input to connect the AC/DC adapter to 230 V. If the battery voltage is above EoCV, the code applies 3.3 V to the relay reset input to disconnect the adapter from the main power. In this way, the AC/DC adapter only consumes power during the charging period.  This procedure is applied to routers and end devices. The algorithm for controlling the relay is represented by the flowchart in Figure 4. The algorithm starts by defining the start-of-charge voltage (SoCV) and the end-of-charge voltage (EoCV). The effect in power consumption of different values of the SOCV was studied, and the results will be presented in the next section. The EoCV is typically 4.2 V for lithium batteries. At each cycle, the Arduino measures the battery voltage using an ADC connected to a voltage divider. If the battery voltage is below SoCV, the code applies 3.3 V to the relay set input to connect the AC/DC adapter to 230 V. If the battery voltage is above EoCV, the code applies 3.3 V to the relay reset input to disconnect the adapter from the main power. In this way, the AC/DC adapter only consumes power during the charging period.
Electronics (Kyoto, Japan) [35], supporting contact ratings of 250 V AC and maximum switching currents of 5 A. This relay is double-winding latching, with a coil voltage of 3 V and approximated power consumption of 280 mW. This component is low power due to its latching characteristic. The relay is controlled via two Arduino digital pins. Applying a voltage to the set or reset terminals switches the contacts. Because the nominal voltage of rechargeable lithium batteries is 3.7 V, the AC/DC adapter converts 230 V AC to 5 V DC, and a charger is used to charge the battery. Finally, a DC/DC converter can be used to aquire the required voltage of 3.3 V. The Arduino Fio already contains a linear regulator to obtain this voltage. This procedure is applied to routers and end devices. The algorithm for controlling the relay is represented by the flowchart in Figure 4. The algorithm starts by defining the start-of-charge voltage (SoCV) and the end-of-charge voltage (EoCV). The effect in power consumption of different values of the SOCV was studied, and the results will be presented in the next section. The EoCV is typically 4.2 V for lithium batteries. At each cycle, the Arduino measures the battery voltage using an ADC connected to a voltage divider. If the battery voltage is below SoCV, the code applies 3.3 V to the relay set input to connect the AC/DC adapter to 230 V. If the battery voltage is above EoCV, the code applies 3.3 V to the relay reset input to disconnect the adapter from the main power. In this way, the AC/DC adapter only consumes power during the charging period.  As previously mentioned, the system uses energy harvesting to charge 12 V batteries. Thus, the power supply of the sensor nodes can also be carried through this energy source. In this case, a circuit similar to the one of Figure 3 is used, with the 230 V source replaced by the 12 V battery and the AC/DC adapter replaced by a 12 V to 5 V DC/DC converter.

Data Visualization
Data is collected via the coordinator connected to the Raspberry Pi. A java program interprets the data and saves it on a local MySQL database server. A simple webpage was developed using PHP on the Raspberry Pi to monitor the collected data. This allows data to be viewed anywhere on a device with internet access. The webpage shown in Figure 5 displays a list of parameters with their latest values, including the sensors monitored by the ZigBee network. Two graphs show the stored values according to the time interval selected by the user and data set, which allow easy comparison of results and study of events. The live parameters display provides the ability to detect a loss of communication by changing the color of data that has not been updated within a predetermined period. This is exemplified by the ModCO2_RSSI parameter. It is important to quickly identify and find solutions to problems related to the sensor nodes that may be due to the power supply or network issues.
As previously mentioned, the system uses energy harvesting to charge 12 V batteries. Thus, the power supply of the sensor nodes can also be carried through this energy source. In this case, a circuit similar to the one of Figure 3 is used, with the 230 V source replaced by the 12 V battery and the AC/DC adapter replaced by a 12 V to 5 V DC/DC converter.

Data Visualization
Data is collected via the coordinator connected to the Raspberry Pi. A java program interprets the data and saves it on a local MySQL database server. A simple webpage was developed using PHP on the Raspberry Pi to monitor the collected data. This allows data to be viewed anywhere on a device with internet access. The webpage shown in Figure 5 displays a list of parameters with their latest values, including the sensors monitored by the ZigBee network. Two graphs show the stored values according to the time interval selected by the user and data set, which allow easy comparison of results and study of events. The live parameters display provides the ability to detect a loss of communication by changing the color of data that has not been updated within a predetermined period. This is exemplified by the ModCO2_RSSI parameter. It is important to quickly identify and find solutions to problems related to the sensor nodes that may be due to the power supply or network issues. Owing to its low power consumption, the Raspberry Pi is a good option to be used as a local server. However, because this small computer uses an SD (Secure Digital) memory card to store the operating system, programs, and data, card corruption may occur. In this case, all data may be lost. To minimize this problem, all data are exported via MySQL files to a web cloud according to a pre-established periodicity. This cloud is used only for momentary storage of that information. Another script is running on a desktop computer to import this data into another database when it is powered on. This computer also makes it possible to analyze a larger volume of data because it has greater resources.

Results
This section presents the results related to several aspects of the power consumption of the sensor nodes. The proposed system was tested to evaluate its efficiency. Owing to its low power consumption, the Raspberry Pi is a good option to be used as a local server. However, because this small computer uses an SD (Secure Digital) memory card to store the operating system, programs, and data, card corruption may occur. In this case, all data may be lost. To minimize this problem, all data are exported via MySQL files to a web cloud according to a pre-established periodicity. This cloud is used only for momentary storage of that information. Another script is running on a desktop computer to import this data into another database when it is powered on. This computer also makes it possible to analyze a larger volume of data because it has greater resources.

Results
This section presents the results related to several aspects of the power consumption of the sensor nodes. The proposed system was tested to evaluate its efficiency.

Power Consumption of Sensor Nodes
The power consumption of sensor nodes was measured for three types of power sources: 3.7 V lithium batteries; 12 V batteries; 230 V AC power. The INA219 (Texas Instruments, Dallas, TX, USA) was used to measure the power consumption of the DC sources. The power of the AC source was obtained by measuring the AC voltage and the current. The current sensor was the one shown in Figure 2, and the average power was determined by using Equation (2). Figure 6 shows the measured waveforms of AC/DC adapters for the no-load condition. Figure 6a refers to a 230 V AC to 3.3 V converter, the ECL10US03 from XP Power [36]. The measured average power was about 110 mW, being inside the range of values given by the manufacturer that is below 300 mW for no load input power. Figure 6b refers to a 230 V AC to 5 V converter used to charge cellphones. The measured average power was about 81 mW. The power consumption of other AC/DC adapters has been measured and the values can be even higher. These tests reveal the importance of avoiding the use of these adapters that are always connected to the electrical network to power low consumption devices.

Power Consumption of Sensor Nodes
The power consumption of sensor nodes was measured for three types of power sources: 3.7 V lithium batteries; 12 V batteries; 230 V AC power. The INA219 (Texas Instruments, Dallas, TX, USA) was used to measure the power consumption of the DC sources. The power of the AC source was obtained by measuring the AC voltage and the current. The current sensor was the one shown in Figure 2, and the average power was determined by using Equation (2). Figure 6 shows the measured waveforms of AC/DC adapters for the no-load condition. Figure 6a refers to a 230 V AC to 3.3 V converter, the ECL10US03 from XP Power [36]. The measured average power was about 110 mW, being inside the range of values given by the manufacturer that is below 300 mW for no load input power. Figure 6b refers to a 230 V AC to 5 V converter used to charge cellphones. The measured average power was about 81 mW. The power consumption of other AC/DC adapters has been measured and the values can be even higher. These tests reveal the importance of avoiding the use of these adapters that are always connected to the electrical network to power low consumption devices. Another energy source used in this study was a 12 V battery. In this case, a DC/DC converter was required to obtain 5 V to charge the lithium batteries. The power consumption of a 12 V to 5 V converter was measured for the no-load condition, giving 11.4 mW. Comparing this value with those of AC/DC converters, this result is much lower. It is interesting to note that the usual conversion from 12 V DC to 230 V AC from renewable energy systems to power low voltage equipment introduces a great waste of energy.
For the three mentioned energy sources, the power consumption of the sensor nodes is shown in Table 1. The tests were carried out with the sensor nodes acting as routers or end devices when transmitting data with a period of 20 s. The results are presented for five nodes, consisting of an energy sensor node operating as a router (R) and another one as an end device (ED), a node to monitor temperature and humidity (T/H) operating as a router and as an end device, and a node to monitor carbon dioxide (CO2) also being a router. Column two of the table shows the current consumption of these sensor nodes. Column three shows the power consumption for a voltage of 3.3 V. Column four shows the results for these sensor nodes powered by 3.7 V lithium batteries. Because a rechargeable lithium battery operates with voltages between 3.1 and 4.2 V, these measurements were made for different battery charges and the average was obtained. In another experiment, the average voltage during discharge was determined, with a result of about 3.8 V. This result is close to the average voltage used to obtain the values of the fourth column. Column five shows the average power consumption when the energy source was a 12 V battery. Comparing columns five and four, the efficiency of the DC/DC converter is about 56% for routers. Although this converter has an efficiency above 80%, this result is only Another energy source used in this study was a 12 V battery. In this case, a DC/DC converter was required to obtain 5 V to charge the lithium batteries. The power consumption of a 12 V to 5 V converter was measured for the no-load condition, giving 11.4 mW. Comparing this value with those of AC/DC converters, this result is much lower. It is interesting to note that the usual conversion from 12 V DC to 230 V AC from renewable energy systems to power low voltage equipment introduces a great waste of energy.
For the three mentioned energy sources, the power consumption of the sensor nodes is shown in Table 1. The tests were carried out with the sensor nodes acting as routers or end devices when transmitting data with a period of 20 s. The results are presented for five nodes, consisting of an energy sensor node operating as a router (R) and another one as an end device (ED), a node to monitor temperature and humidity (T/H) operating as a router and as an end device, and a node to monitor carbon dioxide (CO 2 ) also being a router.
Column two of the table shows the current consumption of these sensor nodes. Column three shows the power consumption for a voltage of 3.3 V. Column four shows the results for these sensor nodes powered by 3.7 V lithium batteries. Because a rechargeable lithium battery operates with voltages between 3.1 and 4.2 V, these measurements were made for different battery charges and the average was obtained. In another experiment, the average voltage during discharge was determined, with a result of about 3.8 V. This result is close to the average voltage used to obtain the values of the fourth column. Column five shows the average power consumption when the energy source was a 12 V battery. Comparing columns five and four, the efficiency of the DC/DC converter is about 56% for routers. Although this converter has an efficiency above 80%, this result is only valid for output currents above 60 mA. For routers, the output current is approximately 23 mA (@12 V). This conversion efficiency is even lower for end devices, giving 24% for the Energy-ED node and 17% for the T/H-ED node. Column six shows the results for sensor nodes powered through an AC/DC adapter of 230 V to 5 V. As expected, the conversion efficiency is low, and compared to the fourth column the efficiency is 42% for routers and below 10% for end devices. Considering that the sensors used in this study, Arduino and XBee, operate at 3.3 V, the third column of Table 1 refers to the power consumption of each sensor node. Thus, these values can be used as a reference for the efficiency calculations. Figure 7 shows the efficiencies of the sensor nodes for the three energy sources. The efficiency of routers and end devices is above 85% when the sensor nodes are powered by 3.7 V batteries. For this energy source, there is practically no difference in efficiency when a sensor node operates as a router or as an end device. For the 12 V battery, the results are below 50% for routers and below 21% for end devices. In this case, there is a great waste of energy when the end devices were continuously connected to this source. When the energy source is the 230 V mains supply, the efficiencies are about 36% for routers, 9% for the Energy-ED node, and 4% for the T/H-ED node. These very low efficiencies have led to the use of batteries to power end device sensor nodes. Even for routers, the use of AC/DC adapters connected to the main power results in small efficiencies. Considering that these nodes are consuming about three times more energy than necessary and because AC/DC adapters are proposed in many studies to power routers, a more efficient way of power supply is required. valid for output currents above 60 mA. For routers, the output current is approximately 23 mA (@12 V). This conversion efficiency is even lower for end devices, giving 24% for the Energy-ED node and 17% for the T/H-ED node. Column six shows the results for sensor nodes powered through an AC/DC adapter of 230 V to 5 V. As expected, the conversion efficiency is low, and compared to the fourth column the efficiency is 42% for routers and below 10% for end devices. Considering that the sensors used in this study, Arduino and XBee, operate at 3.3 V, the third column of Table 1 refers to the power consumption of each sensor node. Thus, these values can be used as a reference for the efficiency calculations. Figure 7 shows the efficiencies of the sensor nodes for the three energy sources. The efficiency of routers and end devices is above 85% when the sensor nodes are powered by 3.7 V batteries. For this energy source, there is practically no difference in efficiency when a sensor node operates as a router or as an end device. For the 12 V battery, the results are below 50% for routers and below 21% for end devices. In this case, there is a great waste of energy when the end devices were continuously connected to this source. When the energy source is the 230 V mains supply, the efficiencies are about 36% for routers, 9% for the Energy-ED node, and 4% for the T/H-ED node. These very low efficiencies have led to the use of batteries to power end device sensor nodes. Even for routers, the use of AC/DC adapters connected to the main power results in small efficiencies. Considering that these nodes are consuming about three times more energy than necessary and because AC/DC adapters are proposed in many studies to power routers, a more efficient way of power supply is required. In addition to the sensor nodes, the system includes other components consuming energy, such as the home server. The Raspberry Pi 3 model B requires a power source of 5.1 V. For the Raspberry Pi [37], the typical bare-board active current consumption is 400 mA, giving a power consumption of 2.04 W. This consumption can be higher depending on what is connected to the Raspberry. Due to the higher power requirements, the Raspberry Pi must use 12 V batteries or the 230 AC source. The average power consumption measured was 2.25 W for the 12 V battery. The minimum consumption was 2.1 W, and peaks of 5 W were obtained. This power source can be very efficient to operate the Raspberry because typical 12 V to 5 V converters have a high efficiency for higher current consumption. The average power consumption measured for the 230 V AC source was 2.58 W. The server also includes an LCD display that consumes an average 3.8 W when connected to 12 V and 4.1 W when connected to 230 V. It should be noted the Raspberry Pi is always connected to the power supply, and the display is only turned on when it is necessary to access the data.

Energy Consumption for Charging Lithium Batteries
From Figure 7, it may be concluded that low voltage batteries are the most effective way to power sensor nodes. However, this requires periodic charging. Three battery capacities were considered to evaluate the energy consumed in this process. Figure 8 shows the time evolution of power consumption to charge a 1800 mAh lithium battery from the 12 V battery. Considering an SoCV of 3.5 V, the average power consumption was 3.55 W for a time interval of 2 h and 30 min, giving an energy consumption of 31950 J. The energy consumption was also measured for batteries of 980 mAh and 2500 mAh, giving the results shown in Figure 9. The graph also provides the results for the 230 V AC power supply. Charging from 12 V consumes 81%, 87%, and 91% compared to charging from 230 V, for 980 mAh, 1800 mAh, and 2500 mAh batteries, respectively. The relative difference in energy consumption between both cases is smaller for batteries of greater capacity. berry because typical 12 V to 5 V converters have a high efficiency for higher current consumption. The average power consumption measured for the 230 V AC source was 2.58 W. The server also includes an LCD display that consumes an average 3.8 W when connected to 12 V and 4.1 W when connected to 230 V. It should be noted the Raspberry Pi is always connected to the power supply, and the display is only turned on when it is necessary to access the data.

Energy Consumption for Charging Lithium Batteries
From Figure 7, it may be concluded that low voltage batteries are the most effective way to power sensor nodes. However, this requires periodic charging. Three battery capacities were considered to evaluate the energy consumed in this process. Figure 8 shows the time evolution of power consumption to charge a 1800 mAh lithium battery from the 12 V battery. Considering an SoCV of 3.5 V, the average power consumption was 3.55 W for a time interval of 2 h and 30 min, giving an energy consumption of 31950 J. The energy consumption was also measured for batteries of 980 mAh and 2500 mAh, giving the results shown in Figure 9. The graph also provides the results for the 230 V AC power supply. Charging from 12 V consumes 81%, 87%, and 91% compared to charging from 230 V, for 980 mAh, 1800 mAh, and 2500 mAh batteries, respectively. The relative difference in energy consumption between both cases is smaller for batteries of greater capacity. berry because typical 12 V to 5 V converters have a high efficiency for higher current consumption. The average power consumption measured for the 230 V AC source was 2.58 W. The server also includes an LCD display that consumes an average 3.8 W when connected to 12 V and 4.1 W when connected to 230 V. It should be noted the Raspberry Pi is always connected to the power supply, and the display is only turned on when it is necessary to access the data.

Energy Consumption for Charging Lithium Batteries
From Figure 7, it may be concluded that low voltage batteries are the most effective way to power sensor nodes. However, this requires periodic charging. Three battery capacities were considered to evaluate the energy consumed in this process. Figure 8 shows the time evolution of power consumption to charge a 1800 mAh lithium battery from the 12 V battery. Considering an SoCV of 3.5 V, the average power consumption was 3.55 W for a time interval of 2 h and 30 min, giving an energy consumption of 31950 J. The energy consumption was also measured for batteries of 980 mAh and 2500 mAh, giving the results shown in Figure 9. The graph also provides the results for the 230 V AC power supply. Charging from 12 V consumes 81%, 87%, and 91% compared to charging from 230 V, for 980 mAh, 1800 mAh, and 2500 mAh batteries, respectively. The relative difference in energy consumption between both cases is smaller for batteries of greater capacity. Another study with battery charging was to assess the influence of the SoCV on efficiency. Figure 10 shows the energy consumed to charge a 1800 mAh battery for different SoCVs. The power supply used in the measurements was 230 V AC. Another study with battery charging was to assess the influence of the SoCV on efficiency. Figure 10 shows the energy consumed to charge a 1800 mAh battery for different SoCVs. The power supply used in the measurements was 230 V AC.

Energy Consumed with Charging Control
In the previous subsection, the energy consumed to charge a 1800 mAh lithium battery for different SoCV was evaluated. On the other side, the energy consumed by a sensor node, so that the battery reaches an end of discharge equal to the SoCV represented in Figure 10, will be evaluated. The reason for this is that higher SoCV values require less energy consumption, but the battery does not last as long. Figure 11a shows the results when suppling power to a router. Comparing with the required energy to charge the battery (Figure 10), Figure 11b shows the efficiency of energy consumption in discharge. It is observed that greater efficiencies are obtained for lower values of end of discharge. Because the difference in the amount of energy is negligible between 3.3 V and 3.5 V, a value of 3.5 V was chosen for the end of discharge so as to not stress the batteries. For this situation, the efficiency of the system was 57%. The discharge time of the batteries was measured when feeding the sensor nodes shown in Table 1. As expected, the duration of the battery is proportional to the battery capacity. The battery life of routers was less than a day for the capacity of 980 mAh, about a day and a half for the capacity of 1800 mAh, and more than two days for 2500 mAh. The

Energy Consumed with Charging Control
In the previous subsection, the energy consumed to charge a 1800 mAh lithium battery for different SoCV was evaluated. On the other side, the energy consumed by a sensor node, so that the battery reaches an end of discharge equal to the SoCV represented in Figure 10, will be evaluated. The reason for this is that higher SoCV values require less energy consumption, but the battery does not last as long. Figure 11a shows the results when suppling power to a router. Comparing with the required energy to charge the battery (Figure 10), Figure 11b shows the efficiency of energy consumption in discharge. It is observed that greater efficiencies are obtained for lower values of end of discharge. Because the difference in the amount of energy is negligible between 3.3 V and 3.5 V, a value of 3.5 V was chosen for the end of discharge so as to not stress the batteries. For this situation, the efficiency of the system was 57%. Another study with battery charging was to assess the influence of the SoCV on efficiency. Figure 10 shows the energy consumed to charge a 1800 mAh battery for different SoCVs. The power supply used in the measurements was 230 V AC.

Energy Consumed with Charging Control
In the previous subsection, the energy consumed to charge a 1800 mAh lithium battery for different SoCV was evaluated. On the other side, the energy consumed by a sensor node, so that the battery reaches an end of discharge equal to the SoCV represented in Figure 10, will be evaluated. The reason for this is that higher SoCV values require less energy consumption, but the battery does not last as long. Figure 11a shows the results when suppling power to a router. Comparing with the required energy to charge the battery (Figure 10), Figure 11b shows the efficiency of energy consumption in discharge. It is observed that greater efficiencies are obtained for lower values of end of discharge. Because the difference in the amount of energy is negligible between 3.3 V and 3.5 V, a value of 3.5 V was chosen for the end of discharge so as to not stress the batteries. For this situation, the efficiency of the system was 57%. The discharge time of the batteries was measured when feeding the sensor nodes shown in Table 1. As expected, the duration of the battery is proportional to the battery capacity. The battery life of routers was less than a day for the capacity of 980 mAh, about a day and a half for the capacity of 1800 mAh, and more than two days for 2500 mAh. The  The discharge time of the batteries was measured when feeding the sensor nodes shown in Table 1. As expected, the duration of the battery is proportional to the battery capacity. The battery life of routers was less than a day for the capacity of 980 mAh, about a day and a half for the capacity of 1800 mAh, and more than two days for 2500 mAh. The battery life of end devices was of several weeks. The energy consumed to charge the batteries shown in Figure 9 was divided by the time taken by the battery to reach the 3.5 V EoCV. This allows one to determine the average power consumption when using the proposed system. Then, the efficiencies were determined considering the reference values presented in the third column of Table 1. Figure 12 shows the results for two routers and two end devices. The results of the T/H-R node are not shown as they are similar to those of the Energy-R node. "Plug" refers to the efficiencies represented in Figure 7 for two situations. Figure 12a shows the results for the 230 V AC supply, and Figure 12b shows the results for the 12 V DC supply. Because the end devices do not require high battery capacities, no results were obtained with 2500 mAh batteries for these nodes. battery life of end devices was of several weeks. The energy consumed to charge the bat-teries shown in Figure 9 was divided by the time taken by the battery to reach the 3.5 V EoCV. This allows one to determine the average power consumption when using the proposed system. Then, the efficiencies were determined considering the reference values presented in the third column of Table 1. Figure 12 shows the results for two routers and two end devices. The results of the T/H-R node are not shown as they are similar to those of the Energy-R node. "Plug" refers to the efficiencies represented in Figure 7 for two situations. Figure 12a shows the results for the 230 V AC supply, and Figure 12b shows the results for the 12 V DC supply. Because the end devices do not require high battery capacities, no results were obtained with 2500 mAh batteries for these nodes. For the batteries charged by the 230 V AC system, the efficiencies are about 50% for both types of sensor nodes. The improvement in the efficiencies of routers with the proposed system was, on average, 28%. The improvement in the efficiencies of end devices was, on average, 87%. For batteries charged by the 12 V DC system, the improvements are smaller than those in the previous case, but higher efficiencies were still obtained. The For the batteries charged by the 230 V AC system, the efficiencies are about 50% for both types of sensor nodes. The improvement in the efficiencies of routers with the proposed system was, on average, 28%. The improvement in the efficiencies of end devices was, on average, 87%. For batteries charged by the 12 V DC system, the improvements are smaller than those in the previous case, but higher efficiencies were still obtained. The improvement in the efficiency of end devices was, on average, 71%, with efficiencies close to 60%.

Energy Harvesting
The monitoring system contains ten sensor nodes measuring energy consumption and air quality parameters. Before applying the power supply technique proposed in this study, the network was tested for a year to evaluate some practical characteristics. Two sensor nodes were defined as routers and eight as end devices. The end devices were battery operated. The parameter RSSI (Received Strength Signal Indicator) was measured and stored in the database to monitor the quality of the radio signals. Over time, it was found that the end devices occasionally lost their connection to the network for long periods. Evaluating the RSSI, the loss of connection did not seem to be due to the loss of radio signal. A possible reason for this loss could be the frequency range used by the system, since ZigBee and Wi-Fi operate in the same band. As a result, the loss of connection of a sensor node increased the power consumption due to data retransmission. Another problem faced was the recharging of batteries. Although the battery life was of several weeks, on average it was necessary to replace a battery every two weeks. This required constant monitoring of battery levels. Therefore, during the experiment, some batteries have run out of power and data has been lost. The way to solve this problem is to avoid the need for human intervention in the functioning of the network and make it fully automatic.
The experience gained from the tests carried out led to an increase in the number of routers. With five routers, the network has become much more stable. The problem of battery charging was solved by using the proposed system. The proposed system also uses energy harvesting to provide all energy necessary to operate the monitoring network, as shown in Figure 1. Figure 13 shows the average power production per month for the year 2020. The residence is located in the city of Funchal, Madeira Island.

Energy Harvesting
The monitoring system contains ten sensor nodes measuring energy consumption and air quality parameters. Before applying the power supply technique proposed in this study, the network was tested for a year to evaluate some practical characteristics. Two sensor nodes were defined as routers and eight as end devices. The end devices were battery operated. The parameter RSSI (Received Strength Signal Indicator) was measured and stored in the database to monitor the quality of the radio signals. Over time, it was found that the end devices occasionally lost their connection to the network for long periods. Evaluating the RSSI, the loss of connection did not seem to be due to the loss of radio signal. A possible reason for this loss could be the frequency range used by the system, since ZigBee and Wi-Fi operate in the same band. As a result, the loss of connection of a sensor node increased the power consumption due to data retransmission. Another problem faced was the recharging of batteries. Although the battery life was of several weeks, on average it was necessary to replace a battery every two weeks. This required constant monitoring of battery levels. Therefore, during the experiment, some batteries have run out of power and data has been lost. The way to solve this problem is to avoid the need for human intervention in the functioning of the network and make it fully automatic.
The experience gained from the tests carried out led to an increase in the number of routers. With five routers, the network has become much more stable. The problem of battery charging was solved by using the proposed system. The proposed system also uses energy harvesting to provide all energy necessary to operate the monitoring network, as shown in Figure 1. Figure 13 shows the average power production per month for the year 2020. The residence is located in the city of Funchal, Madeira Island. The average power consumption of the developed system is 3.8 W. For this result, the LCD was considered to be turned on for half an hour a day. As can be observed from Figure 13, the system generated more than the required energy in all months of this year. The worst month was December, with an average power production of 7 W. Because the energy production is not constant, the energy generation per day was evaluated for this month. On cloudy days, the energy generation was not enough to compensate the consumption. The power generation only exceeded the power consumption for an average of The average power consumption of the developed system is 3.8 W. For this result, the LCD was considered to be turned on for half an hour a day. As can be observed from Figure 13, the system generated more than the required energy in all months of this year. The worst month was December, with an average power production of 7 W. Because the energy production is not constant, the energy generation per day was evaluated for this month. On cloudy days, the energy generation was not enough to compensate the consumption. The power generation only exceeded the power consumption for an average of four days. The 100 Ah battery at full charge guarantees a system operating autonomy for more than ten days.

Discussion
The proposed technique of power supply home monitoring systems has several advantages, such as:

•
Decreasing the power consumption of routers; • Allowing an increase in the number of routers to increase network reliability; • Reducing costs by avoiding the use of alkaline batteries; • Avoiding the changing of batteries; • Allowing higher sampling frequencies of data with a reduced effect in power consumption; • Reducing loss of data by avoiding human intervention; • Reducing to zero the energy consumption from the main home power system; • Providing all energy via a renewal energy source; • Allowing the accommodation of higher power consumption to use low-cost sensors; • Providing a battery powered backup in case of mains power failure; • Extending battery lifetime due to not maintaining the battery at full charge.
In a ZigBee network, routers must always be powered on to allow routing data from other routers and end devices. Thus, the power consumption is high because they must be connected to the home's power system. It was important to develop techniques to reduce this waste of energy. As shown in Figure 12, the proposed system increased the power supply efficiency from about 36% to about 58%. Tests carried out in this work have shown that it may be effective to increase the number of routers to avoid loss of data by the ZigBee network. The renewable energy system allowed it to accommodate this increase of power consumption.
In several studies and many commercial devices, sensor nodes operating in sleep mode use alkaline batteries. This power source provides very high power supply efficiency. However, to control the consumption, data is sampled at very low frequencies. Furthermore, periodic change of batteries is required. To understand the cost associated with this solution, let us compare the price of batteries with the price of electricity. A pack of four AA-alkaline batteries usually costs more than €2. Supposing a battery lifetime of two months, and that an end device uses two batteries, the cost of batteries is 6 €/year per end device. Taking into account the prices of electricity in Portugal of about 0.18 €/kWh and an average power consumption of 10 mW for an end device using the proposed system, the energy cost is only 0.016 €/year. The use of rechargeable batteries reduces the costs in comparison to the use of alkaline batteries, but still requires a change of batteries. The proposed system avoids this change of batteries and keeps power consumption low. Another great advantage of the automatic recharging of end devices is to increase the sampling frequency of data. In fact, the typical usage of systems that run on batteries are only viable with low sampling frequencies to maximize battery lifetime. However, as mentioned in [13], to maintain a real-time sampling, some mechanism must exist to reduce power consumption. With the proposed technique, the sampling period may be as desired because the power consumption of end devices is low, as can be seen from Figure 12. In addition, removing the manual intervention reduces the probability of any possible loss of data due to human errors.
Energy harvesting is mandatory for outdoor systems operating in remote environments. For indoor monitoring systems, there are practically no energy harvesting systems because of the easy access to the power sources. As a home energy monitoring system aims to reduce energy consumption, it is important that the system avoids any increase in energy consumption. Harvesting from solar energy is a good solution for powering home monitoring systems, because a small photovoltaic panel placed on a roof or in any other small area oriented towards the sun generates all the energy required by the system.
Various published works propose batteries to support backup in the case of temporary power failure. The proposed system also solved this problem because all sensor nodes are battery powered.

Conclusions
In this work, a smart technique was proposed to power home monitoring systems. A wireless sensor network based on ZigBee was developed to test the proposed solution. The system measures energy consumption and air quality parameters. The charging process is controlled by a low-cost microcontroller through relays connected between the main power source and the charging system. Considering a router using a 230 V AC adapter, the power consumption is almost three times the power consumed by the node. It was verified that high power efficiencies are obtained if a low voltage device is powered by a low power system. In this case, low voltage batteries must be used. However, this solution has several drawbacks. Alkaline batteries are very expensive compared to the cost of energy. Rechargeable batteries require charging or changing batteries, which in many practical situations is carried out by human intervention. Furthermore, the data sampling frequency must be very low to decrease power consumption. The use of the main energy network to power monitoring systems is a very attractive solution as it removes human intervention and ensures continuous energy supply. Nevertheless, its efficiency is very low when applied to low power systems. To combine the advantages of both sources of energy, the proposed technique uses rechargeable batteries to power all sensor nodes, combined with a controlled charging system connected to the main power supply. The tests to evaluate the appropriate SoCV revealed that greater efficiencies are obtained if most of the energy stored in the batteries is used in the discharge process. For the routers, the proposed technique increased the power supply efficiency from about 36% to about 50% when using 230 V AC adapters and to about 58% when using 12 V DC batteries. End devices have been typically battery operated. In this work, end devices used 230 V AC plugs or 12 V DC batteries with power supply efficiencies between 50% and 60%. Furthermore, a small energy harvesting system based on a solar panel supplies all energy needed for the monitoring system. For a network with ten sensor nodes, the average power consumption was about 3.8 W. In 2020, the 80 W solar panel generated, on average, 8.4 W. The generated energy provided all energy consumed, and the extra production can be used to accommodate higher power consumption to use low-cost sensors. Future works include studying the application of the proposed technique to other low-power systems.