Wireless Sensor Networks for Smart Homes: A Fuzzy-Based Solution for an Energy-Effective Duty Cycle

: This paper introduces a fuzzy-based method that, according to the ratio of Throughput to Workload and the battery level, manages the sleeping time of devices in Wireless Sensor Networks (WSNs) for smart homes. The purpose of this work is a system that can be executed on off-the-shelf hardware and offers enhanced performance confronted with other approaches. The challenge here is to achieve a practical method that reaches the target while bypassing complex and computationally expensive solutions, which would diminish the possible applicability of the method in real scenarios. The retrieved results prove that the proposed approach outperforms other solutions, signiﬁcantly prolonging the life of battery-powered wireless devices with also satisfactory values of the ratio Throughput to Workload. Besides, a proof-of-concept implementation on off-the-shelf devices conﬁrms that the proposed method does not expect powerful hardware and can be surely implemented on a low-cost device.


Introduction
In the last few years, technological progress in the wireless communication, energy consumption, and chip miniaturization have facilitated the growth and the deployment of original applications based on Wireless Sensor Networks (WSNs) [1][2][3][4][5].Several works have been published in the research fields related to WSNs, and many architectures [6][7][8] and protocols [9][10][11] have been produced.Typical WSNs are not complicated monitoring systems, whose applications embrace environment monitoring [12], infrastructure security [13], industrial sensing [14] and intelligent transportation systems [15].In these WSNs, sensors collect the demanded information, frequently according to a fixed temporal schedule, and transmit it to the sink, which interfaces with a server or a computer.The nodes of a WSN are typically battery-powered and equipped with low-performance processors and small memories to decrease the power requirements.The power consumption represents a crucial problem in WSNs.For instance, a battery-operated sensor device that wakes up once every few minutes to examine an environmental parameter requires to spend as little power as possible to lessen the battery replacement.In several instances, nodes can be disposed of in harsh conditions, such as underwater or underground, where the battery replacement could be a tricky procedure.Accordingly, the extension of the network lifetime is a critical issue.
In generical home automation, WSNs serve several home device controllers, such as HVAC, lights, doors, and more [16][17][18].The open problem, in the contemporary transition period, is to adopt those new home automation technologies into already built and furnished houses, minimizing the annoyance during the installation phase.For this reason, the power management is a crucial factor, and despite the vastness of smart homes literature [19][20][21][22][23][24][25], it is still challenging to state that the batteries life issue has been solved.
Recently, two classes of parallel procedures have been utilized to face up the problem related to energy consumption, i.e., power management and energy scavenging methods [26].The above techniques gain the energy from the monitored environment, e.g., employing photo-voltaic cells [27], vibration or motion-driven micro-electromechanical devices [28], thermoelectric converters [29], or particular radio frequency receivers [30].Other approaches move intelligence and analytic capacities into the network to achieve better utilization of the limited energy resources at IoT nodes, with fewer transmissions leading to less network load and a higher data yield.This solution is known as edge mining, or data mining that takes place on wireless, battery-powered, smart sensing devices that sit at the edge of the IoT network [31][32][33].The application of this method reduces the transmissions number but, at the same time, involves various overheads leading to a small additional increase in devices lifetime.On the contrary, power management methods rely on hardware and/or software solutions that momentarily disable those components which are unused or underused.In particular, since the radio part is frequently the most power-hungry characteristic of a WSN node, the appropriate control of the duty cycle is significant to extend the battery life.For instance, the amount of consumed power could be significantly diminished through energy-efficient routing schemes [34,35] to find, among all the possible communication paths, which one lessens the energy consumption.Besides, the nodes can be grouped through a clustering algorithm.In this way, the data obtained by the nodes of a cluster can be aggregated and lessened by the cluster head before being sent, with a consequent energy saving [36,37].At the data link layer, a Medium Access Control (MAC) protocol can implement energy-efficient methods for managing multiple accesses to the wireless channel.The differences among the existing MAC protocols are moved by the variety of WSN in which they are applied.For instance, several protocols, such as the IEEE 802.15.4 standard [38], regulate the wireless communication of short-range, low-data-rate, and low-power devices.It specifies two working forms: active and sleep.Nodes are active only when they have to communicate, or they presume to accept data.Contrarily, they start the sleep mode, and they switch off their modules to preserve power.At the application layer, regulating the sampling time, i.e., the rate of the environment measurements [39,40], can influence the network lifetime.A high sampling time decreases the energy consumption since few measures are expected, but it also penalizes the reactivity and effectiveness of the WSN, due to the latency in recognizing environmental variations.The adjustment of the sampling time influences also on the data link layer [41,42], because a node can sense the environment only during the active state.
This paper introduces a solution based on fuzzy logic to cope with the energy consumption issue in battery-powered devices composing a WSN for smart homes.In detail, regarding the duty cycle, the sleeping time of network nodes is dynamically adjusted by a Fuzzy Logic Controller (FLC).It is useful to note that the approach proposed in this work is an extension of the excellent solution presented in [43].In this paper, not only a different type of membership function is used in the FLC but, mainly, the target here is to realize a practical method that reaches the goal while avoiding difficult and computationally costly solutions, such as the Particle Swarm Optimization (PSO), which would decrease the possible applicability of the procedure in real situations.The objective is to develop a proof-of-concept implementation on off-the-shelf devices, highlighting that the suggested method does not demand compelling hardware and can be openly realized on low-cost devices.The application scenario represents another difference.An Industrial WSN is considered in [43] while a WSN for smart homes is regarded in this work.It is well-known that both scenarios have different requirement concerning the duty cycle of battery-powered devices composing the wireless network.Fuzzy logic has been chosen even in this paper because the use of rule-based FLCs expedites the development of multi-criteria control policies [44,45].Fuzzy logic can perform real-time settlements even with incomplete information while other common control systems are based on a precise characterization of the environment.Considering that fuzzy-based systems can quickly examine the linguistic rules, they can be expressly applicable in numerous scenarios, such as WSNs employment, including smart homes.For instance, the adoption of smart tuning and setting methods for FLCs can increase the energy preservations in a WSN.As a consequence, the FLCs can be the appropriate option to represent a procedure for energy saving to lengthen network's lifetime.
In this research field, a fuzzy logic system is introduced in [46] whose goal is to preserve the battery life of WSN nodes and to produce an active sensing network.The FLC suggested in [46] assists efficiently to ascertain the on/off state for active/sleep mode of sensor nodes.Simulation results prove that the proposed system is energy efficient.Considering that, usually, in a WSN most of the energy is spent in data communication to the sink and that, in recent years, several researchers have offered mobile sink methods to lessen the energy consumption, the authors of [47] present an approach in which a fuzzy-based mechanism administers the movement of the sink.Simulation results are compared with a method having a stationary base station, and results emphasize that the strategy recommended by the authors reduces the energy consumption and, thereby, enhances the lifetime of the WSN.Another approach, based on a distributed fuzzy logic control method, is offered in [48].This fuzzy logic engine is developed on each node of the wireless network to decrease the number of message transmissions.Even in this case, the procedure proposed by the authors is compared with others in the literature, and the results are promising concerning energy consumption.Another method is proposed in [49] where the authors introduce a novel solution for cluster formation in WSNs that uses fuzzy logic to improve the network lifetime.The obtained results reveal that the protocol proposed by the authors advances the overall network lifetime.Another fuzzy-based clustering solution is introduced in [50] where the main aim is to extend the lifetime of a WSN.The obtained results reveal that this approach also resolves the ineffectual utilization of the remaining energy in sensor nodes efficiently with the cooperation of the proper cluster head selection method.The authors of [51] propose a fuzzy-based algorithm to increase the network lifetime and to enhance the energy efficiency of WSNs.The sectors of the network are formed, through a fuzzy inference system, taking into account the residual energy of nodes and the proximities to the base station.Simulation results are promising since the proposed solution can extend the total number of live nodes and increasing the lifetime of nodes on each round.Another fuzzy-based approach that deals with the power management in WSNs is proposed in [52].In this case, the goal is to adjust the duty cycle of the sensing node dynamically.The experimental results highlight that the proposed method outperforms other comparing methods concerning the residual battery energy and exercised duty cycle.
The paper is organized as follows.The system architecture is described in Section 2, while the fuzzy-based approach and the considered membership functions are introduced in Section 3. The performance gained by the proposed method, from simulations and real testbed, is presented In Section 4. Lastly, in Section 5, the paper is summed up reporting conclusions.

