• A complete Fuzzy-based energy management system design for an isolated microgrid comprising a photovoltaic system, diesel generator, and energy storage system. • The complete procedure for tuning the parameters of a fuzzy logic controller using metaheuristic optimization algorithms. • Analyzes the state of health of the energy storage system of an isolated microgrid in a rural area of Ecuador. • A hardware-in-the-loop validation using the Typhoon HIL-405 device and Matlab. Rural areas have increased directly with the growth of the world population. Although, isolated rural areas do not have the energy infrastructure to supply essential services such as electricity. In Ecuador, as in the rest of the world, these areas of the rural population usually present access problems due to the topography of the place. This makes the construction of power lines to connect them to the Interconnected National Energy System unfeasible. In this regard, isolated microgrids have emerged as a great solution to cover the energy demands in these locations. However, an optimal implementation of isolated microgrids depends on several factors, such as geographical location, weather conditions, sizing, load demand, operating costs, and social impacts. Therefore, this study proposes the design of a new energy management system (EMS) for isolated microgrids comprising a photovoltaic system, diesel generator, and battery energy storage system (ESS). Since fuzzy logic control (FLC) has proven to be a powerful tool for dealing with the nonlinearities of a microgrid and the application of fuzzy-based EMS for isolated microgrids is rarely reported in the literature, this study proposes the application of an FLC for the EMS's design of an isolated microgrid. The proposed fuzzy-based EMS uses generation and demand forecasts, enhances the operating time of diesel generators (DLG), and takes advantage of the available solar resource to supply the energy required by a community while preserving the ESS lifetime. An adjustment of the FLC parameters by Particle Swarm Optimization (PSO) and Cuckoo Search (CS) algorithms is performed to improve the behavior of the proposed EMS. Furthermore, a battery degradation model is applied to estimate the ESS State of Health (SOH). To highlight the advantages of the proposed approach, a case study in a specific community in Ecuador is presented. In this location, the proposed EMS is compared with an EMS without parameter adjustment developed in previous work, demonstrating improved performance in DLG limits, preserving the battery lifespan by controlling the battery SOC limits more efficiently, and minimizing the microgrid operating costs by maximizing the use of photovoltaic power (i.e., reducing the wasted photovoltaic energy). The results provide evidence that the EMS adjusted with the PSO algorithm presents an enhanced behavior than the one adjusted by the CS algorithm. Finally, the fuzzy-EMS is validated using Matlab® and Hardware-in-the-Loop Typhoon HIL-402 device. Results demonstrate that the proposed approach limits DLG usage, make the most of the available solar resources, and extends the battery life by controlling overcharges and deep discharges. [ABSTRACT FROM AUTHOR]