## 5 Fuzzy Logic-Based WSN Power Management and Optimization
The results of the proposed mechanism achieved a real power consumption reduction and prolonged the network lifetime. Further, the algorithm used three input variables: sleeping time, battery level, and the ratio of throughput to workload. Moreover, the proposed FLC employs three membership functions (low, medium, and high) for each input and output linguistic variables. The FLC must convert its fuzzy output variables in crisp values by using de-fuzzification method so that the system can understand them. Several methods can accomplish the de-fuzzification process. In this study, the COA method was selected. In this scheme, the COA of each membership function, for each rule, is first estimated. The final output is then measured as the average of the individual COA weighted by their membership values. [PERSON] et al. [55] proposed a fuzzy logic-based adaptive energy management mechanism through the particle swarm optimization algorithm (FLC-PSO) in order to improve the energy efficiency for WSN. The proposed mechanism considered the most important performance factors of WSN, namely, the overall remaining energy and the number of dead nodes, which were used as the input variables of the fuzzy system depicted in Figure 13. The aim of using PSO is to optimize the membership functions, and the optimization goal is to minimize the number of dead nodes and maximize the remaining energy in order to reach an optimal fuzzy logic controller. Simulation results proved that the proposed FLC-PSO  
Figure 12: The proposed fuzzy sink selection paradigm. mechanism outperformed its literature counterparts. Therefore, FLC-PSO provides an efficient energy management mechanism for WSN. [PERSON] et al. [56] proposed a fuzzy logic-based algorithm to overcome the WSN energy consumption problem in battery device nodes in an IEEE 802.15.4 network for smart home applications. Considering the duty cycle, the sleeping time of nodes is dynamically set by the FLC. The proposed mechanism in this work is an extension of the work presented in [54]. The main goal of this work was to design a system that could be executed using off-the-shelf hardware. In this study, a different type of membership function was used in the FLC to realize a practical method that reached the goal while avoiding complicated and computationally costly solutions, such as PSO, which would decrease the possible applicability of the procedure in real situations. The goal was to develop a proof-of-principle implementation utilizing off-the-shelf devices, highlighting that the suggested method does not demand compelling hardware and can be openly realized on low-cost devices. Similar to the work presented in [54], the proposed mechanism used two input variables to the FLC: throughput to workload and the device battery level. Further, it had three membership functions: throughput to workload, the device battery level, and sleeping time. The proposed method operates as follows: the first pan coordinator node utilizes an FLC to realize the output values of the sleeping_time of each reduced function device. The FLC fixes the sleeping_time of the RFD by considering the ratio of throughput to workload and the battery_level. The FLC has three membership functions (low, medium, and high) for the input variables. These functions fuzzify the crisp inputs, and the range for input variables are 0 to 100%, with 0 to 1024 for the TH/WL and battery_level, respectively. Furthermore, the output variable has three membership functions (low, medium, and high); the range of the crisp values of this output variable is 0 to 10 s. Trapezoidal membership functions are applied to the TH/WL, battery_level, and sleeping_time, where the degree of the membership is represented by normalized values from 0 to 1, and the output value is obtained on the basis of nine IF-THEN fuzzy rules. The FLC converts internal fuzzy output variables into crisp values through the de-fuzzification method so that the system can understand these variables. The de-fuzzification used in this study is the COA method.