This paper addresses the issue of surplus energy produced during batteries charging in a standalone photovoltaic (PV) system consisting of a PV array, house equipment’s and batteries. The energy management algorithm does not utilize energy excess when the batteries are charged, reducing overall efficiency and robustness. This paper proposes an enhanced energy management algorithm that improves the system efficiency while employing excess energy for irrigation, presenting a valuable solution for agriculture. The energy management unit ensures effective communication among system components, aiming to extend the batteries lifespan and maintain their state of charge within optimal limits of 20% to 90%. Simulations conducted with MATLAB/Simulink over 72 hours under varying irradiance conditions demonstrate the proposed algorithm effectiveness and robustness in protecting batteries from deep discharges and high overcharges and feeding a water pumping system for agriculture purposes besides the house requirements.