Microgrids are a promising solution for decentralized energy generation and distribution, offering reliability, efficiency, and resilience. These small-scale power systems can operate independently or connect to the main grid, providing greater reliability and resilience. However, integrating renewable energy into microgrids presents challenges due to their unpredictable nature and fluctuating load of electricity. Energy management strategies play a crucial role in optimizing the operation of microgrids, aiming to balance electricity supply and demand, maximize renewable energy utilization, and minimize operational costs. Various approaches have been proposed for energy management in microgrids, including optimization algorithms, machine learning techniques, and intelligent control systems. This study proposes an optimized and efficient strategy for microgrids operating in both independent and grid-connected modes, focusing on microgrids that utilize a combination of solar and green energy sources. The proposed approach, based on the Promoted Remora Optimization (PRO) algorithm, aims to meet load power requirements at the lowest possible cost while ensuring constant DC bus voltage and safeguarding batteries against overcharging and depletion. The CRO method effectively optimized the charging process, maintaining a consistent level of charge and achieving a final SoC of 33.37 %–33.60 %. It also demonstrated high system efficiency, with an average of 87.99 %, and a range of 87.80 %–88.03 %. The optimizer efficiency ranged from 83.12 % to 86.52 %, with an average of 86.46 %. The CRO method also achieved reasonable operating costs, with a cost per power of $0.1687/kW to $0.1699/kW and a daily cost of $1,379,595 to $1,479,998. Overall, the CRO method showed promise in optimizing the charging process in terms of efficiency and cost-effectiveness. Comparative analysis with existing literature is conducted to evaluate the effectiveness of the proposed approach, demonstrating its superior results compared to other energy management strategies for microgrids. This study contributes to the field of microgrid energy management by providing a novel approach based on the PRO algorithm and demonstrating its effectiveness through comparative analysis.