1 Introduction

The rising demand for clean and sustainable energy has led to the increase in the adoption of major renewable energy sources (RES) such as solar and wind energy [1, 2]. In addition, the harmful impact of fossil fuels on the environment such as toxic gas emission and greenhouse effects has motivated the global landscape to shift towards decentralized and sustainable solutions [3]. It is estimated that the demand for sustainable energy is going to increase substantially soon and it is challenging to balance the energy demand and supply [4]. Along with RES, components such as distributed generation (DG), energy storage systems, and microgrids (MG) also play an important role in maintaining the reliability of the energy generation process [5,6,7]. The increasing energy demand and transformation of conventional power systems has resulted in energy generation near the load. Microgrids have emerged as a pioneering concept within this transformation, offering localized and resilient energy distribution systems that cater to the increasing demands of energy [8]. Microgrids are characterized by their ability to operate autonomously or in conjunction with the main grid to improve energy efficiency, and reliability of the power supply. However, the dynamic nature of load patterns and the inherent variability of RES pose intricate challenges to their operation. Based on the varying climatic condition, most of the microgrids combine hybrid RES with battery storage systems [9]. The hybrid energy systems supply energy for various applications such as residential areas, large-scale industries, and other stand-alone systems [10]. In most cases, hybrid systems are more efficient with lower costs and high reliability compared to systems with a single energy source [11]. Microgrids consist of multiple small-scale energy generation systems with energy storage devices and loads which makes it a distributed energy generation system. The reliability of microgrids can be enhanced by effectively controlling the energy generated by the hybrid RES and by optimizing the energy management through load forecasting. Accurate energy prediction and load forecasting are the important factors to address the challenges associated with microgrids such as load variation, issues with power quality and improper load balance. In addition, these factors help the microgrid operators to make optimal decisions with respect to energy generation, storage, and distribution [12]. In microgrids, it is crucial to balance the energy supply and demand for achieving better operational stability considering the intermittent nature of solar and wind energy. The volatility associated with these sources makes it challenging to predict energy generation since it fluctuates based on the availability of the fundamental sources. As a result, energy prediction becomes an important topic of research to address the supply–demand problem in microgrids while operating in a stand-alone mode [13, 14]. Artificial intelligence-based machine learning models have gained huge significance in predicting the energy generation from RES with high accuracy [15, 16]. Along with energy prediction, it is also essential to forecast the load for estimating the source demand. Accurate load forecasting helps in making informed decisions (both short term and long term) for energy management [17, 18]. Several methods such as statistical methods, ML models and hybrid techniques have been proposed in the literature for estimating the load forecasting. This research presents an ML based approach for energy management in microgrids. The ML models are used for predicting energy generated by solar and wind energy generation systems and for forecasting the load demand. In addition, the study also estimates the State of Charge (SoC) of the battery for energy storage.

The prominent contributions of this paper are discussed as follows:

  1. i.

    This paper analyzes different ML models such as RF, SVR, LR, and LSTM for the prediction of wind and solar energy generation for microgrid applications.

  2. ii.

    A time-series based forecasting approach is employed for forecasting source generation and load demand.

  3. iii.

    An accurate estimation of SoC of the battery using ANN at a given instance.

  4. iv.

    A GUI is developed for validating the energy management system under different case studies.

The organization of the paper is structured as follows: Sect. 2 discusses the related work on various existing methods on energy management. Section 3 presents the methodology for application of various regression models for predicting solar and wind energy generation. Section 4 discusses load forecasting and source generation in microgrids. Section 5 discusses battery SoC prediction using ANN. Section 6 discusses the outcome of experimental analysis along with the development of GUI and Sect. 7 concludes the paper with prominent research observations and future directions.

2 Related work

