Tree Search Fuzzy NARX Neural Network Fault Detection Technique for PV Systems with IoT Support

: The photovoltaic (PV) panel’s output energy depends on many factors. As they are becoming the leading alternative energy source, it is essential to get the best out of them. Although the main factor for maximizing energy production is proportional to the amount of solar radiation reaching the photovoltaic panel surface, other factors, such as temperature and shading, inﬂuence them negatively. Moreover, being installed in a dynamic and frequently harsh environment causes a set of reasons for faults, defects, and irregular operations. Any irregular operation should be recognized and classiﬁed into faults that need attention and, therefore, maintenance or as being a regular operation due to changes in some surrounding factors, such as temperature or solar radiation. Besides, in case of faults, it would be helpful to identify the source and the cause of the problem. Hence, this study presented a novel methodology that modeled a PV system in a tree-like hierarchy, which allowed the use of a fuzzy nonlinear autoregressive network with exogenous inputs (NARX) to detect and classify faults in a PV system with customizable granularity. Moreover, the used methodology enabled the identiﬁcation of the exact source of fault(s) in a fully automated way. The study was done on a string of eight PV panels; however, the paper discussed using the algorithm on a more extensive PV system. The used fuzzy NARX algorithm in this study was able to classify the faults that appeared in up to ﬁve out of the eight PV panels and to identify the faulty PV panels with high accuracy. The used hardware could be controlled and monitored through a Wi-Fi connection, which added support for Internet of Things applications.


Introduction
Photovoltaic (PV) panels are nowadays commonly and widely used to generate clean energy. Their main objective is to convert solar radiation emitted by the sun and received on the PV panel's surface into electricity. The amount of power generated by a PV panel is proportional to the total amount of solar radiation received on the PV panel's surface. This is typically denoted by the global horizontal irradiance (GHI), which is the PV panel's surface collective solar radiation directly obtained from the sun or indirectly received through diffusion or reflection. So, any factor that causes to lower the GHI will negatively affect the generation of energy from a PV panel [1]. Such factors include year season, the density of air molecules, water vapor, clouds, dust, air pollution, raindrops, snow, and shadow from near objects.
Internally, a PV panel consists of many smaller units called solar cells. Several solar cells are connected in series to form a PV panel. These units are the primary converters of solar radiation

