The proliferation of mobile devices and the spread of IoT devices have increased the tendency to use wireless sensor networks (WSNs), especially since the implementation of the 5G communication system has begun in most countries. This type of network does not require any infrastructure or additional cost, making it a good alternative for use in disasters, environmental monitoring, military, and rescue operations. However, WSNs suffer from some limitations, such as mobility and battery lifetime. Significant research has been conducted to overcome the limitation of battery lifetime by developing routing methods and reducing the required communications among wireless mobile nodes. In this research, we utilize the low-energy adaptive clustering hierarchy (LEACH) concept to minimize communication between the nodes and the base station. A new approach has been developed to form clusters in WSN nodes and select the optimal cluster head by facilitating the election of a new cluster head (CH). When the current cluster head’s energy depletes, a new one is selected, ensuring continuous operation. The simulation results demonstrate that the proposed algorithm outperforms the existing LEACH clustering algorithm in terms of energy consumption, packet delivery ratio (PDR), and latency time.