This paper proposes an energy management strategy using artificial neural networks (ANNs) to integrate multiple energy sources, including photovoltaic generators, diesel generators, and public grid, ensuring a continuous electricity supply, especially for critical loads. The proposed system addresses challenges related to the random operation of renewable energy sources by maximizing their utilization while maintaining safety protocols for battery management and generator operation. Overall, the study demonstrates the effectiveness of ANNs in enhancing the reliability and efficiency of smart grid systems.