System Architecture
The methodology used in this work relayed on an algorithm implemented on an embedded system. This embedded system was added to the PV system to enable fault detection and identification.
The embedded system consisted of the Internet of Things breaker connector (IoTBC) system and a fault diagnosis system with sensors (FDSS). The availability of the IoTBC system enabled the PV system to be logically represented as a tree. For instance, Figure 1 shows a PV system consisting of eight PV panels that are connected in series as one string. The PV string was connected to the FDSS system and also to an electrical load through a controller/inverter system. The IoTBC and the FDSS worked in collaboration with each other over a Wi-Fi connection to carry out what we called a tree search fuzzy NARX neural network fault detection technique. Both IoTBC and the FDSS systems supported connecting to the internet through a Wi-Fi connection. The internet connection allowed the system to support by being monitored and controlled by a remote device, such as a smart handheld device or a computer, and hence, the support of the Internet of Things (IoT).
The used IoTBC, in this example, had a granularity level of one PV panel. It means that the IoTBC could eliminate any number between 1 and 7 of PV panels using just one breaker unit. This enabled the fault diagnosis algorithm to detect faults that might occur in any single PV panel in the system. If IoTBC had a granularity of two PV panels, then IoTBC could only eliminate 2, 4, or 6 PV panels using one breaker unit. Hence, the fault detection algorithm could only detect faults that might occur in any group of two PV panels. During the regular system operation, as seen in Figure 1, there was no active breaker unit. Figure 1 also shows, as an example, the difference between the U3 breaker unit being inactive and being active. When the U3 was active, the leftmost five PV panels were eliminated from the system. consisting of eight PV panels that are connected in series as one string. The PV string was connected to the FDSS system and also to an electrical load through a controller/inverter system. The IoTBC and the FDSS worked in collaboration with each other over a Wi-Fi connection to carry out what we called a tree search fuzzy NARX neural network fault detection technique. Both IoTBC and the FDSS systems supported connecting to the internet through a Wi-Fi connection. The internet connection allowed the system to support by being monitored and controlled by a remote device, such as a smart handheld device or a computer, and hence, the support of the Internet of Things (IoT).  For each PV system, an additional two DC-DC solid-state relays (SSR) were needed, denoted by SSR1 and SSR2 in Figure 1. These were very important to eliminate DC arcs phenomenon in breaker units during the transition state of any breaker unit. The transition state of a breaker unit was the state during which the unit was being inactive and becoming active or being active and becoming inactive. Without these two SSR units, a breaker unit might be damaged due to the DC arcs phenomenon. It was essential to switch off both SSR1 and SSR2 before any attempt to activate or deactivate any breaker unit. After activating or deactivating a breaker unit, either SSR2 was switched on, or both SSR1 and SSR2 were switched on, respectively.
For the PV string and the IoTBC system shown in Figure 1, the tree fault search representation could be viewed, as shown in Figure 2.
Electronics 2020, 9, x FOR PEER REVIEW 4 of 26 The used IoTBC, in this example, had a granularity level of one PV panel. It means that the IoTBC could eliminate any number between 1 and 7 of PV panels using just one breaker unit. This enabled the fault diagnosis algorithm to detect faults that might occur in any single PV panel in the system. If IoTBC had a granularity of two PV panels, then IoTBC could only eliminate 2, 4, or 6 PV panels using one breaker unit. Hence, the fault detection algorithm could only detect faults that might occur in any group of two PV panels. During the regular system operation, as seen in Figure 1, there was no active breaker unit. Figure 1 also shows, as an example, the difference between the U3 breaker unit being inactive and being active. When the U3 was active, the leftmost five PV panels were eliminated from the system. For each PV system, an additional two DC-DC solid-state relays (SSR) were needed, denoted by SSR1 and SSR2 in Figure 1. These were very important to eliminate DC arcs phenomenon in breaker units during the transition state of any breaker unit. The transition state of a breaker unit was the state during which the unit was being inactive and becoming active or being active and becoming inactive. Without these two SSR units, a breaker unit might be damaged due to the DC arcs phenomenon. It was essential to switch off both SSR1 and SSR2 before any attempt to activate or deactivate any breaker unit. After activating or deactivating a breaker unit, either SSR2 was switched on, or both SSR1 and SSR2 were switched on, respectively.
For the PV string and the IoTBC system shown in Figure 1, the tree fault search representation could be viewed, as shown in Figure 2. The inner nodes of the tree represented the breaker units between PV panels, whereas tree leaves represented PV panels.
When the root node or any one of the inner nodes was activated, only the right side (branch) of that node was operational, and the left side (branch) of that node was temporarily eliminated or disconnected. This could be compared to the searching process in tree-like data structures.
When in operational mode, all relays were in their normal close state, meaning the PV system was operating as if there were no breaker units, and all PV panels were contributing to the process of power generation. In the meantime, the fault diagnosis system with sensors (FDSS) was concurrently working and analyzing any possible change in the PV system energy production. The FDSS was working in real-time and with full awareness of any change in the PV system and its surrounding environment. Using the current sensor (Isens) and a voltage sensor (Vsens), the FDSS could read information about the PV system energy production. Using a pyranometer and temperature sensor, the FDSS could get information about the PV system's related properties of the surrounding The inner nodes of the tree represented the breaker units between PV panels, whereas tree leaves represented PV panels.
When the root node or any one of the inner nodes was activated, only the right side (branch) of that node was operational, and the left side (branch) of that node was temporarily eliminated or disconnected. This could be compared to the searching process in tree-like data structures.
When in operational mode, all relays were in their normal close state, meaning the PV system was operating as if there were no breaker units, and all PV panels were contributing to the process of power generation. In the meantime, the fault diagnosis system with sensors (FDSS) was concurrently working Electronics 2020, 9, 1087 5 of 26 and analyzing any possible change in the PV system energy production. The FDSS was working in real-time and with full awareness of any change in the PV system and its surrounding environment. Using the current sensor (Isens) and a voltage sensor (Vsens), the FDSS could read information about the PV system energy production. Using a pyranometer and temperature sensor, the FDSS could get information about the PV system's related properties of the surrounding environment. Figure 3 shows an illustration of the FDSS.
Electronics 2020, 9, x FOR PEER REVIEW 5 of 26 the ESP8266 Wi-Fi IC. The ESP8266 Wi-Fi IC enabled the embedded system to support IoT applications and to control more than one IoTBC through Wi-Fi connection or over the internet. The IoTBC was designed, taking into consideration the cost, the power consumption, and the expandability of the system.
The ESP-01 module was used to allow connecting to the internet using Wi-Fi. The ESP-01 had many preferable features, such as its low power consumption, its ability to enter power saving mode without its integrated antenna, its Wi-Fi range, its physical area small size, and its support for the different Wi-Fi versions. The limitation for the ESP-01 was that it had only four general input/output interface pins to control external peripherals. This, however, was not a problem for expandability since these four pins were more than enough to control as many breaker units as needed. This could be done with the help of shift registers. Figure 4 shows the circuit diagram, which allows one ESP-01 to control as many breaker units as required by the ability to introduce more and more shift registers. For the PV system in Figure 1, we only needed to connect seven breaker units (relays) and two SSR units. This is shown in the circuit diagram in Figure 4 by the top shift register.
The FDSS controlled the IoTBC. When the FDSS detected a fault, it issued a series of commands to identify the faulty PV panel. The algorithm of fault detection and the communication between FDSS and IoTBC has been discussed in the methodology section. It is worth mentioning that the granularity level of the IoTBC system could be adjusted as a trade-off between cost and the precision of fault location detection. It indicated that the fault location was to be found on a single PV panel or on a group of PV panels. For instance, Figure 5 shows an example where the granularity level was set to a group of two PV panels. Here, the breaker units were chosen to be between two PV panels. In this scenario, the fault could be identified and classified to the level of one group. However, the FDSS system would not tell in which PV panel inside the group was the fault. In other words, the larger the granularity level of the IoT system, the fewer the number of breakers needed in the system, hence, the less the cost of the fault detection system. The FDSS consisted of some sensors, such as the pyranometer sensor for the solar irradiation measurement, the temperature sensor, the voltage sensors, and the current sensor from each PV string. The core of the FDSS system was an embedded system with a fuzzy NARX fault detection algorithm. This embedded system was equipped with the ATmega2560 low-cost microcontroller and the ESP8266 Wi-Fi IC. The ESP8266 Wi-Fi IC enabled the embedded system to support IoT applications and to control more than one IoTBC through Wi-Fi connection or over the internet.
The IoTBC was designed, taking into consideration the cost, the power consumption, and the expandability of the system.
The ESP-01 module was used to allow connecting to the internet using Wi-Fi. The ESP-01 had many preferable features, such as its low power consumption, its ability to enter power saving mode without its integrated antenna, its Wi-Fi range, its physical area small size, and its support for the different Wi-Fi versions.
The limitation for the ESP-01 was that it had only four general input/output interface pins to control external peripherals. This, however, was not a problem for expandability since these four pins were more than enough to control as many breaker units as needed. This could be done with the help of shift registers. Figure 4 shows the circuit diagram, which allows one ESP-01 to control as many breaker units as required by the ability to introduce more and more shift registers. For the PV system in Figure 1, we only needed to connect seven breaker units (relays) and two SSR units. This is shown in the circuit diagram in Figure 4 by the top shift register.   The FDSS controlled the IoTBC. When the FDSS detected a fault, it issued a series of commands to identify the faulty PV panel. The algorithm of fault detection and the communication between FDSS and IoTBC has been discussed in the methodology section.
It is worth mentioning that the granularity level of the IoTBC system could be adjusted as a trade-off between cost and the precision of fault location detection. It indicated that the fault location was to be found on a single PV panel or on a group of PV panels. For instance, Figure 5 shows an example where the granularity level was set to a group of two PV panels. Here, the breaker units were chosen to be between two PV panels. In this scenario, the fault could be identified and classified to the level of one group. However, the FDSS system would not tell in which PV panel inside the group was the fault. In other words, the larger the granularity level of the IoT system, the fewer the number of breakers needed in the system, hence, the less the cost of the fault detection system.
In case the IoTBC system was connected to more than one string, corresponding breaker units in the different PV strings must operate together. For example, in Figure 5, if unit U3 was to be activated, U4 must also be activated at the same time as U3. U2 and U5 must be activated or deactivated with each other. Besides, U1 and U6 must be activated or deactivated together.

