Energy Shortage Failure Prediction in Photovoltaic Standalone Installations by using Machine Learning Techniques

The use of ESS in standalone photovoltaic installations is essential to supply energy demands, independently of solar generation. Accurate prediction of the battery state is critical for the safe, durable, and reliable operation of systems in this type of installations. In this study, an installation located in the area of Aragon (Spain) has been considered. Two methods, based on different types of RNN, are proposed to predict the battery voltage of the installation two days ahead. Specifically, the NARX network and the LSTM network are studied and compared. The implemented algorithms process battery voltage, temperature and current waveforms; and rely on the selection of different future scenarios based on weather forecasting to estimate the future voltage of the battery. The proposed methodology is capable of predicting the voltage with an RMSE error of 1.2 V for batteries of 48V, in critical situations where the installation is running out of energy. The study contributes to the ongoing research of developing preventive control systems that help reduce costs and improve the performance of remote energy storage systems based on renewable energies with a positive outcome.


I. INTRODUCTION
In the search to generate energy in ways less harmful to the environment, solar energy is considered one of the most promising and reliable alternatives to reduce global carbon emissions. Thus, photovoltaic (PV) systems have become a very important aspect of sustainable development [1]. PV systems generate energy directly from sun irradiation that reaches the solar panels. Some of the advantages of this technology are minimal environmental impact and pollution, not having moving parts, having less operational cost, and overall being a cheap technology to manufacture [2]. This paper focuses on standalone stations, which are not connected to the electrical grid. They are located far from urban centers and their only power source is solar panels. These installations count with different energy generation/consumption patterns. On the one hand, the system must operate during the night. On the other hand, there is a general uncertainty in the generated power, due to meteorological conditions (cloudy days or other environmental phenomena). For these reasons, it is necessary to add a battery system (Fig. 1) capable of storing the energy generated during periods of high irradiation and then supplying the system at night or specific moments in the absence of sun [3]. These battery systems undergo different issues that worsen their performance in these installations. For example, [4] studies the impact of Partial State-of-Charge and its consequences on Lead-Acid batteries, whereas in [5], the battery system of a PV installation is monitored during six months and the same behavior is observed, especially during low-irradiation winters. Finally, [6] explores a new model that incorporates these effects plus temperature-related effects that decrease the maximum available capacity. Different solutions to these problems have been proposed in the literature. Typically, battery manufactures ( [7], [8]) advice using a common and easy-to-implement technique consisting of periodically overcharging the batteries. This ensures a higher SoC in the battery before a low irradiation period. However, these overcharges reduce battery life, thus it is interesting to only overcharge the battery packs when needed. Other more complex solutions have been studied as in [9], where a hybridization between two battery chemistries is used to improve the performance of the installation.
For this reason, a system capable of predicting the energy store in the batteries (obtained by the future voltage) several days in advance would help to avoid critical installation blackout, and acting accordingly (i.e., only overcharging the batteries previously to several cloudy days), thus avoiding unnecessary battery degradation. Among the possible benefits would be an optimization of the performance of the installation and an extension of the useful life of all its elements.
The application of machine learning techniques to the PV field has been explored before in the literature. For example, in [10], a set of NN is used to make a 15-minute forecast of the energy yield of the installation. Other studies such as [11] and [12] use more complex NN to make a generation of the installation prediction, with a prediction horizon up to 24 hours. As happens in these studies, the vast majority focus on installations connected to the grid, trying to predict the future power generation, based on irradiation or other meteorological variables [13]. By contrast, the field of standalone installations is less explored. In addition, other investigations do not contemplate a two-day prediction horizon as in this paper.
Regarding the outputs of the algorithms, most papers focus on estimating unmeasurable battery parameters. In this respect [14] has designed a battery model with which the SoC of leadacid or lithium batteries can be predicted. Works like [15] or [16] use neural networks for the same purpose of estimating or predicting the SoC of batteries for electric car related applications. Another variable that is being discussed a lot lately is Remaining Useful Life (RUL). In this regard [17] manages to predict this data using a neural network model and improving the results through the use of multiple sensory signals. Fewer studies are focused on predicting the voltage of the batteries, even though it is the most critical variable regarding a possible failure of the system and are mostly focused on applications not related to PV such as unmanned aerial vehicles [18] or electric motorcycle [19].
With regard to the different machine learning techniques used in PV installations and batteries, most works are centered in Recurrent Neural Networks (RNN). In [20] the model Nonlinear AutoRegressive eXogenous models (NARX) is used to predict the output power of the panels and a studio of different combinations of its inputs is made. Other RNN used is Long-Short Term Memory (LSTM) networks, for example in [21] this network is combined with statistical methods to forecast PV power with an horizon of 24 hours. In [22] an example of Convolutional Neural Networks (CNN) is used to predict the output power of an installation for the next 24 hours, based on past values of temperature, solar irradiation and power generated. Gaussian Process Regression (GPR) has also been considered in other studies, but its increased complexity makes it worse positioned when trying to implement these techniques in a simple BMS [23], [24].
In this paper, a novel methodology is proved to make a voltage prediction based on NN, including historical data and multiple future scenarios depending on weather forecasting. A comparison between a simple and easily implemented network (NARX) and another more complex and computationally more demanding (LSTM) is made to validate the suitability of the methodology. The main contribution of this paper is proving that energy disruption detection can be effectively done in a PV standalone installation, with a prediction window of 48h, a larger prediction horizon than usually considered in the state-of-art. This margin has been set by experts attending the time necessary to carry out preemptive maintenance. The prediction is based on fuzzy scenarios depending on the weather in the following days. This tool has been deployed in a real-time system monitoring real standalone PV installations. A preliminary study related to this tool is available in [25].
The outline of the paper is as follows. Section II describes the dataset, focusing on its origin and the features that make it interesting. Then, Section III explains the methodology followed, detailing the neural network (NN) models used, the algorithm design process, and its training. Section IV delves into the development that the system has undergone to be implemented in a real-time application. Section V provides the results obtained during the process and the final implementation in a real system. Finally, Section VI includes the conclusions.