Energy management in microgrids is critical to achieve stability and reliability of power generation systems. This research emphasizes the integration of machine learning methodologies into the domain of load forecasting and energy prediction. Machine learning techniques, particularly those rooted in time series analysis, have demonstrated remarkable proficiency in modeling complex and dynamic patterns found within energy consumption data. The work in [19] presented a comprehensive analysis of different ML models for effective energy management in centralized, decentralized and distributed microgrids. Different ML models such as ANN, LSTM, federated learning and reinforcement learning techniques are applied for energy management in microgrids. Although the study validates the effectiveness of the ML models, the research states that the issues such as scalability and reliability of these models in terms of predicting renewable energy are still persistent. A hybrid RES was developed for microgrids in [20]. AI-based techniques such as ML and reinforcement learning methods are employed for designing and controlling the energy management framework. Results show that linear regression, support vector regression, and backpropagation neural networks are more suitable for predicting short term energy demand. However, certain aspects such as nonlinearity of the RES poses challenges to the accuracy of these models and hence it is significant to consider these aspects while designing an energy management framework. The ref. [21] presented a novel energy management system based on load and weather forecasting. The proposed EMS employs a hybrid approach which combines adaptive neuro-fuzzy inference system (ANFIS), multilayer perceptron (MLP), ANN and radial basis function (RBF) for accurately predicting the load data and weather conditions. It can be inferred from the experimental analysis that MLP–ANN, and RBF–ANN models exhibit excellent prediction performance in terms of predicting wind speed, solar irradiance and load demand. Experimental evaluation shows that the uncertainty of RES parameters affects energy efficiency. Load forecasting is a complex problem which cannot be solved using conventional statistical techniques [22]. This study implemented different ML algorithms such as SVM, linear regression, LSTM and ANN models for forecasting the load demand in the short term. ANN with the Levenberg–Marquardt algorithm exhibits excellent prediction performance compared to other models. But, the computational complexity of the forecasting process reduced the efficacy of the process. Most of these techniques fail to extract the correlation between the weather data and load demand. This problem is addressed in [22] using a fixed SPM–LSTM method. SPM analyzes discrete data while LSTM is used for processing continuous data. The proposed approach comparatively takes lesser time compared to other existing models. However, the performance of the SPM–LSTM method for long-term forecasting needs a detailed evaluation. The authors in [23, 24] analyzed short term load forecasting for estimating the electricity demand. A hybrid SVR–LSTM model is used to identify the behavioral pattern of the load profiles [24] and a hybrid Bidirectional LSTM–CNN model is employed in [25] for extracting the timely data about the energy profile. The hybrid BiLSTM–CNN model is optimized using a metaheuristic Grey Wolf Optimization (GWO) algorithm for obtaining an optimal set of parameters for the hybrid model. Both the works forecast the load demand for 1–2 days and a week. Considering the need for long term forecasting, there is a need to test these models for providing estimation for longer terms such as monthly or yearly terms. A hybrid deep learning model for forecasting the energy demand is presented in [26]. A LSTM model is implemented in this work for predicting the demand considering the uncertainties of RESs. The LSTM model is optimized using a genetic algorithm-adaptive weight particle swarm optimization (GA-AWPSO) algorithm. The parameters of the LSTM are tuned using GA-AWPSO algorithm for accurate prediction of load. It can be inferred from existing works that it is difficult for the ML models to capture the complex and nonlinear relationship between energy generation using hybrid RES and load demand. In addition, there is a need to improve the efficiency of the batteries by accurately estimating the SoC for storing excess energy. This research intends to address these limitations by employing time-series based forecasting and SoC estimation using ML models. A brief overview of the proposed research methodology is discussed in further sections.

3 Methodology

This research focuses on designing an effective energy management framework that incorporates time-series based forecasting and SoC estimation using different ML models. A simplified flow chart representation of the proposed work is shown in Fig. 1. As we know that, it involves a lot of complexities to predict wind and solar power and as a result balancing supply and demand becomes a difficult task. The energy generated by a solar photovoltaic (PV) system depends on factors such as sun irradiation, temperature, and other weather parameters. On the other hand, energy generation through wind turbines depends on the wind speed, and wind direction. Since these sources are not the same throughout the day, the prediction of energy generation through these sources becomes unreliable. In this research, three ML models such as Random Forest (RF), Support vector regressor (SVR) and linear regression (LR) are trained to accurately predict the energy generated using solar and wind power.

Fig. 1
figure 1

A simplified flow chart representation of the proposed framework

3.1 System model