Methodology
The PV system tree search fuzzy NARX fault detection algorithm could be logically divided into three separate operations. The first operation was to diagnose the PV system for a possible fault. The second operation was to classify the fault type in case there was one. The last operation, in case there was a fault, was to identify the source of the fault. The flow chart in Figure 6 shows an overview of the system's three operations in general.
The FDSS system did the first operation. It continuously reads current from each string current sensors (denoted by Isens in Figure 3). The FDSS also collected the PV system voltage and the ambient area temperature and solar radiation. With these reading and the help of the fuzzy NARX neural network, the FDSS system could determine if any of the PV strings had a faulty status. The fuzzy NARX neural network, discussed in the subsequent section, could predict the correct operation of a PV string under a set of surrounding conditions. Then, by classifying the difference between the expected process and the actual outcome of a PV string, the fuzzy NARX could identify if there was a fault in the PV string. In case there was a fault, the fuzzy NARX could determine if this fault was critical or not. A critical fault is a fault that hinders the operation of the PV system to a large extent. The definition of a critical fault varies depending on the PV system under consideration. For instance, in a single string PV system, like the one shown in Figure 1, an open circuit fault in any PV panel was considered critical as this would render the whole PV system inoperational. In case the fault was critical, the FDSS sent a notification to the system administrator, and the process of identifying the source of fault commenced. If the fault was not critical, the identification process could be scheduled for later, for example, in the early morning. The flow chart shown in Figure 6 was implemented using an embedded system, which was added to the PV panels, as described in Section 2. In general, any embedded system would have a specific sequence of operations that would be performed over and over as long as the system is operational. In our case study, the diagnosis process could be scheduled to run regularly, and the Electronics 2020, 9, 1087 8 of 26 duration between each run could be customized. The fault source identification process is discussed in the next section.
activated, U4 must also be activated at the same time as U3. U2 and U5 must be activated or deactivated with each other. Besides, U1 and U6 must be activated or deactivated together.