II. DATASET DESCRIPTION
The database used in the research comprises data from a PV standalone installation that belongs to Confederación Hidrográfica del Ebro (CHE) [26], a state entity in Spain. The installation has been built and managed by Sociedad Ibérica de Construcciones Eléctricas, S.A. (SICE) company member of the international ACS group [27]. This installation (Fig. 2) is used to provide energy supply to different communication systems, metering stations and irrigation channel controls close to the site. It is located in the region of Aragón, Spain (latitude: 40,711563N, longitude: 0,347228W). The importance of a continuous power supply for the devices to which it transmits energy is high. If one of the facilities runs out of power, a quick action is needed to bring a generator set with which to feed the system until there is sun again. Depending on the season of the year and the road conditions, this action is very difficult or impossible, in addition to the high cost of doing it. For these reasons a predictor would avoid many problems and save costs.
The standalone installation has a battery bank of 40 Ni-Cd cells (model Sunica plus SUN+920-1 by SAFT) with a nominal voltage of 1.2V each, in series and for a total nominal voltage of 48V and a capacity of 950Ah. The installation energy source is 16 solar panels of 195W of rated power. This installation provides energy to different electronic equipment with an average consumption of 250W in total.
In Fig. 3, a block diagram of the PV installation is shown. The panels are connected to the system through a Maximum Power Point Tracking (MPPT) regulator [28]. This block represents a DC-DC converter that optimizes the connection between PV panels and the battery bank plus the load.
Additionally, there is data collecting and communications equipment, capable of monitoring different variables: voltage at the battery terminals (Vbat), ambient temperature, generation current (Igen), and current consumed by the load (Iload). The current through the battery (Ibat), which is the subtraction of Igen and Iload, is also measured. Almost 13 years of information have been recorded with a sample rate of one sample every hour. The vast majority of the facilities deployed in the territory only have data on voltage, current and temperature. There are no meteorological variables or the health status of the materials, so we will only work with the variables that are commonly available for these installations.

III. METHODOLOGY
The main hypothesis of this study is that the future voltage of the batteries can be predicted by using a window of past observations, and an input based on the weather forecast for the future days (implicit in the forms of artificial future current). To demonstrate the applicability of this methodology, two standard algorithms specifically designed for processing real-time series, are going to be evaluated as options. The first option seeks simplicity and low computational cost to be easy to implement on a simple programable device for deploying the algorithm locally, i.e., on the microcontroller of the MPPT. The second option seeks greater benefits, with higher computational complexity and deployed as cloud computing. However, the selected algorithms do not have to be the definitive ones since it is the methodology that is being evaluated.

