This paper introduces a fault node recovery algorithm (FNR) designed to enhance the lifetime of wireless sensor networks (WSNs) by addressing power depletion issues in sensor nodes. The FNR algorithm integrates grade diffusion and genetic algorithms to minimize sensor replacements, maximize active nodes, and reduce data loss and energy consumption. Simulation results indicate that the FNR algorithm significantly outperforms traditional algorithms, achieving up to 98.8% less data loss and 31.1% lower energy consumption.