System Model
Widespread networks of inexpensive wireless sensor devices concede a valuable opportunity to check more precisely the surrounding physical phenomena's when compared to conventional sensing methods.WSNs for smart homes are distinguished by scenarios in which tiny devices, like actuators and sensors, use most of their time in a sleep state and wake up with a given periodicity or when a critical event occurs.The WSN has its design restrictions, correlated with the purpose and the features of the installation context.The latter delimit the extension of the network, the deployment scheme, and the network topology.The network structure considered in this paper is represented in Figure 1 and is composed of several Home Monitoring Cells (HMCs) based on the IEEE 802.15.4 wireless standard [38].
Two network topologies are maintained by the IEEE 802.15.4,i.e., peer-to-peer and star.Several purposes would typically employ a one-hop star topology.On the contrary, the peer-to-peer topology can be adopted for more elaborate arrangements, like the cluster-tree and mesh networking topologies, and can be the favored option for purposes such as smart homes.An IEEE 802.15.4 network can operate either in beacon-enabled or in non-beacon-enabled mode.In the former method, the transmission is managed by a network coordinator, which delivers regular beacons for synchronization and correlation procedures.In the non-beacon-enabled mode, there are no regular beacons, but the coordinator may unicast beacons to a soliciting device.The transmission among devices in the non-beacon-enabled mode practices the un-slotted CSMA (Carrier Sensing Multiple Access) for decentralized access.Furthermore, in the beacon-enabled method, the standard permits the energy saving by fulfilling the duty cycling, so that all nodes can periodically go to sleep.For this reason, in this paper, the IEEE 802.15.4 network works in the beacon-enabled mode.The wireless network for smart home considered in this work is constituted by all the HMCs within which various devices are dealing with a specific task.Considering the IEEE 802.15.4 standard, Reduced Function Device (RFD) nodes evaluate a physical parameter of the monitored environment, such as temperature, humidity, light, smoke density, carbon monoxide, and so on.Suddenly, they send the acquired data to their Full Function Device (FFD) nodes.An FFD node could be a ZigBee router [53].It forwards data obtained by RFD nodes to the First Pan Coordinator (FPC) that processes information and sends proper command messages to the sensor nodes.It is helpful to note that in the IEEE 802.15.4 the transmission range changes considerably based on the nature of the path that must be in a line of sight (LOS) for the most part.The transmit power level and receiver sensitivity are also characteristics to take into account.Under the favorable conditions, the range can be as high as 1000 m with a clear outdoor path.In this case, proper hardware with range extender is needed to improve the receiver sensitivity and increase the total link budget, enabling up to four times the range of each node in the network.For instance, considering ZigBee PRO [54], sub GHz channels transmission ranges up to 1 km.Most applications cover a shorter range of 10-75 m.Anyhow, it is essential to take into account the energy consumption of battery-powered wireless devices.Accordingly, the Fuzzy Controller presented in this paper, detailed in Section 3, can be a proper solution to ensure adequate power consumption management.This module dynamically handles sampling times to increase the sleeping periods of sensor nodes.In this way, it is feasible to increase energy savings and, at the same time, prolong the batteries and network life-cycle.

