## 1 Introduction  
Wireless sensor networks (WSNs) are among the most popular communication media for many real-time applications due to their size, cost and deployment characteristic [1]. WSNs are made up of self-organizing sensors, which can build an adaptive multi-hop network and send optimized data packets to the base station (BS) for post-processing analysis [2, 3]. Some WSN implementations make use of a lot of sensor nodes. The residual energy and memory of these wireless nodes are the biggest challenging task for implementation. Therefore, in order to maximize the benefits of these WSNs, the WSNs nodes must have a system for controlling the interactions with one another as well as an access point [4, 5]. Digital data, such as images or videos, are used extensively in WSNs. WSNs are very useful in several real-life applications, viz., agriculture, small scale and/or large-scale industry, military surveillance, weather monitoring, healthcare and smart homes/smart cities [6, 7] which all use multimedia data. Multimedia data that contain images and videos are commonly large which generally increase the energy consumption of each sensor node. However, the energy consumption can be optimized by using several algorithms [8, 9]. The widespread deployment of large-scale WSNs is being driven by recent developments in semiconductor, networking and material science technologies. These technologies have enabled a new generation of WSNs that are significantly different from wireless networks created and implemented as recently as five to ten years ago. Modern WSNs are more reliable, cost effective to deploy and maintain and are also more resilient. Although there was no such technology for extensive industrial and consumer application in the 20 th century, both academia and industry had seen the possibilities for such networks and collaborated to overcome the engineering barrier. Examples of these academia/industrial initiatives include (i) UCLA wireless integrated network sensors, (ii) University of California at Berkeley Pico radio program, (ii) NASA sensor webs and (iv) the Zigbee alliance. Security is one of the biggest issues with WSNs, which has a significant impact on energy usage. The complexity of a WSN's security increases with node power consumption and vice versa. The two main concerns where new research can make only limited progress are the requirement for reducing energy use and enhancing network security [10; 11]. In the study of WSN, energy efficiency has emerged as a key topic. The restrictions imposed by the batteries used to power such devices may be the cause of the interest in energy efficiency. These batteries typically serve as the primary source of energy for these devices, and they have a finite lifespan before needing to be recharged or discarded. For precision agricultural, environmental, disaster, environmental, structural, health, security applications and military surveillance, WSNs are the foundation of ubiquitous computing. Since sensor nodes are typically deployed in harsh environments with low battery capacities, their lifespan is typically a significant concern. Using sophisticated network security protocols and sending and receiving digital information can have a significant impact on network lifetime. Numerous mechanisms, including clustering and routing protocols, are utilized [12; 13; 14] to enhance energy efficiency by extending network lifetime. Complex network security and energy conservation have become crucial concerns in WSNs due to the number of sensor nodes and the exchange of digital information. In order to increase energy efficiency and maximize network lifetime, a new algorithm must be developed. Hence, to increase network lifetime, a new optimal algorithm is proposed in this study that is capable of selecting the cluster head (CH) in each round based on specific constraints. Wireless communication in WSNs uses a clustering strategy.