A. NEURAL NETWORK MODELS
Among the machine learning models, it has been seen that RNNs are the ones that suit better this application. This type of network has been widely used in prediction problems [29] with more accurate results than other forecasting methods [30]. Two models of NN have been selected to make a comparison between a simple and easily to implement network (NARX), and another more complex and computationally more demanding (LSTM) to validate the good results of the methodology.

1) NARX
NARX is a recurrent dynamic neural network that has feedback connections from the output to the inputs [31]. It has been proved that this type of RNN model is well suited for modeling nonlinear systems and especially time series [32]. The input data passes through a tapped delay block, providing the network with memory on the past inputs. There is feedback from the output data, which also passes through a tapped delay block, to provide memory on past outputs. A NARX network usually follows one of the two following architectures: open-loop architecture or closed-loop architecture. This depends on whether true measurements of past outputs are available at the time of the prediction and can be used as input or, on the contrary, they are not available and past estimates of the output need to be used as inputs. The general equation of the NARX model is defined in (1), where f is a non-linear function that relates the output at the discrete moment n+1 with the different inputs x and the output itself y in the previous instants (from n to n-d). There are multiple options to implement the kernel of a NARX model, but the most used is the architecture based on a multilayer perceptron (MLP), also known as a feed-forward network. The common structure of an MLP is an input and an output layer, and a variable number of hidden layers. Each layer has a determined number of neurons interconnected with all neurons of adjacent layers. The equation which defines the output of each neuron is (2), where xj is the input vector. This value is multiplied by the weights vector of the neuron wij. The last factor f (the activation function) models the behavior of the neuron. The complete network structure is shown in Fig. 4. The MLP is composed of as many hidden layers and neurons as the problem requires. The last layer must have the same number of neurons as outputs have the network. Since this network is implemented for a regression problem the activation function of the output layers must be linear. The taped delay lines which collect past instants of input and output data have no restrictions of length, however when using large temporal windows, the problem of vanishing gradient may appear [33].
Like all NN, NARX needs a training process that consists of modifying the weights iteratively to fit the training outputs. During this process, both the inputs and the desired outputs are introduced in the network. With this information, the algorithm adjusts the weights, so the outputs generated by the network are as close as possible to the desired target. Training is fully detailed in Sect. III.B.2.

2) LSTM
Long Short Term Memory was proposed by Hochreiter and Schimdhuber in 1997 [34]. It is a special type of recurring network that was designed to solve long-term dependency and to overcome the problem of vanishing gradient that appears in conventional RNN models. The structure of an LSTM layer is shown in Fig. 5. Each layer has an input x n , an output h n , and a memory term c n , which are vectors that change over time, being n the time variable. The vector x n has dimensionality m, and both h n and c n have the same dimensionality p.
The LSTM layer controls information through three subnetworks, or "gates": The forget gate f, the input gate i, and the output gate o, which are also vectors of dimensionality p. The forget gate controls how much old information is removed from the memory term. The input gate controls how much new information in ĉ passes to the memory term. Finally, the output gate controls the impact the memory term has on the output h. In the figure, the σ layer and tanh layer blocks represent complete neural layers with sigmoid or hyperbolic tangent function as activation function respectively.
In each time instant n, the equations for each element k of the p elements in f, i, o, and ĉ are: Where is the array of m+p weights associated with the k-th element in the f gate, and is the bias term associated with the k-th element in the f gate. The same is applicable for the rest of the gates.
After the gates have been calculated, the updated memory term and the output at the instant n, , can be obtained as in (7) and (8), where ⊗ represents the Hadamard product. Structures with a higher complexity may be built by stacking multiple LSTM layers, so the term of the previous cell acts as the input to the following one. Additionally, post-processing linear layers can be added to obtain a scalar output from the term of the final LSTM cell. The LSTM network is trained using backpropagation similarly to the process followed in conventional NN. The internal weights of each cell are adjusted to reduce the total error committed by the network. This process is fully detailed in Sect. III.B.2