Methodology
The PV system tree search fuzzy NARX fault detection algorithm could be logically divided into three separate operations. The first operation was to diagnose the PV system for a possible fault. The second operation was to classify the fault type in case there was one. The last operation, in case there was a fault, was to identify the source of the fault. The flow chart in Figure 6 shows an overview of the system's three operations in general. The FDSS system did the first operation. It continuously reads current from each string current sensors (denoted by Isens in Figure 3). The FDSS also collected the PV system voltage and the ambient area temperature and solar radiation. With these reading and the help of the fuzzy NARX neural network, the FDSS system could determine if any of the PV strings had a faulty status. The fuzzy NARX neural network, discussed in the subsequent section, could predict the correct operation of a PV string under a set of surrounding conditions. Then, by classifying the difference between the expected process and the actual outcome of a PV string, the fuzzy NARX could identify if there was a fault in the PV string. In case there was a fault, the fuzzy NARX could determine if this fault was critical or not. A critical fault is a fault that hinders the operation of the PV system to a large extent. The definition of a critical fault varies depending on the PV system under consideration. For instance, in a single string PV system, like the one shown in Figure 1, an open circuit fault in any PV panel was considered critical as this would render the whole PV system inoperational. In case the fault was

The Fuzzy NARX Fault Detection
The developed fault classification algorithm (FCA) is presented in Figure 7. As shown, the FCA went through three stages. In the first stage, the FCA tried to classify if there was a fault in the string or not, by measuring the value of the PR (power ratio) using the NARX network. In the second stage, the FCA would classify the type of fault and whether it was minor, moderate, or significant faults by using the Sugeno fuzzy logic. Furthermore, in the final stage, the FCA would work in parallel with the tree fault search to allocate the faulty panels. We have discussed in more detail throughout this section how to calculate (PR) and specify its regions. went through three stages. In the first stage, the FCA tried to classify if there was a fault in the string or not, by measuring the value of the PR (power ratio) using the NARX network. In the second stage, the FCA would classify the type of fault and whether it was minor, moderate, or significant faults by using the Sugeno fuzzy logic. Furthermore, in the final stage, the FCA would work in parallel with the tree fault search to allocate the faulty panels. We have discussed in more detail throughout this section how to calculate (PR) and specify its regions.  In this work, as illustrated in Figure 7, the NARX network model was used to estimate the values of the optimum operating current (Ip) and voltage (Vp). NARX and NARMAX models [55][56][57] could be considered a neural network with recurrent dynamic behavior that had been effectively used for time series problem estimation. The main difference between multi-layer perceptrons and NARX was that NARX allowed a weighted feedback connection between layers of neurons. This feedback allowed the NARX models to consider lagged (past period) values of variables, which made them suitable for time series analysis.
The NARX network behavior, in compliance with the time series forecast, could be mathematically modeled by the following equation: In this work, as illustrated in Figure 7, the NARX network model was used to estimate the values of the optimum operating current (Ip) and voltage (Vp). NARX and NARMAX models [55][56][57] could be considered a neural network with recurrent dynamic behavior that had been effectively used for time series problem estimation. The main difference between multi-layer perceptrons and NARX was that NARX allowed a weighted feedback connection between layers of neurons. This feedback allowed the NARX models to consider lagged (past period) values of variables, which made them suitable for time series analysis.
The NARX network behavior, in compliance with the time series forecast, could be mathematically modeled by the following equation: where f(.) is the mapping function of the network, y(t) is the output of the NARX at time t, (y(t−1), y(t−2), ..., y(t−n y )) are the NARX past output values, (x(t−1), x(t−2), ..., x(t−n x )) are the NARX exterior data, n y is the number of output delay, and n x is the number of input delays. Figure 8 shows the detailed structure of the proposed NARX network.  Once the NARX model was implemented and trained, it was used then to measure the voltage As shown in Figure 8, in the input layer, the network model used two-time series inputs that represented its previous outputs at the time (t−1). In addition, it used four inputs with exterior data at a time (t−1). These were the solar radiation, panel temperature, the short circuit current (SCC), and the open-circuit voltage (OCV). In the hidden layer, it had five nodes with a hyperbolic tangent sigmoid transfer activation function [58], while in the output layer, it had two nodes with a linear activation function.
Only one lagging value, (t−1), was considered as an input to the neural network. The decision of not taking other lagging values, such as (t−2) and (t−3), was because they were not with significant added value for the system under study, with all concerns considered. This decision was reached after several trials were performed to determine the neural network configuration, as discussed in our previous work [36]. There were two essential concerns that affected this decision-simplicity and accuracy. The simpler the structure of the neural network, the more feasible to be implemented on an embedded system. Hence, the decision was made to considering only one lagging value, which gave a relatively simple neural network structure with excellent accuracy.
After implementing the network model, a training set of 5880 cases was obtained from three different PV panels before conducting network training using the Levenberg Marquardt algorithm [59], namely: Sharp's-NUS0E3E, Astronergy-CHSM6610P, and Lorentz mono-crystalline. This dataset covered the various temperatures and solar radiation conditions that would typically take place. The panel's electrical characteristics are shown in Table 1. The OCV and SCC parameters were used as a reference parameter to select between the three PV panels. More detail regarding the NARX network validation could be found in the author's previous work [36]. Once the NARX model was implemented and trained, it was used then to measure the voltage (VR) and power ratio (PR), which would be used later as input linguistic variables for the fuzzy rule-based classification system. The VR and PR were given as in Equations (2) and (3): where Vp and Pp are the maximum theoretical (predicated) output voltage and power, the PV system should have produced, respectively. Vs and Ps are the measured output voltage and power from the PV system, respectively. The maximum power point tracking (MPPT) conversion error rate used in this paper was 98.2%, which had been validated in the author's previous work [36,46]. Therefore, the power ratios were calculated at about ±2% error tolerance of the theoretical power, which presented the maximum error condition for the examined PV system. Hence, the minimum and maximum voltage and power ratios were expressed by the following formulas: where Vr and Pr are the measured output voltage and power from the PV panels. Hence, in the normal operation mode region of the examined PV system (8 "Astronergy-CHSM6610P" PV panels; for more information see Section 4.3) at standard test condition (STC), the values of the PR could be calculated using Equations (8) and (9): The STC for these solar panels was solar irradiance = 1000 W/m 2 , and panel temperature = 25 • C. In this work, as shown in Table 2, twenty-three different PV faults were investigated and categorized into three Sugeno fuzzy models (minor, moderate, and major). In the case of faulty shaded panels, the user must remove the shading first before the tree search algorithm, and the FCA would be able to allocate faulty panels in the string if faulty shading panels had been classified in the string (e.g., FL7, FL8... etc.). Moreover, in the partial shading condition, the radiation level was assumed to affect all PV panels belonging to the string equally.
The minimum and maximum voltage and power ratios for each fuzzy classification regions are shown in Table 3, which were calculated using Equations (4)-(7). As shown in Table 3, three partial shading levels had been studied in this work, which were low (10-40%), medium (41-65%), and high (66-95%).
After identifying the input variables VR and PR regions, the fuzzy sets and the membership functions for the three Sugeno fuzzy models are shown in Figures 9-11.  After selecting the linguistic variable and identifying the region of the fuzzy set, the fuzzy rules were required to be set. The initial rule sets for the three fuzzy models are illustrated in Table 4. The presented Sugeno fuzzy models were utilizing the product as an intersection method and the weighted average as a defuzzification method. Moreover, as shown in Table 4, the rules had been After selecting the linguistic variable and identifying the region of the fuzzy set, the fuzzy rules were required to be set. The initial rule sets for the three fuzzy models are illustrated in Table 4. The presented Sugeno fuzzy models were utilizing the product as an intersection method and the weighted average as a defuzzification method. Moreover, as shown in Table 4, the rules had been weighted during the tuning process, in order to select a single winner rule in the classification phase. After selecting the linguistic variable and identifying the region of the fuzzy set, the fuzzy rules were required to be set. The initial rule sets for the three fuzzy models are illustrated in Table 4. The presented Sugeno fuzzy models were utilizing the product as an intersection method and the weighted average as a defuzzification method. Moreover, as shown in Table 4, the rules had been weighted during the tuning process, in order to select a single winner rule in the classification phase. Table 4. Fuzzy logic rules.

