# Wireless Sensor Networks for Smart Homes:
## 3 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/WI\)) 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/WI\)) 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=\frac{data}{time}\frac{transferd}{interval} \tag{1}\]  
Figure 2: The proposed FLC architecture.  
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=\frac{data\quad to\quad transfer}{time\quad interval} \tag{2}\]