1) INPUTS AND OUTPUTS
As seen in previous sections, the available variables are voltage at the battery terminals, the ambient temperature, the current generated by the solar panels, and the current consumed by the load. From them, the battery current is obtained as the subtraction of both currents. Starting from a time instant n, the output is the voltage at time n + 48h (corresponding to the objective of predicting the voltage two days ahead). This forecast horizon has been chosen after consulting experts in the field, so the operator has time to carry out appropriate solutions (i.e., overcharging the batteries the previous days, or charging the batteries with a fuel-powered generator) to avoid energy supply disruption. The input vectors are the values of the three variables (voltage, current, and temperature) during the last two days, from n-48 to n. A preliminary study has been made to select the length of the past inputs vector, the final value selected is a compromise between minimal error and computational cost. Additionally, to provide information on the evolution of the system in the following 48 hours, data of the current during this period is also going to be used (Fig. 6). The future temperature was also considered but discarded after some tests due to its low relevance to the prediction.
Regarding using future current as an input, it is necessary to distinguish between the training process and the final implementation, since for the training process future real current will be available as an input, but for the final implementation, it must be estimated. Other machine learning techniques will be used to estimate this profile of future current. This topic will be covered in depth in the following sections. Once the input vectors are ready, the next step is to normalize the features in the dataset. In this application, the ranges of the input variables are very different due to their diverse nature. It is convenient to normalize the data to a range determined to accelerate and improve convergence at the optimal point during the training process, obtaining an increased accuracy. In this case, data of each variable (voltage, current and temperature) has been normalized to the range [0,1] separately.

2) TRAINING PROCESS
Supervised training is used for this application. In this type of training, both the input vectors and the true output value (corresponding to each of the inputs) are used. During the training process, the network adjusts the values of its weights so that the error between the expected output value and the estimation provided by the network is minimized. This method is called backpropagation.
The configurable parameters of the process in which special attention must be paid are: • Neurons/cells activation function: it returns an output that will be generated by the neuron given an input or set of inputs. • Cost function: it measures the difference between the estimated value and the real value. • Optimizer: it oversees the update of the weights values to minimize the error made. The activation function of the neurons of the input and hidden layers has been selected by doing a parametric search and selecting the best performing for each network: ReLu (Rectified Linear Activation Function) for NARX and hyperbolic tangent for LSTM, two functions widely used in this type of network. Since the voltage estimation task is a regression problem, the output layer of both models will have a linear activation function. In both networks, the cost function used to optimize the network parameters is the mean squared error (MSE).
An important factor to consider is avoiding local minima and get a globally optimal solution. For that, the use of an algorithm/optimizer that randomly initiates the weights and keeps only the one with the better results is considered. From the different options of optimizers, ADAM (ADAptive Moment estimation) is selected. ADAM [35] is a stochastic optimizer with a variable learning rate that combines the advantages of two algorithms that are extensions of the stochastic gradient descent (SGD), such as AdaGrad (Adaptive Gradient Algorithm) and RMSProp (Root Mean Squared Propagation). In Table 1 a summary of the hyperparameters for the two models is shown. The dataset has been divided into three subsets to train and validate the correct operation of the neural network. The first is the training subset, made up of 70% of the data. The second one is the validation subset, made up of 15% of the data. The last one is the test subset, made up of the remaining 15% of the data.  The data is divided by random shuffling for the training and validation subset, while for the test subset the final 15 % of the database has been set aside. The reason for doing this division is to carry out the strategy of Early Stopping to avoid overfitting. This phenomenon occurs when the network is over-trained with a training set, causing it to learn the particularities and the noise of this data. An overfitted network does not generalize well and has worse results when new data is processed. The Early Stopping strategy consists of training the network (obtaining an error metric and updating the weights) only with the training set and at the same time checking its behavior with the validation set. The training process stops when the network stops improving its performance over the validation set, achieving a network with a correct generalization. The training process of both networks is compared using a computer with an Intel i7-9700K CPU of 3.60 GHz. As Table 1 manifests, preliminary tests shows that the duration of the training process for the LSTM network is larger, as well as the modifiable parameters, which are 3.6 times more than in NARX network. Finally, the test set is used to benchmark different algorithms or different hyperparameters fairly, since this set has not been used in any stage of the training process.
In Fig. 7, the evolution of the training and validation set is done, the point where the model stops to improve and therefore the training process must cease is around 200 epochs.