Mode # Rules
Minor 1 If PR is 1 and VR is 2, then the fault is 1 (1) 2 If PR is 2 and VR is 3, then the fault is 2 (0.01) 3 If PR is 2 and VR is 4, then the fault is 3 (0.01) 4 If PR is 4 and VR is 5, then the fault is 4 (1) 5 If PR is 5 and VR is 6, then the fault is 5 (1) 6 If PR is 2 and VR is 1, then the fault is 6 (1) 7 If PR is 3 and VR is 2, then the fault is 9 (1) 8 If PR is 4 and VR is 3, then the fault is 10 (1) 9 If PR is 5 and VR is 4, then the fault is 11 (1) Moderate 1 If PR is 1 and VR is 1, then the fault is 7 (1) 2 If PR is 1 and VR is 5, then the fault is 12 (1)  3 If PR is 2 and VR is 6, then the fault is 13 (1)  4 If PR is 1 and VR is 2, then the fault is 14 (1)  5 If PR is 2 and VR is 3, then the fault is 15 (1)  6 If PR is 3 and VR is 4, then the fault is 16 (1)  7 If PR is 4 and VR is 5, then the fault is 17 (0.01) 8 If PR is 5 and VR is 6, then the fault is 18 (1) Major 1 If PR is 1 and VR is 1, then the fault is 8 (1) 2 If PR is 2 and VR is 2, then the fault is 19 (1)  3 If PR is 3 and VR is 3, then the fault is 20 (1)  4 If PR is 4 and VR is 4, then the fault is 21 (1) 5 If PR is 5 and VR is 5, then the fault is 22 (1)  6 If PR is 6 and VR is 6, then the fault is 23 (1) Using the Matlab Fuzzy Logic Toolbox, a satisfactory level of performance was reached. The tuning process started from a faulty PV panel only and progressively modifying the fuzzy system to detect all possible faults that might occur in the PV according to the fault types listed in Table 2. The tuning process involved: Review the fuzzy sets Revise shapes of the fuzzy sets Review the existing rules Adjust the rule execution weights

