An extremely high number of geographically dispersed, energy-limited sensor nodes make up wireless sensor networks. One of the critical difficulties with these networks is their network lifetime. Wirelessly charging the sensors continuously is one technique to lengthen the network’s lifespan. In order to compensate for the sensor nodes’ energy through a wireless medium, a mobile charger (MC) is employed in wireless sensor networks (WRSN). Designing a charging scheme that best extends the network’s lifetime in such a situation is difficult. In this paper, a demand-based charging method using unmanned aerial vehicles (UAVs) is provided for wireless rechargeable sensor networks. In this regard, first, sensors are grouped according to their geographic position using the K-means clustering technique. Then, with the aid of a fuzzy logic system, these clusters are ranked in order of priority based on the parameters of the average percentage of battery life left in the sensor nodes’ batteries, the number of sensors, and critical sensors that must be charged, and the distance between each cluster’s center and the MC charging station. It then displays the positions of the UAV to choose the crucial sensor nodes using a routing algorithm based on the shortest and most vital path in each cluster. Notably, the gradient-based optimization (GBO) algorithm has been applied in this work for intracluster routing. A case study for a wireless rechargeable sensor network has been carried out in MATLAB to assess the performance of the suggested design. The outcomes of the simulation show that the suggested technique was successful in extending the network’s lifetime. Based on the simulation results, compared to the genetic algorithm, the proposed algorithm has been able to reduce total energy consumption, total distance during the tour, and total travel delay by 26%, 17.2%, and 25.4%, respectively.