Wireless energy transfer (WET) is a revolutionary method that has the power to tackle the energy and longevity challenges in wireless sensor networks (WSN). This paper uses a mobile charger (MC) to discover the procedure of WET based on a wireless sensor network (WSN) for a periodic charging technique to maintain the network operational. The goal of this work is to lower overall system energy consumption and total distance traveled while increasing the mobile charger device vacation time ratio. Based on an analysis of total energy consumption, a new metaheuristic called mayfly algorithm (MA) is used to achieve energy savings. Instead of charging all nodes at the same time in each cycle, in our strategy, the mobile charger charges only energy-hungry nodes due to their levels of energy. In this strategy, when the first node reaches the calculated minimum energy, it notifies the base station (BS), which computes all nodes that fall under threshold energy and sends the MC to charge all of them to the maximum energy level in the same cycle. Mathematical results show that the mayfly algorithm can considerably decrease the charging device’s total energy consumption and distance traveled while maintaining performance because it can keep the network operational with less complexity than other schemes.