3) NETWORK SIZING
With the dataset and the training process selected, the next step is network sizing and actual training. Both networks (NARX and LSTM) have been trained following the same procedure. For both networks, after trying with a varied number of hidden layers, the option that offered the best tradeoff between precision and network complexity was two, in addition to the input and output layer. The dimension of the input layer (number of neurons) must be equal to the number of inputs, in this case, 192. The output layer has one neuron since there is only one output (the value of the predicted voltage). To choose the dimension of the hidden layers, a comparison has been made by training the model with different numbers of neurons. Table 2 shows the MSE error of the different NN combinations. The option of 100 and 50 neurons has been chosen in both cases because it shows the best results.
To reduce possible overfitting, a dropout layer has been added after each hidden layer.  The dropout [36] is a technique in which different neurons are randomly selected to not update their weights in different iterations of the training phase. With this technique, a network less dependent on a particular neuron is achieved and therefore it generalizes better. For this case, a dropout rate of 10% is chosen, meaning that 10% of the neurons are randomly dropped on each iteration. The final structure of the network is shown in Table 3. The process followed to train both NN models is summarized in Algorithm 1.

A. SYSTEM OVERVIEW
The final voltage prediction system contains one of these trained neural network models, among other different blocks. This system is implemented in Python code language and is nsta e n a oca server n the C E's fac t es. Fig. 8 shows a diagram with all the parts that make up the entire system. The neural network block (voltage prediction algorithm) has been trained with the dataset, and the preprocessing block groups and normalizes the inputs (both real-time inputs and future current inputs) as explained in the previous section. However, during training, the algorithms have used known future current as input. In the implementation phase, this information is not available. This s e cte n the f g re w th the "F t re c rrent re ctor" block. In this section, an estimation for the future current waveforms, based on weather forecasting, is presented. The details of this estimation are explained below. Algorithm 2 explains step by step the process followed by the final implementation of the system to make the prediction.

B. ESTIMATION OF FUTURE CURRENT
The key idea is that a forecast of the weather for the future days is selected, then an artificial current waveform corres on ng w th that scenar o s generate the "F t re c rrent re ctor" ock. To o so, a st on the fferent daily irradiation patterns that can appear in the installation has been carried out. Each of these types of day has a representative current pattern. A weather forecast system, or a specialized operator selects the type of day more likely to happen for the forecasting horizon and the corresponding current patterns are used as future current inputs to the NN.
To obtain the day-type classification, different features have been extracted from voltage, current, and temperature waveforms of the same day. Then, these features have been processed by clustering techniques. The selected features have been based on previous work made by the research group [24]: • The voltage at the beginning of the discharge: voltage of the battery at the beginning of the night when the solar panels stop producing energy. • The voltage at the end of the discharge: voltage of the batteries at the end of the night when the solar panels begin producing energy. • Stored charge: integral of the charge during the charging process. To determine the day classification, Self-Organizing Maps (SOM) [37], and clustering K-means algorithm [38], [39] have been used. SOM is an unsupervised classification algorithm that is commonly used for pattern recognition, database visualization, and preliminary analysis of datasets [40], [41].
A SOM has been trained with the features described before as inputs using the SOM Toolbox MATLAB library [42]. A standard size of 10x6 neurons has been selected. The map has two operation modes: training and inference. During the training process, the neurons adjust so that for each example exists a region of the map that better fits it. (1) Obtain the future current pattern based on the election of an expert or the local weather prediction.
(2) Extract the past values of voltage, current and temperature of the PV station batteries.
(3) Matching input vectors with past and future data (4) Preprocess the input to suit the NN. (5) Compute the NN to obtain the prediction (voltage 48h into the future) and save that value. The resulting trained SOM can be considered a twodimensional, non-linear picture of the database, where the map groups similar data patterns (or type of days) in closer regions.
After the training, a K-means has been applied to the SOM map to establish different clusters for each different type of day (Fig. 9). This algorithm needs as an input the number of clusters into which the database will be separated, so a parametric search with this parameter has been carried out. After classifying each of the days of the dataset into one of the clusters, the current pattern corresponding to that type of day has been obtained by averaging the current waveform of all the days belonging to that cluster. The results show that by using four clusters, most of the days can be classified without committing large errors. Fig. 10 is the result of this process. Each cluster has been assigned a label related to its characteristics: • High irradiation day without reaching the maximum voltage (red): This type of profile usually happens when a high sunshine day occurs after a bad day (low irradiation). As the voltage levels are low, during the charging process the maximum voltage of the batteries is not reached, and therefore the battery absorbs maximum irradiation. • Prototypical good day (light blue): This type of profile usually occurs when a high irradiation day occurs after another good day. The starting voltage levels are high, and the maximum voltage is reached soon, thus the current decreases, and the batteries cannot absorb as much current. • Medium irradiation day (dark blue): This type of profile appears on light cloudy days, with medium irradiation. • Low irradiation day (yellow): This type of profile occurs when there is very low absorption of solar energy. They could be rainy or foggy days. Additionally, the fifth type of day without any irradiation ("Da w th e treme ow rra at on") has een nc e . This fifth cluster would represent days where there are heavy storms, or snow blocking the panels, or any critical system failures. This new type of day has been included artificially because there are almost no identifiable patterns of this situation in the dataset.
These artificial current patterns are the ones that are entered into the predictive system as information of the future days. Depending on the expected type of day, an operator will choose the current profile that best suits that scenario