The Fault Source Identification Process
The search for the PV panel or panels causing the fault was based on a tree search algorithm. Once the FDSS system realized that a fault existed, it could identify the source of the fault with the help of the IoTBC system.
The algorithm used to identify the source of the fault is shown in Algorithm 1. The PV tree fault search (PTFS) algorithm resided in the FDSS system. It communicated with the IoTBC system based on the results obtained by the fuzzy NARX fault detection and classification method. To understand how the algorithm works, let us consider the PV system shown in Figure 1. This system had one PV string with a granularity level of one PV panel. The tree representation for this PV system is repeated in Figure 12. Let us assume that P2, highlighted in Figure 12, is the faulty PV panel. During regular operation, all breaker units (U1-U7) are inactive. Assume, for some reason, P2 is now faulty. The FDSS detects a fault in the PV string and classifies the fault as discussed in the fuzzy NARX fault detection section. Now, let us assume that FDSS is required to identify the source of the fault. The FDSS system runs a procedure, as illustrated in Algorithm 1. First, there is only one string, and it is known to be faulty. The PTFS now executes at line 2-a, as shown in Algorithm 1. The PTFS sends a command to the IoTBC to eliminate half of the PV panels. In our case, PTFS commands the The PV tree fault search (PTFS) algorithm resided in the FDSS system. It communicated with the IoTBC system based on the results obtained by the fuzzy NARX fault detection and classification method. To understand how the algorithm works, let us consider the PV system shown in Figure 1. This system had one PV string with a granularity level of one PV panel. The tree representation for this PV system is repeated in Figure 12. Let us assume that P2, highlighted in Figure 12, is the faulty PV panel. The PV tree fault search (PTFS) algorithm resided in the FDSS system. It communicated with the IoTBC system based on the results obtained by the fuzzy NARX fault detection and classification method. To understand how the algorithm works, let us consider the PV system shown in Figure 1. This system had one PV string with a granularity level of one PV panel. The tree representation for this PV system is repeated in Figure 12. Let us assume that P2, highlighted in Figure 12, is the faulty PV panel. During regular operation, all breaker units (U1-U7) are inactive. Assume, for some reason, P2 is now faulty. The FDSS detects a fault in the PV string and classifies the fault as discussed in the fuzzy NARX fault detection section. Now, let us assume that FDSS is required to identify the source of the fault. The FDSS system runs a procedure, as illustrated in Algorithm 1. First, there is only one string, and it is known to be faulty. The PTFS now executes at line 2-a, as shown in Algorithm 1. The PTFS sends a command to the IoTBC to eliminate half of the PV panels. In our case, PTFS commands the During regular operation, all breaker units (U1-U7) are inactive. Assume, for some reason, P2 is now faulty. The FDSS detects a fault in the PV string and classifies the fault as discussed in the fuzzy NARX fault detection section. Now, let us assume that FDSS is required to identify the source of the fault. The FDSS system runs a procedure, as illustrated in Algorithm 1. First, there is only one string, and it is known to be faulty. The PTFS now executes at line 2-a, as shown in Algorithm 1. The PTFS sends a command to the IoTBC to eliminate half of the PV panels. In our case, PTFS commands the IoTBC to activate the U4 breaker, as shown in Figure 12. This activation removes the PV panels P1 to P4, and now the system operates using the remaining panels shown on the Circle C1 in Figure 12. It should be noted that the elimination process is only done temporarily for a short amount of time to find the faulty PV panel and is done using the IoTBC system, as discussed in Section 2.
The FDSS tests the system again for possible fault, line 2-b in Algorithm 1. According to our initial assumption, the system will not be faulty.
However, if, P7 is also faulty, the PTFS will command the IoTBC to activate U2 in order to eliminate half of the remaining PV panels. In our case, the remaining would be indicated by circle C2 in Figure 12.
The elimination process will continue until we reach a subset of PV panels with no-fault, or there is no further elimination that could be performed.
In case no further elimination is possible, and the system status is faulty, the PTFS returns the PV panel as faulty PV panel, line 2-c-i in Algorithm 1.
On the other hand, if the algorithm reaches a subset of PV panels that has no faults, then the fault is in the eliminated PV panels.
To find that faulty PV panel, the PTFS repeatedly issues the proper commands to add a single leaf to the non-faulty subset of PV panels from the eliminated PV panels, line 3-a in Algorithm 1.
In our example, this process is indicated by circles C3, C4, and C5 in Figure 12. Each time a new leaf is added to the non-faulty subset, the PTFS calls the FDSS system to test for a possible fault, line 3-b in Algorithm 1. If a fault exists, then the PTFS has found the faulty leaf, and that would be the last added one.
Following these steps, the PTFS can identify the faulty PV panel in log(n) steps, where n is the number of leaves in a single string.

