SummaryUnmanned aerial vehicle (UAV)‐enabled wireless sensor networks (WSNs) have evolved as the significant paradigms to communicate the information among the devices in today's scenario instantly. These technologies support for developing smart crop spraying, smart infrastructure, aerial photography and videography, emergency services, etc. in providing smart solutions. Therefore, there is a dire need to develop an energy‐efficient solution for data gathering through UAVs. In this paper, an optimum weighted probability function is proposed by considering residual node energy, node spacing, and average energy of networks. This function helps in optimizing the clustering process for three‐tier heterogeneity by minimizing the energy of the proposed network. The proposed methods achieve 29.45% and 52.48% increment in the network lifespan as compared to the existing algorithm. The reason for such a gigantic enhancement in the network lifespan is the selection of the highest capable node as a cluster head using the proposed function.