Fuzzy Controller
In smart homes applications, the battery-powered end nodes discover information on the environment in which they are located continually.Hence, it can be advantageous to develop an energy control model to guarantee network versatility, adjustability, and scalability.Besides, this mechanism must be able to optimize power resources and, at the same time, to increase the life-cycle of devices.In the WSN considered in this paper, it is not reasonable to define the behavior of all nodes preventively since they are often employed to monitor sporadic events.Nevertheless, data generated by WSNs can be considered as periodic, as stated in [55].
In this paper, a smart approach is proposed to adjust the sleeping time of battery-powered field devices in an IEEE 802.15.4 network for smart homes, with the aim of diminishing their power consumption.Each RFD transmits information about its working conditions to the FPC when its sleeping time is expired.The FPC is a unique device developed adequately for performing computational tasks.Anyhow, it is useful to remark that, generally, in an IEEE 802.15.4-based network, the FPC nodes are not always battery-powered.
A comprehensive illustration of the system introduced in this work is pictured in Figure 2.Although the representation is simplistic and generic, it shows explicitly what are the input contents of the FLC and also the one that returns as output.It is valuable to mention that the proposed FLC is applied to save the battery life and to have an efficient and cost-effective sensing network to monitor the event of interest in a smart home.The arrangement of the FLC displayed in Figure 2 is simplistic because it enables both a straightforward implementation on real devices and, mainly, a low computational complexity.The proposed system comprises small data exchanges, as the data to be transferred to the FLC are the ratio of Throughput to Workload (Th/Wl) and the battery level of the device.This situation involves a lower computational cost than, for instance, other approaches based on more complex fuzzy controllers (such as Type-2 fuzzy or Petri net), other methods that utilize different controllers in parallel (for instance, a FLC in each cluster in the network), or other solutions that consider several parameters (more than two) as the inputs to the controller.These qualities of the Fuzzy Controller not only concede to execute the proposed approach on low-cost hardware but are also are expected to be advantageous concerning lower data processing times and lower command actuation rates for the fuzzy logic controllers.As shown in Figure 2, in the proposed solution the FPC node employs an FLC to ascertain the new values of the sleeping_time of each RFD.The FLC settles the sleeping_time of the RFD taking into account the ratio of Throughput to Workload (Th/Wl) and the battery_level.The throughput [56] (Equation ( 1)) is the quantity of data transferred from one node to another in a specified measure of time, i.e., how many packets are transferred over some time.