The microgrids consist of solar photovoltaic systems (PV), wind turbine (WT), batteries and DC power converters [27]. In microgrids, PV and wind turbine systems act as main energy generation systems whereas the batteries act as energy storing devices which store the excess power generated by the PV/wind systems. The operational efficiency of the microgrid depends on the performance of each component in the system and hence it is essential to predict the energy generation through these components. The equation for obtaining the net power flow in a microgrid is given in Eq. 1.

$$P_{pv} \left( t \right) + P_{wind} \left( t \right) + P_{battery} \left( t \right) - P_{load} \left( t \right) = 0,$$
(1)

In (1), \(P_{pv}\), \(P_{wind}\), \(P_{battery}\) and \(P_{load}\) are the output power of the PV system, wind turbine, battery, and the electrical load power, respectively. The microgrid considered in this work consists of a decision algorithm implemented between Grid connected and isolated operation. There are certain constraints considered in this research which are as follows:

  1. (i)

    In case of excess energy generation:

  2. (ii)

    If SOC of the battery is greater than 80% then power will be supplied to the grid.

  3. (iii)

    If SOC of the battery is less than 20% then battery will be charged.

  4. (iv)

    If SOC of the battery is in between 20 and 80% then based on the price decision will be taken.

  5. (v)

    If the generated energy cannot satisfy the load demand:

  6. (vi)

    The batteries will discharge if SOC is greater than 35%.

  7. (vii)

    Power will be taken from the grid if the battery can’t supply the required power.

3.2 ML models for predicting energy generation

This research discusses the performance of three different ML models such as RF algorithm, SVR and linear regression models.

3.2.1 Data acquisition and preprocessing

The data for the experimental analysis is collected from both solar and wind energy [28] which are tabulated in Tables 1 and 2, respectively.

Table 1 Set of data for solar energy prediction
Table 2 Set of data for wind energy prediction

The data collected is read by using Pandas library in the Python programming language and is stored as a data frame. Further the data is preprocessed using the standard scaler module from the scikit learn library. The ML models are trained using the data wherein the inputs taken were temperature in kelvin scale, diffuse horizontal irradiance in Wb/m2 and diffuse vertical irradiance in Wb/m2 and the output is the solar generation in KW.

3.2.2 Linear regression for prediction

Regression models are mainly used as a statistical technique to analyze the relationship between the variables [29,30,31]. A fundamental linear regression model is analyzed using a single independent variable x which has a correlation with an output variable y. The relation between the variables ‘x’ and ‘y’ is linear and is given as follows:

$$y = \beta_{0} + \beta_{1} x + \varepsilon \ldots ,$$
(2)

In (2), the β0 and β1 are the intercepts and slope which are unknown constants, and ε is the random error. The error is assumed to have a mean zero value and unknown variance σ2. The Eq. 2 representing linear regression is also called the equation for least squares regression which states the criteria for selecting the appropriate fitting line. When used for prediction tasks, the LR model observes the dataset of values of both response and explanatory variables. If unknown values are obtained from these variables without any appropriate response, then the fitted model is used for predicting the response.

3.2.3 Support vector regression

The SVR is a ML technique which is mainly applied for solving regression problems, including energy prediction in microgrids. The SVR is an extension of Support Vector Machines (SVM), which were originally designed for classification tasks [32]. The SVR focuses on predicting continuous output values rather than class labels and aims to find a regression function that best fits the data while maintaining a certain margin around the predicted values. This margin is determined by two hyper parameters: ε (epsilon) and C. Epsilon controls the width of the margin, and C controls the trade-off between minimizing prediction errors and allowing points to fall outside the margin. The network architecture of the SVR is shown in Fig. 2.

Fig. 2
figure 2

Network architecture of SVR model [32]

The SVR model uses different kernel functions which are categorized as polynomial, exponential radial basis function (ERBF), RBF, and sigmoid. The SVR model consists of a training dataset denoted as Z = {xi, yi} where, i = 1, 2, 3. …. n. The term xi ∈ Rq where q is the dimensional input vector and yi ∈ R is the respective target value and ‘n’ is the size of the training dataset. The SVR model is represented in Eq. 3.

$${\text{y}} =\upomega ^{{\text{T}}}\uptheta \;\left( {\text{x}} \right) + {\text{b,}}$$
(3)

