In the complex environment of microgrid deployments targeted at geographic regions, the seamless integration of renewable energy sources meets a variety of essential challenges. These include the unpredictable nature of renewable energy, characterized by intermittent energy generation, as well as ongoing fluctuations in load demand, the vulnerabilities present in distribution network failures, and the unpredictability that results from unfavorable weather conditions. These unexpected events work together to disturb the delicate balance between energy supply and demand, raising the alarming threat of system instability and, in the worst cases, the sudden advent of damaging blackouts. To address this issue, a fuzzy logic-based energy management system has been developed to monitor, manage, and optimize energy consumption in microgrids. This study focuses on the control of diesel generators and utility grids in a grid-connected microgrid which manages and evaluates numerous energy consumption and distribution features within a specified system, e.g., building or a microgrid. An energy management system is suggested based on fuzzy logic as a swift fix for complications with effective and competent resource management, and its presentation is compared with both the grid-connected and off-grid modes of the microgrid. In the end, the results exhibit that the proposed controller outclasses the predictable controllers in dropping sudden variations that arise during the addition of sources of renewable energy, supporting the refurbishment of the constant system.