A. EVALUATION INDEXES
To evaluate the two types of RNN, three metrics widely used in regression problems are chosen: Root Mean Squared Error (RMSE) (9), Mean Absolute Error (MAE) (10), and Mean Absolute Percentage Error (MAPE) (11).
Where N is the number of examples in the test dataset, ̂ is the predicted voltage for the i-th example, and is the actual voltage value for the i-th example.

B. RESULTS OF TRAINING WITH REAL CURRENT AS FUTURE INPUT
The first result is a comparison between both NN models, following the training process, using the test dataset to evaluate the performance of NARX against LSTM. The predicted and the real voltage are shown in Fig. 11 where both NN models achieve accurate predictions for different types of days. In the first four days, the solar panels receive high irradiation but from then on, some cloudy/rainy days appear and the predictions in these critical situations are also correct.
The error achieved by NARX and LSTM is shown in Table  4. Both models have similar values, but the LSTM has higher precision.  Fig. 11, it can be seen a better performance of LSTM in the higher voltage levels. On the contrary, the NARX algorithm does not reach the actual voltage values in these ranges. Nevertheless, these instants of operation are not critical since the critical values to predict are in the lower voltage levels.
To make sure the prediction algorithms are suitable for this application, a more exhaustive evaluation has been done in multiple PV standalone installations with different battery voltages and chemistries. Since the features of each installation are different, the MAPE is the most adequate index to compare the results. As Table 5 shows the errors are similar or even better in the different stations. The election of Morrón to continue the study over the other installations is because it has had more installation failures in recent years, and it is a higher priority installation for the client.

C. CHANGE FROM REAL TO ARTIFICIAL CURRENT
To check how the behavior changes when introducing the synthetic current as future input, the same window of days shown in Fig. 11 is used. The new results are shown in Fig.  12. For this evaluation, future current values for the next two days are selected based on the five types calculated in the previous section. Table 6 presents worse results, but the system is still capable of reproducing with high accuracy the behavior of the batteries. At this point in the implementation, the LSTM network still has a more precise estimation in the higher levels of the waveform, but for the lower ranges, the NARX network seems to get closer to the actual values.