In (3), ω is the weight vector, b represents the bias term and θ (x) is the function used for nonlinear mapping which maps the variable x into a high dimensional feature space.

3.2.4 Random forest (RF) regression

The RF regression model uses an ensemble learning approach which combines the predictions of multiple models to generate a finalized output. The RF regression model consists of multiple individual decision trees which make use of subsets of the input data samples to make individual predictions. The optimal split for each node in the decision tree is selected randomly and this helps in reducing the problem of overfitting and thereby enhancing the generalization capacity of the model.

The flow of the RF regression model for generating prediction is given as follows:

For a given node n = 1, …., N;

A sample Xn is generated using a bootstrap technique.

Construct a decision tree bn for a sample Xn;

  1. a)

    Based on the criteria, the best features are selected, and the decision tree is partitioned until the samples are exhausted.

  2. b)

    A tree is constructed until the minimum condition is satisfied or until a certain number of levels is reached.

  3. c)

    For each partition, the features of ‘m’ is selected randomly from the actual ‘n’ features and the samples are divided equally.

  4. d)

    The classifier generates the final output based on the majority votes, which is calculated as given in Eq. 4.

    $$a\left( x \right) = \frac{1}{N}\mathop \sum \limits_{i = 1}^{N} b_{i} \left( x \right).$$
    (4)

The final prediction output is the combined output of all individual trees.

4 Time series-based forecasting of load demand and source energy

This research focuses on forecasting the load demand and source energy using time-series based ML models. Time series-based load forecasting is a critical component of energy management in microgrids. In this process, the future energy demand or consumption is predicted based on historical load data and other relevant factors. Time series models are well-suited for this task since they can capture temporal patterns and dependencies related to energy consumption data. Based on the duration, load forecasting is categorized into three classes namely, short-term forecasting (STF), medium-term forecasting (MTF) and long-term forecasting (LTF), which are discussed as follows:

  1. A)

    Short-term forecasting (STF) STF is mainly conducted from 1 h to 1 week. Short term horizons are mainly suitable for achieving a stable and optimal operation of microgrids. Grid operators make use of STF results for providing appropriate pricing and thereby help in obtaining effective energy management with better load distribution characteristics [33, 34].

  2. B)

    Medium-term forecasting (MTF) MTF is conducted from 1 week to 1 year and helps in forecasting for utilities, microgrids, and energy providers to plan resources, manage supply–demand imbalances, and optimize operational strategies.

  3. C)

    Long-term forecasting (LTF) LTF is performed for a time horizon of 1 to 20 years. It is crucial for energy planning, infrastructure development, and policymaking.

In this research, load forecasting is performed using RF regression, SVR, and LSTM–RNN model. The SVR and RF regression models are discussed in the previous section (Sect. 3) and the LSTM–RNN model for load forecasting is discussed below.

4.1 Time-series analysis for load forecasting

Time series prediction has attracted researchers and academicians due to its ability to identify complex nonlinear data patterns, to understand the changes occurring over a period of time, and to make predictions based on past observations. Statistical models such as the Autoregressive Moving Average (ARMA) and the Autoregressive Integrated Moving Average (ARIMA) Model are extensively used in time series-based prediction analysis. However, these models are characterized by poor generalization ability, difficulty in obtaining appropriate measures, poor identification of an appropriate model to represent the data. These drawbacks can be addressed using machine learning and deep learning models [35, 36]. In this research a RNN based LSTM model is used for predicting the load demand. The proposed model used historic data for predicting time series for load forecasting.

4.2 LSTM–RNN for load forecasting

RNN is a type of ANN which makes use of sequential information for generating outputs. However, RNNs suffer from the problem of vanishing gradient, and this forces the RNN model to return back to only a few time steps. On the other hand, LSTM belongs to the class of RNNs that are particularly appropriate for sequential data analysis, making them a popular choice for time series forecasting tasks such as load forecasting. Load forecasting involves predicting the future demand for a resource, such as electricity, based on historical consumption patterns and other relevant factors. The LSTM model is implemented in this research since it provides better performance for longer sequences.

