## 1 Introduction  
Advancements in the field of information communication technology have paved the way for the establishment of WSNs [1, 2]. Generally, WSNs consist of tiny and low-cost sensors whose major function is to sense information from a particular environment and transmit it through a wireless network to the monitoring zone. WSNs have a wide range of applications in various fields such as defense, agriculture, healthcare, smart cities, smart building emergency rescue, and vehicular applications. The main processing unit in the sensors is a battery [3, 4] for the effective functionality of sensor node. The batteries are powered with minimum energy owing to the minor nature of the sensor nodes. At the same time, it is very complex to replace the sensors once they are deployed. Therefore, energy efficiency is a major concern in WSNs [5]. Previous research on WSNs has shown that significant energy is consumed during data transmission. This transmission process relies mainly on routing protocols. Thus, it is essential to design an energy-efficient routing strategy to reduce energy consumption, thereby improving the network lifetime [6, 7].  
Following energy depletion, another major issue faced in wireless networks is security because wireless signals are subjected to various attacks. The increase in the usage of WSNs in various applications has resulted in considerable vulnerabilities to malicious attacks [8; 9]. Therefore, to secure information from malicious attackers, efficient security protocols must be designed for WSNs applications. The third significant challenge faced in WSNs is providing a better Quality of Service (QoS) [10]. To offer better QoS, to calculate metrics such as increased packet delivery ratios, throughput, latency, decreased time delay, packet loss, and energy consumption, are needed.  
By satisfying this requirement, a better QoS in the WSNs can be attained [11]. Several scholars have performed various studies to design energy-efficient and secure routing protocols for WSNs. Most existing WSN protocols are designed based on optimization algorithms and artificial intelligence systems. Some of the existing routing protocols related to WSNs are the hybrid hierarchical secure routing protocol (HHSRP) [12], QoS-aware Energy Balancing Secure Routing (QEBSR) [13], energy-efficient clustered gravitational and fuzzy-based routing algorithms [14], and energy-balanced zone-based routing protocols [15]. However, these existing routing approaches lack efficient energy conservation and data privacy preservation. Therefore, an energy-aware and secure routing protocol for WSNs must be developed for smart building applications. The main motive of the proposed framework is as follows:  
* To design a grid-based network structure for attaining energy conservation and securing data transmission in smart building WSNs.
* An optimal routing path selection based on a fuzzy interference system attains an enhanced packet delivery ratio.
* To select the best grid organizer, a meta-heuristic algorithm, namely the sailfish optimizer, was utilized.
* For the optimal selection of the grid organizer, the residual energy and distance were considered as objective functions.
* A two-fish encryption algorithm is used to achieve trust-based routing.  
The remainder of the manuscript is organized as follows: Section 2 reviews articles related to various routing approaches in WSNs. Section 3 discusses the background of the proposed methodology. A detailed explanation of the proposed framework is provided in Section 4. Section 5 presents the results obtained through the implementation. Finally, Section 6 concludes the study.