Many isolated locations, including hilly areas, remote sites, and military camps, lack feasible access to the main power grid. In these conditions, locally established Microgrids can provide the necessary power supply. However, to meet the demands of these isolated areas, numerous individual Microgrids are required. Although some of these Microgrids might be integratable, geographical constraints may preclude full integration. Under these circumstances, the establishment of a smart grid – integrating multiple Microgrids with a battery management system – can potentially solve many power supply issues. A smart grid control system paired with a centralized battery management system is proposed in this paper. The system considers the use of multiple renewable energy sources at various locations for stable and reliable power generation. The proposed method incorporates a long short-term memory (LSTM)-based artificial neural network (ANN) to ensure a stable, high-quality power supply at different load buses. Additionally, this work introduces an artificial intelligence-based operating system designed to maintain energy management under various conditions. To enhance voltage quality, a 7-level aligned multilevel inverter is incorporated into the system. As compared with PI and Fuzzy controllers, the proposed method with LSTM-ANN controller is improved the power quality under sudden changes in the system which are also presented in results. The effectiveness of the proposed energy management system (EMS) is verified by using a hardware-in the-loop approach with OPAL-RT modules, yielding realistic results.