The LSTM has three gates that regulate the flow of information in and out of the cell state:

  1. (i)

    Forget gate This gate decides what information from the previous cell state should be discarded. It takes the previous hidden state (h_{t − 1}) and the current input (x_t) and outputs a value between 0 and 1 for each element in the cell state. A value of 0 means “completely forget the data,” and 1 means “completely store the data.” The equation representing forget gate is given as follows:

$${\varvec{f}}_{{\varvec{t}}} = {\varvec{\sigma}}\left( {{\varvec{W}}_{{\varvec{f}}} *\left[ {{\varvec{h}}_{{{\varvec{t}} - {\varvec{1}}}} , \, {\varvec{x}}_{{\varvec{t}}} } \right] + {\varvec{b}}_{{\varvec{f}}} } \right),$$
(5)

where ft is the forget gate, ht is the hidden state, ht−1 is the previous hidden state, Wf is the input word sequence, bf represents the bottleneck features and σ is the sigmoid function.

  1. (ii)

    Input gate The input gate decides what new information should be added to the cell state. It consists of two parts: a sigmoid layer that decides which values should be updated, and a tanh layer that creates candidate values to be added to the cell state. The equation representing input gate is given as follows:

    $${\varvec{i}}_{{\varvec{t}}} = {\varvec{\sigma}}\left( {{\varvec{W}}_{{\varvec{i}}} *\left[ {{\varvec{h}}_{{{\varvec{t}} - {\varvec{1}}}} , \, {\varvec{x}}_{{\varvec{t}}} } \right] + {\varvec{b}}_{{\varvec{i}}} } \right),$$
    (6)

In (6), the it is the input gate.

  1. (iii)

    Output gate The output gate decides what the next hidden state should be based on the current cell state, but it also filters the output. It determines which parts of the cell state are going to be output. The equation representing output gate is given as follows:

$${\varvec{o}}_{{\varvec{t}}} = {\varvec{\sigma}}\left( {{\varvec{W}}_{{\varvec{o}}} \cdot \left[ {{\varvec{h}}_{{{\varvec{t}} - {\varvec{1}}}} , \, {\varvec{x}}_{{\varvec{t}}} } \right] + {\varvec{b}}_{{\varvec{o}}} } \right),$$
(7)

In (7), ot is the output gate.

In addition, LSTM models have a hidden state which is a modified version of the cell state that acts as the actual output of the LSTM at a given time step. The output is based on the cell state but filtered by the output gate. The current state of the cell and the memory unit status of the cell is obtained from Eqs. 8 and 9, respectively.

$$\hat{\user2{C}}_{{\varvec{t}}} = {\varvec{tanh}}\left( {{\varvec{W}}_{{\varvec{C}}} *\left[ {{\varvec{h}}_{{{\varvec{t}} - {\varvec{1}}}} , \, {\varvec{x}}_{{\varvec{t}}} } \right] + {\varvec{b}}_{{\varvec{C}}} } \right),$$
(8)
$${\varvec{C}}_{{\varvec{t}}} = {\varvec{f}}_{{\varvec{t}}} *{\varvec{C}}_{{{\varvec{t}} - {\varvec{1}}}} + {\varvec{i}}_{{\varvec{t}}} *\hat{\user2{C}}_{t} ,$$
(9)

Ct is the cell state, Ct−1 is the cell state of the previous time instance, tanh is the hyperbolic tangent activation function, and \({\hat{\text{C}}}_{{\text{t}}}\) is the updated cell state.

$$h_{t} = o_{t} *tanh\left( {C_{t} } \right).$$
(10)

At each time step, the two states cell state and hidden state are passed to the next cell. The model learns weights and biases by reducing the deviations between actual training samples and LSTM outputs.

5 Battery SoC prediction using ANN

ANNs are mainly used as classifiers because of its reliability, scalability, precise accuracy, quick adopting technique and its high tolerance towards fault occurrences. In this research, ANNs are used for predicting the State of Charge (SoC) in batteries. The SoC represents the amount of energy stored in a battery at a given time, and accurately predicting it is crucial for optimizing battery usage and managing battery systems effectively. In this work, the ANN model is trained using the input data such as energy consumption data and load demand related information. Based on the changes in the load, the proposed approach generates proper control signals to achieve a balance between the source power and load power.