D. PERFORMANCE IN A LOW ENERGY SITUATION
To verify the performance of the implemented system, detrimental situations have been selected, in which it would be convenient to foresee what is going to happen. These detrimental situations have been defined as those with voltages below the threshold of 50V, as marked with an orange line in the Figures 13,14 and 15. In this example, one of the facilities studied runs out of power due to several adverse weather days. In Fig. 13 the real and the predicted values obtained by NARX and LSTM are shown. After a few days of normal irradiation, a first low-irradiation period occurs, but the installation manages to recover with two days of good irradiation. After those two days, three low irradiation days take place, and voltage plummets, so the installation stops working. During the days before the two main low-irradiation events, the predicted waveforms are similar to what has been seen in previous tests. When the voltage begins to drop below 47.5V, the estimates begin to differ from the actual data. This divergence happens because the database contains very few complete examples of waveforms in these voltage ranges, and therefore, the network is not able to learn the exact behavior of these failure situations. However, the trend of the dropping voltage is captured, and an alert message could be sent, warning that the installation may fall. If an operator observes this trend, pertinent precautions should be taken. Table 7 shows a comparison between the errors obtained for the full waveform and the errors obtained for voltage values below 50V (a risky situation). The results obtained show no clear benefit from using one or another NN, and the computational cost of LSTM is much higher than NARX, so the final implementation is made with the NARX model.

E. FAULT TOLERANCE
The forecast horizon has been set at two days. When choosing the future scenario that will occur during those two days, the operator will choose an artificial current profile based on weather forecasts and his experience. In this section, a preliminary study against possible minor errors in the selection of the scenario is presented. Figures 14,  15, and Table 8 collect some results for the cases where the operator does not estimate the day properly, choosing a wrong pattern. S ec f ca , rather than a "Da w th e treme ow rra at on" scenar o, the "Low rra at on a " scenar o has een chosen n F g. , an the "Me m rra at on a " scenario has been chosen in Fig. 15.  Although the waveform prediction is worse, it is still possible to estimate that there is a chance of failure in the s stem when se ect ng " ow rra at on a ", es ec a looking at the trend of the curve rather than the exact waveform. The errors increase by 0.2V approximately, which is acceptable for this application. If the day selected is medium, due to the substantial difference in the current waveform the prediction becomes much more unprecise.
This allows inferring that there will be some fault tolerance in the selection of days by the operator.

F. PRELIMINARY IMPLEMENTATION OF THE SYSTEM
A preliminary example of the behavior obtained with the final system implemented in the servers of CHE is shown in Fig.  16. For the final implementation, in addition to the 48-hour prediction, a 24-hour prediction was also implemented. In Fig.  16 the red line is the real value, the green line is the prediction 24-hour ahead and the orange line is the prediction 48-hour ahead. The future current can be selected manually or by consulting a local weather forecast system. The results obtained are very promising, but the final evaluation needs to be done with a larger amount of data, of at least one year running in real time.

VI. CONCLUSION
This paper study the issue of future voltage estimation in ESS batteries with a new methodology that relies on standard algorithms such as NARX and LSTM. The purpose is to predict future failures cause by low energy disruption in PV standalone installations. The prediction horizon has been lengthened until two days ahead in the future. The algorithms rely on past voltage and current measurements, and in future current estimations to make the predictions. To provide these future estimations, a model based on the classification of future irradiation scenarios has been developed. The machine learning techniques applied to perform the prediction are NARX and LSTM, and their performance has been compared. Both models obtain good estimation results, with average RMSE metrics of 0.906 V and 0.870 V respectively, for batteries with nominal voltages of 48V. In the case of a risky scenario, the RMSE metrics are 1.128 V and 1.298 V respectively. Although the error is greater, the trend can be clearly observed when a failure is about to occur, and an operator could take preventive measures accordingly. This phenomenon is reasonable due to the scarcity of these events in the database, but it is acceptable for the application. The sensitivity of the proposed model to errors in the classification of the future days is also evaluated, concluding that a certain level of misclassification could be allowed. The algorithms have been deployed in real installations, with a positive outcome.
The results are very promising, achieving good estimation results. However, the proposed prediction algorithms are still sensitive to long-term variations: battery aging, cell cracks, hotspots, finger failures, corrosion, or changes in other elements of the installation such as solar panels, battery chargers… To m t gate th s sens t v t , f t re nes of work include adaptive algorithms, capable of learning and being retrained online, after been deployed in the installation. With this modification of the algorithm its performance in new situations will be improved. In order to make available the deployment of these algorithms in new installations without history data, a future line of work is to train a representative set of several installations so that the tool is not exclusive to one installation, and it can be used for every PV station. Then, the adaptive algorithm will improve its approximation. Finally, other future lines are to add new functionalities like a waveform anomaly detector, to alert that something out of the normal behavior may have happened and any of the system components may have suffered a breakage.