Throughput =
data trans f erred time interval On the contrary, the workload (Equation ( 2)) is the quantity of data that a device has to transfer in a defined measure of time.Then, the workload is the number of packets that the device has to send.The Th/Wl returns a percentage value due to the ratio of the number of packets that are obtained at the target and the number of packets that have been transmitted.If the Th/Wl value is 100% then all the transferred packets have reached the destination.

Workload =
data to trans f er time interval (2)

Used Membership Functions
A Membership Function (MF) is a graphical representation that determines how every location in the input area is outlined to a degree of membership between 0 and 1.The input range is seldom mentioned as the universe of discourse.An MF can possess various aspects.Nevertheless, in this article, trapezoidal MFs have been granted.It is necessary to describe the scientific illustration of these MFs (available in the literature) concisely as they are the basis for the explanation of the inference rules employed by the FLC introduced in this work.
Considering a general variable x containing a series of values from the minimum to the maximum that the variable itself can arrogate, each MF can be realized, for instance, in a generic trapezoidal-shaped way [57].In detail, considering the Figure 3, this MF is defined by a lower limit a, an upper one d, a lower support limit b, and an upper support one c, where a < b < c < d:

Description of the FLC
The FLC introduced in this paper considers three MFs (Low, Medium, High) for the input variables.These functions fuzzify the crisp inputs, while the ranges of which are:

•
Th/Wl: [0, 100] (percentage); • battery_level: [0, 1024], where 0 is the lowest level of battery while 1024 is the highest one and it is the maximum value at the output of a 10-bit AD converter (with an appropriate electronic signal conditioning circuit. Furthermore, three MFs (Low, Medium, High) are applied for the sleeping_time.In this case, the range of the crisp values of this output variable is: where the sampling_time value is a constant value defined at design time for each field device.
Trapezoidal MFs of the Th/Wl, the battery_level and the sleeping_time are depicted in Figure 4, where the degree of membership is represented by normalized values [0, 1].Moreover, considering the Equation ( 3), the different values of the variables are depicted in Table 1.
As presented in Table 2, the output value is discovered through 9 fuzzy rules.They are based on the IF-THEN statement of standard programming languages.For instance, regarding rule 5, if the Th/Wl is Medium and battery_level is High, then the sleeping_time will be Low.The outputs of the inference mechanism are fuzzy output variables.The FLC needs to turn its internal fuzzy output variables toward crisp values, through the defuzzification method, so that the system can practice these variables.The defuzzification can be performed in several ways.In this paper, the Centroid of Area (COA) method [58] has been chosen.

Model Development
Several assessments have been conducted to compare the proposed method with another similar in the literature.The method of Wang et al. [46] has been taken into account.In the wireless network, both the FPC, FFD, and RFD nodes are provided with a micro-controller and a wireless module IEEE 802.15.4 compliant.The values used in the simulations have been deduced from the following devices: The simulations have been administered with a model built in Simulink/Matlab pictured in Figure 5.The main aim of this model is to simulate the procedure between a coordinator and a sensor.Precisely, the Sensor Node block accomplishes the battery waste of the RFD node.The sleeping_time, the transmission power (TXPower) and the power in receiving (RXPower) are earned as inputs of this block through a feedback loop system.This block returns two output variables (Th/Wl and battery_level) that are employed as input variables by the FLC.It is useful to remark that the actions of the micro-controller and a joined sensor have a low impact on battery consumption.Their power demand is evaluated at 50 − mA (MC PC ).This value has been measured in an electronic board distinguished by the PIC24FJ256GB108 micro-controller and a DS18B20 [61] sensor.Therefore, the energy waste is related to the working state of the device.When the device is sleeping, the battery consumption is 50 mA + 5 µA (5 µA is the power consumption of the IEEE 802.15.4 module in sleeping mode, obtained from the datasheet [60]).Contrarily, when the device is transmitting, the transmission power profoundly influences energy consumption.The battery loss trend is evaluated concerning the sleeping time through the Simulink/StateFlow environment.This tool practices flow charts and finite state machines to describe the evolution of a system.The Chart section, created in Simulink/StateFlow, related to the operation of the battery loss, is pictured in Figure 6.
Considering a 10.8 V lithium-ion battery in the performance evaluation, the maximum level of the battery when it is completely energized is 3100 mAh (FullBattery), while the comparable digital value, acquired through a 10-bit AD Converter, is 1024 (MaxDV).It is significant to perceive that when the device is in sleeping mode, the power consumption is largely due to the micro-controller and the sensor since the radio frequency transceiver consumption is negligible, as shown also in [43,[62][63][64][65].In this case, the consumption is 0.0046 bit/s.The following relation determines this value: where the number of seconds in an hour is 3600.By employing the Equation ( 4) the power consumption of each device in sleeping mode is: In case of maximum transmission power (0 dB) the radio frequency transceiver consumption is 130 mA [60].As shown in Figure 5 the TXPower value is obtained as follows: The evolution of StateFlow is established to 1 second.In the transmission mode, the system is unmistakably in his ActiveState, so able to receive.It is required to check the receiving power, 19 mA [60], then the RXPower value is accomplished as follows: 19 × 1024 3100 × 3600 = 0.0017 (7) The idle state of sensor nodes is not supposed.Idle listening would be another source of energy loss because a sensor node starts this mode when is listening for traffic that is not sent.Lastly, the proposed FLC gets the Th/Wl and battery_level as input variables and dynamically produces the sleeping_time.Anyhow, beyond the battery considered in this paper, it is necessary to note that the proposed approach can be used with any battery, concerning voltage and capacity.

Obtained Results
Several simulations have been carried out to prove the proposed solution.Both the ratio of Throughput to Workload (Th/Wl) and the battery level have been assessed.The battery level during a simulation period of 48 h is depicted in Figure 7.Even the results achieved without FLC have been taken into account, i.e., assuming that the transmission power (0 dB) and the sleeping time (equal to 1, coinciding with the sampling time) are both fixed.Figure 7 reveals that the proposed fuzzy-based approach reaches a real power consumption reduction and, consequently, it lengthens the device lifetime.Using trapezoidal MFs, the battery is fully discharged after about 169,950 s (47 h and 21 min).In the case without the FLC, the battery is fully discharged much earlier, after about 120,000 s, i.e., after 33 h and 50 min.Hence, is evident that the trapezoidal MFS has obtained concrete improvement respect to the case without FLC.Using the approach proposed by Wang et al. the battery is fully discharged after about 155,600 s (43 h and 22 min).Even in this case, it is proved that the performance of the proposed fuzzy-based solution is better than the one proposed by Wang et al.During the simulation period of 48 h, the ratio of Th/Wl has been assessed, and its performance is represented in Figure 8.As it is possible to recognize, practicing the fuzzy-based approach proposed in this work the Th/Wl flutters between about 20% and 70%.Considering the method suggested by Wang et al. the Th/Wl range differs from 25% to 59% on average.On the contrary, the values collected without FLC fluctuate from 31% to 77%, representing the soundest results concerning the ratio of Th/Wl but at the expense of the battery consumption.Nevertheless, it is essential to remark that the values obtained with the proposed FLC and even those measured with the approach of Wang et al. are satisfactory particularly in those application fields in smart homes with a reasonable variety of data, e.g., temperature, humidity or light detection.In these cases, the most relevant goal is to increase, as much as possible, the battery life rather than guaranteeing high Th/Wl performance.Instead, the Th/Wl behavior achieved with the proposed FLC would not be appropriate in a context characterized by real-time constraints, in which the sleeping_time of network nodes should not be increased too much to obtain and ensure high values of the ratio Th/Wl.
A real testbed scenario has been effectuated to prove the obtained results also on physical hardware devices.This situation allows demonstrating both the facility of implementation of the fuzzy-based approach proposed in this paper and its effectiveness.The hardware boards used in the considered IEEE 802.15.4 network for smart home use the Microchip PIC24F [59] and the MRF24J40MB IEEE 802.15.4 Radio Frequency Transceiver [60].The Microchip PIC24F integrates the control characteristics of a microcontroller unit with the processing and throughput capacities of a digital signal processor.This 16-bit microcontroller has a maximum processing power of 16 MIPS and grants multiple serial ports (3xI2C, 3xSPI), 4xUARTS and 23 independent timers.The availability of 16 kB of RAM memory for buffering, of up to 256 kB of enhanced flash program memory, and other features make this microcontroller very suitable for low power (<100 nA standby current), embedded control and monitoring applications.The considered WSN has been a star network with one central network controller and 4 sensor nodes that communicate directly with the network controller.Considering the MRF24J40MB at 2.4 GHz operating mode, the data rate is 250 kbps, while the initial sleeping_time has been set to 5 s.The fuzzy controller, based on trapezoidal MFs, has been realized in the micro-controller PIC24F of the network controller, in C language, through the embedded code generator included in Matlab/Simulink.The network controller gets the battery level from each field device and, then, transmits a frame to them with the indication of the sleeping time.The retrieved results, summed in Table 3, are comparable to those collected through the Matlab simulations.It is useful to note that the data acquired in the testbed are lower because the power wasted by the devices in the idle mode has not been taken into account during the simulations, as stated previously.Nonetheless, using the solution introduced in this paper, the battery life extends considerably compared to both the case without FLC and the method of Wang et al. even in the testbed scenario.These values prove the goodness of the proposed solution and that the purpose of this work is fulfilled.Additionally, the retrieved results reveal that the solution here proposed is flexible and efficient regarding the energy consumption control of battery-powered nodes in WSNs for smart homes that do not require expensive and complicated hardware and so can be implemented on low-cost Commercial Off-The-Shelf (COTS) devices.

Conclusions
A fuzzy logic-based mechanism has been introduced in this paper to improve the lifetime of devices in smart homes applications based on WSNs.The fuzzy-based approach presented in this work dynamically adjusts the sleeping time to extend the battery duration of the sensor devices.This paper has proposed a smart approach that couples several technologies (i.e., WSN and fuzzy logic control) to achieve a lightweight but effective solution, implementable on COTS devices, that is proven to provide better performance than other approaches.Simulations results, obtained with Matlab, have been auspicious and confirm that adopting the proposed FLC an ample decrease of the energy consumption is achieved.Regarding the Th/Wl, measured values are satisfactory particularly in those application fields with a moderate variation of data where the most important thing is to prolong, as much as possible, the battery life rather than to ensure high Th/Wl performance.The workability of the proposed system on real hardware is validated through implementation on a prototyping board based on the Microchip PIC24FJ256GB108 microcontroller [59], a COTS device accessible at affordable price.Experimental results are compliant with simulation ones and confirm the effectiveness of the proposed solution.The potential impact of the proposed approach is broad as, being a non-expensive arrangement to actualize, it can be broadly and efficiently employed in practice.Besides, the suggested approach satisfies several targeted design requests, i.e., scalability, lightweight computation, flexibility, and low cost.

Table 1 .
Values of variables used in definition of trapezoidal membership functions.

Table 3 .
Battery lifetime obtained from simulations and measured in the testbed.