For SoC prediction, initially, the data is collected through IEEE—Data Port which consists of usage data of an automotive Li-Ion cell. The battery’s effective capacity is 15Ah and the measurements are taken with a 1 s sampling time and the SoC sequence is analyzed using the coulomb counting method. Values for sampling time (Ts), time in seconds (s), measured voltage in V, measured current Iin, conducted charge in Ah, state of charge (SoC), cell capacity in Ah, and list Cycles are all included in the data. The data in the “.mat” format is converted to a.csv file in order to make it suitable for analysis. The pre-processed data is shown in Table 3.

Table 3 Preprocessed data for prediction of SoC

ANNs consist of three layers such as input, hidden and output layers. The input layer consists of 3 nodes that represent 3 inputs. The hidden layer consists of 100 nodes and the output layer consists of a single node. The activation functions used are rectified linear unit (ReLU) for the hidden layer and sigmoid for the output layer. The input parameters are voltage in V, measured current Iin, time in second (s) and the output parameter is State of Charge (SoC). The network architecture used for SoC forecasting is described in Table 4.

Table 4 Network parameters of ANN architecture

The total parameters considered for the SoC prediction are 501 where in all 501 parameters are used for training the ANN model. The data is split into a ratio of 70:30 wherein 70% of the data is used for training the model and 30% is used for testing the model. The parameters of the ANN model are optimized using an Adam optimizer and is trained for 100 epochs with a batch size of 1.

6 Results and discussion

This section discusses the results of the experimental analysis conducted for the proposed approach. The experimental outcome of different ML models for energy prediction, load forecasting and SoC prediction is discussed. In addition, the effectiveness of the proposed energy management framework is validated using a GUI interface which is also discussed in this section.

6.1 Responses of ML models for energy prediction

In this work, the popular ML models such as SVR, RF, and linear regression are used for predicting the solar and wind energy generated for power generation. For the prediction of solar energy, the inputs are measured as follows: temperature in kelvin scale, diffuse horizontal irradiance in Wb/m2 and diffuse vertical irradiance in Wb/m2 and the output is the solar generation in KW. On the other hand, the inputs taken for predicting wind energy are as follows: pressure in atm, wind speed in m/s and wind direction in degrees and the output is the generated wind energy in kW. The simulation results are illustrated in the proceeding sub sections. Solar and wind energy prediction by using RF regression models is shown in Figs. 3 and 4, respectively. The number of estimators was set to 100 and the root mean square loss obtained for solar energy and wind energy prediction was 0.08139 and 21.7176, respectively.

Fig. 3
figure 3

Original versus predicted solar energy generation plot using RF model

Fig. 4
figure 4

Original versus predicted wind energy generation plot using RF model frame

The SVR model was trained using a RBF kernel and the results of the model for prediction are illustrated in Figs. 4 and 5. As inferred from the results shown in Fig. 6, the root mean loss obtained was 0.68495 and 50.45461 for predicting solar and wind energy respectively.

Fig. 5
figure 5

Original and predicted solar energy generation plot using SVR model frame

Fig. 6
figure 6

Original and predicted wind energy generation plot using SVR model frame

Energy prediction by using linear regression for solar energy and wind energy predictions are shown in Figs. 7 and 8, respectively. As observed from the results, the RMS loss obtained for linear regressor is 0.6789 and 91.23404 for solar and wind energy prediction respectively. Results show that random forest regressor achieved the least root mean square error compared to SVR and linear regression models.

Fig. 7
figure 7

Original and predicted solar energy generation plot using LR framework

Fig. 8
figure 8

Original and predicted wind energy generation plot using LR framework

6.2 Responses of ML models for load forecasting

Load forecasting is performed using RF, SVR, and a LSTM–RNN model with a fixed set of previous time steps as parameters. For RF regressor, the number of estimators are 100 and prediction is performed for each time step. The LSTM models are trained using a TensorFlow library for 40 epochs with a batch size of 32 with mean square error (MSE) as loss function. Simulation results of all ML models in terms of load forecasting are illustrated in this section. The original and predicted load using RF, LSTM–RNN and SVR frameworks are shown in Figs. 9, 10 and 11 respectively. Further, in this work, the accuracy of the ML framework for the load prediction is investigated by using error metrics. The corresponding error metrics for the ML models are tabulated in Table 5.