Results
This section presents the results of the developed fault detection algorithm. Real-time measure parameters had been used as input for the developed system. Furthermore, this section investigates the developed algorithm using its actual implementation on a low-cost microcontroller.

Meteorological Data
Real-time data consisting of solar radiation and panel temperature were gathered during the period from Feb 2018 to Dec 2019. The equipment used to collect the dataset consisted of a WE300 solar radiation sensor (±1% precision) and a WE710 temperature sensor (±0.25 • C precision) to measure the PV panel body temperature. Although the sensors used were accurate, the captured data were occasionally unreliable or noisy. This was primarily due to the sensor fault or noise ratio in connections. Consequently, to overcome the noise in the data obtained, a moving average filter [36,60] was used, see Figure 13. Electronics 2020, 9, x FOR PEER REVIEW 18 of 26 Figure 13. Average hourly solar radiation and temperature distributions throughout March 2019 with moving average filter.
As illustrated in Figure 13, the meteorological data were collected on an hourly based manner. The abnormality in data due to an unfunctional or broken device/sensor was ignored. This dataset had been used to train and test the proposed NARX network. As shown in Figure 8, the network had four exterior data input, among them solar radiation and panel temperature, while the other two inputs were used to select between the PV panels. This dataset had been collected for three different PV panels, see Table 1.
Moreover, the targeted output voltage (Vp) and current (Ip) were collected by running a Matlab code that analyzed the validated Simulink PV model output characteristics. More detail regarding the proposed PV model and its validation could be seen in our previous work [3,61,62].

Implementing the Algorithm on a Low-cost Microcontroller
The algorithm, shown in Algorithm 1, was implemented on the ATmega2560 microcontroller running at a frequency of 16 MHz. This was low-cost with an 8-bit AVR architecture microcontroller. The Fuzzy NARX algorithm was implemented with the parameters obtained from the Matlab training and simulation. Table 5 shows some experimental test cases for fuzzy classification along with the microcontroller running time required to get such classifications. In Table 5, PR and VR are the calculated power ratio and voltage ratio, respectively. Both VR and PR were calculated using the measured PV system voltage and current values using Equations (2) and (3), respectively. The hardware implementation was able to classify each of the shown scenarios into the correct mode and region, shown in Table 5, in running time given by the diagnosis time column.  As illustrated in Figure 13, the meteorological data were collected on an hourly based manner. The abnormality in data due to an unfunctional or broken device/sensor was ignored. This dataset had been used to train and test the proposed NARX network. As shown in Figure 8, the network had four exterior data input, among them solar radiation and panel temperature, while the other two inputs were used to select between the PV panels. This dataset had been collected for three different PV panels, see Table 1.
Moreover, the targeted output voltage (Vp) and current (Ip) were collected by running a Matlab code that analyzed the validated Simulink PV model output characteristics. More detail regarding the proposed PV model and its validation could be seen in our previous work [3,61,62].

Implementing the Algorithm on a Low-Cost Microcontroller
The algorithm, shown in Algorithm 1, was implemented on the ATmega2560 microcontroller running at a frequency of 16 MHz. This was low-cost with an 8-bit AVR architecture microcontroller. The Fuzzy NARX algorithm was implemented with the parameters obtained from the Matlab training and simulation. Table 5 shows some experimental test cases for fuzzy classification along with the microcontroller running time required to get such classifications. In Table 5, PR and VR are the calculated power ratio and voltage ratio, respectively. Both VR and PR were calculated using the measured PV system voltage and current values using Equations (2) and (3), respectively. The hardware implementation was able to classify each of the shown scenarios into the correct mode and region, shown in Table 5, in running time given by the diagnosis time column. After the fuzzy classifications, the NARX was used to help to identify the source of fault(s), see Figure 8. Table 6 shows some test cases for running the NARX implementation on the used microcontroller. Each row in the table was a test scenario. The first four columns represented the inputs to the NARX, which were the measured solar radiation, the measured temperature, the PV panel open-circuit voltage, and the PV panel short-circuit current. The other columns showed a comparison between the Matlab simulation and the hardware implementation of the NARX prediction of each PV panel current and voltage for each scenario. The tracking time column presented the running time required by the microcontroller to calculate the PV current and voltage for each scenario.

