Wireless sensor networks (WSNs) play a crucial role in the Internet of Things (IoT) for ubiquitous data acquisition and tracking. However, the limited battery life of sensor nodes poses significant challenges to the long-term scalability and sustainability of these networks. Wireless power transfer technology offers a promising solution by enabling the recharging of energy-depleted nodes through a wireless portable charging device (WPCD). While this approach can extend node lifespan, it also introduces the challenge of bottleneck nodes—nodes whose remaining energy falls below a critical value of the threshold. The paper addresses this issue by formulating an optimization problem that aims to identify the optimal traveling path for the WPCD based on ant colony optimization (WPCD-ACO), with a focus on minimizing energy consumption and enhancing network stability. To achieve it, we propose an objective function by incorporating a time-varying z phase that is managed through linear programming to efficiently address the bottleneck nodes. Additionally, a gateway node continually updates the remaining energy levels of all nodes and relays this information to the IoT cloud. Our findings indicate that the outage-optimal distance achieved by WPCD-ACO is 6092 m, compared to 7225 m for the shortest path and 6142 m for Dijkstra’s algorithm. Furthermore, the WPCD-ACO minimizes energy consumption to 1.543 KJ, significantly outperforming other methods: single-hop at 4.8643 KJ, GR-Protocol at 3.165 KJ, grid clustering at 2.4839 KJ, and C-SARSA at 2.5869 KJ, respectively. Monte Carlo simulations validate that WPCD-ACO is outshining the existing methods in terms of the network lifetime, stability, survival rate of sensor nodes, and energy consumption.