Fig. 9
figure 9

Original vs predicted load using random forest framework

Fig. 10
figure 10

Original vs predicted load for the LSTM–RNN framework

Fig. 11
figure 11

Original vs predicted load for the SVR framework

Table 5 Error metrics for different ML models

6.3 Experimental results of SoC prediction

The ANN model is trained using 70% of the training data and is tested using 30% of the testing data. As given in Table 6, the total number of trainable parameters is 501 and there are no non-trainable parameters. The ANN model was trained for 100 epochs with batch size of 1. Results show that the model achieved an MSE loss of 3.6668e−07 which states that the estimated SoC is highly accurate.

Table 6 Network parameters of ANN architecture

6.4 Development of GUI for microgrid by using real-time data

In this research, an efficient GUI is developed for testing and validating the performance of the proposed approach. The GUI is developed using a Tkinter platform which is a standard GUI library for python. The Tk GUI toolkit helps the users to create effective GUI applications swiftly. There is access to specific geometry management methods for all tkinter widgets, that have the purpose of organizing widgets throughout the parent widget area. Tkinter exposes the following geometry manager classes: pack, grid, and place. The pack() method organizes widgets in blocks before placing them in the parent widget, The grid() Method organizes widgets in a table- like structure in the parent widget, and The place() Method organizes widgets by placing them in a specific position in the parent widget.

The working process of the GUI can be explained as follows: the input parameters such as the source for solar energy are temperature, radiation, wind direction and wind speed and for wind energy are pressure, wind direction and wind speed are entered manually into the system. In the next step, the source computes the predicted solar energy and wind energy by using the trained models and displays the sum of wind and solar energy as Psource. Next load input is taken from the user in KW and the SOC of the battery is taken as input. The output button shows the values of Pload, Pgrid, Pbattery and the energy balanced equation and the source forecast and load forecast buttons output the source and load forecast graphs for the next 20 h.

The GUI has validated with different key input parameters such as Psource, load and SOC of battery and different working cases has analyzed. Based on the given load and SOC value, grid working conditions have analyzed whether (i) The power is sold to grid or (ii) Battery supply is turned on to meet the given load or (iii) Battery is less than the threshold value so power battery is being charged. A sample screenshot diagram of developed GUI is shown in Fig. 12, which helps in validating the effectiveness of the proposed energy management framework for different source values.

Fig. 12
figure 12

Demonstration of GUI

The GUI developed in this research provides accurate value of source, load, grid, and battery power for different values. This helps in validating the effectiveness of the proposed energy management framework for different source values.

7 Conclusion

A comprehensive analysis of deploying ML models for effective energy management in microgrids is discussed in this work. The proposed experimental approach with an interface of GUI is focuses on four prominent factors namely, energy prediction by solar and wind energy using RF, SVR, and linear regression models, load forecasting using time series analysis, battery SoC prediction using ANN, and development of framework for validating the energy management framework. From the obtained results as shown in Table 5, the MSE and RMSE with RF method are recorded as 430.8364 and 20.7566, respectively. The results show that the RF model is most suitable and effective for energy prediction and load forecasting since it produced the least error as compared to the other two models. Furthermore, the effectiveness of the ANN model for SoC prediction was validated since it is more accurate in terms of prediction. The application developed for this project is based on the Python Tkinter module for user end GUI service and the machine learning models and forecasting models are deployed into the GUI and the efficacy of the GUI was validated for different use cases. In summary, the proposed energy management framework is more effective for real-time energy prediction, and load forecasting.

8 Future scope

For future research, the proposed energy management system can be integrated with electric vehicles [37] with a vehicle to grid (V2G) configuration for future industrial needs. Besides, other aspects of energy management such as power factor management, security of microgrids by using IoT [38, 39], cost optimization and expansion of GUI through integration of Cloud and IoT applications with microgrids can be considered for future research by an incorporation of various machine learning algorithms [40].