Evaluation of the Proposed Fault Detection Algorithm
The proposed fault detection algorithm performance was tested by conducting several experiments. Table 7 shows eight hours of experimental scenarios applied to the PV string shown in Figure 14. Each scenario lasted for 20 min and contained different conditions. Readings were taken 5 min after installation.
Faulty sample measurements were collected at a rate of 1 Hz over a 1 min period. As shown in Table 7, the power ratio during the normal operational mode was between (1-1.02); hence, as shown in Figure 7, it was not involved in the assessment process of the fuzzy logic. Figure 15 shows the faulty samples versus the output membership function for each fuzzy logic type (minor, moderate, and major). For instance, in cases (1-3), the fuzzy logic system identified that there were no faulty panels, only partial shading. Hence, after removing the shading, the PV system returned to its normal operating condition. After the fuzzy classifications, the NARX was used to help to identify the source of fault(s), see Figure 8. Table 6 shows some test cases for running the NARX implementation on the used microcontroller. Each row in the table was a test scenario. The first four columns represented the inputs to the NARX, which were the measured solar radiation, the measured temperature, the PV panel open-circuit voltage, and the PV panel short-circuit current. The other columns showed a comparison between the Matlab simulation and the hardware implementation of the NARX prediction of each PV panel current and voltage for each scenario. The tracking time column presented the running time required by the microcontroller to calculate the PV current and voltage for each scenario.

Evaluation of the Proposed Fault Detection Algorithm
The proposed fault detection algorithm performance was tested by conducting several experiments. Table 7 shows eight hours of experimental scenarios applied to the PV string shown in Figure 14. Each scenario lasted for 20 min and contained different conditions. Readings were taken 5 min after installation.

Conclusions
This paper proposed a novel and small implementable fault diagnosis method, which allowed the exact identification of the faulty PV panel(s) in a PV string. This was done through a technique that modeled the PV string in a hierarchical tree-like structure and employed a fuzzy NARX fault detection algorithm. The NARX neural network predicted the maximum output power of a PV string under a set of real-time sensed surrounding conditions with an accuracy of 98.2%. The predicted power was used then by the fuzzy diagnosis algorithm to identify the type of fault in a PV string. The proposed technique was monitored and controlled over a Wi-Fi connection, which added support for Internet of Things applications.
Moreover, the proposed algorithm was implemented on a low-cost embedded system. The algorithm was able to categorize faults into minor, moderate, and major faults. Besides, the algorithm could identify 23 different PV string faults, with an average time of about 10 ms for each identification case. Three partial shading levels had been taken into consideration, by designing the model, which were low (10-40%), medium (41-65%), and high (66-95%). The presented fault diagnosis algorithm was flexible and could be customized to model large PV systems efficiently.   On the other hand, in cases (5-9), the fuzzy logic system illustrated that there were only faulty panels. For example, the case (7) showed that there were three faulty panels (1,3,5). Faulty panels were identified using the tree search algorithm discussed in Algorithm 1. The algorithm used the IoTBC to disconnect and test PV panels in groups to identify the faulty PV panels. Although the faulty PV panel(s) identification process could be faster, the fact that the sensed measured values need to be averaged made this process take about three to four minutes for the used case. However, the identification process was better and faster than the manual fault search. Once faulty PV panels were identified, and the maintenance was carried out, the PV system returned to its reasonable operating condition.
Moreover, in other test cases, the fuzzy logic system showed that there were both faulty panels and partial shading faults. Hence, to solve that, we removed the shading first, and then the search tree algorithm correctly identified the locations of the faulty panels. In conclusion, as shown in Figure 15, all examined faulty conditions were accurately detected.

Conclusions
This paper proposed a novel and small implementable fault diagnosis method, which allowed the exact identification of the faulty PV panel(s) in a PV string. This was done through a technique that modeled the PV string in a hierarchical tree-like structure and employed a fuzzy NARX fault detection algorithm. The NARX neural network predicted the maximum output power of a PV string under a set of real-time sensed surrounding conditions with an accuracy of 98.2%. The predicted power was used then by the fuzzy diagnosis algorithm to identify the type of fault in a PV string. The proposed technique was monitored and controlled over a Wi-Fi connection, which added support for Internet of Things applications.
Moreover, the proposed algorithm was implemented on a low-cost embedded system. The algorithm was able to categorize faults into minor, moderate, and major faults. Besides, the algorithm could identify 23 different PV string faults, with an average time of about 10 ms for each identification case. Three partial shading levels had been taken into consideration, by designing the model, which were low (10-40%), medium (41-65%), and high (66-95%). The presented fault diagnosis algorithm was flexible and could be customized to model large PV systems efficiently. Funding: This research received no external funding.

Acknowledgments:
We acknowledge the support of An-Najah National University.

Conflicts of Interest:
The authors declare no conflict of interest.

Abbreviations
The following abbreviations are used in this manuscript