Industrial Wireless Sensor Networks (IWSNs) allow the use of battery-operated nodes to provide easy deployment, even in harsh environments, and are low maintenance. The optimal network design can be difficult because several constraints and requirements must be considered among all the power consumption. For this reason, specific approaches, also based on soft computing methods, can be applied in such a way as to further decrease the energy consumption in IWSNs. To this end, this paper proposes a fuzzy logic based mechanism that, according to the battery level and the ratio of throughput to workload, defines the sleeping time of sensor devices in an IWSN based on IEEE 802.15.4 protocol. A particle swarm optimization (PSO) algorithm is introduced to obtain the optimal values and parameters of the proposed fuzzy logic controller (FLC), i.e., optimizing the membership functions, by varying their range, to achieve the best results regarding the battery life of sensor nodes. This paper provides a detailed description of the FLC configuration, a logical analysis of the PSO algorithm for the derivation of best performance conditions values, and simulative assessments obtained through MATLAB simulations. [ABSTRACT FROM AUTHOR]