Blockchain and Deep Learning-Based Fault Detection Framework for Electric Vehicles

: The gradual transition from a traditional transportation system to an intelligent transportation system (ITS) has paved the way to preserve green environments in metro cities. Moreover, electric vehicles (EVs) seem to be beneﬁcial choices for traveling purposes due to their low charging costs, low energy consumption, and reduced greenhouse gas emission. However, a single failure in an EV’s intrinsic components can worsen travel experiences due to poor charging infrastructure. As a result, we propose a deep learning and blockchain-based EV fault detection framework to identify various types of faults, such as air tire pressure, temperature, and battery faults in vehicles. Furthermore, we employed a 5G wireless network with an interplanetary ﬁle system (IPFS) protocol to execute the fault detection data transactions with high scalability and reliability for EVs. Initially, we utilized a convolutional neural network (CNN) and a long-short term memory (LSTM) model to deal with air tire pressure fault, anomaly detection for temperature fault, and battery fault detection for EVs to predict the presence of faulty data, which ensure safer journeys for users. Furthermore, the incorporated IPFS and blockchain network ensure highly secure, cost-efﬁcient, and reliable EV fault detection. Finally, the performance evaluation for EV fault detection has been simulated, considering several performance metrics, such as accuracy, loss, and the state-of-health (SoH) prediction curve for various types of identiﬁed faults. The simulation results of EV fault detection have been estimated at an accuracy of 70% for air tire pressure fault, anomaly detection of the temperature fault, and battery fault detection, with R 2 Scores of 0.874 and 0.9375.


Introduction
EVs have completely revolutionized conventional vehicles worldwide due to their benefits, e.g., decarbonization, being eco-friendly, and low maintenance costs. Immense burning of fossil fuels in conventional gasoline or diesel vehicles can generate a high amount of harmful greenhouse gases that are detrimental to the greener environments free with strengthened privacy. However, the applied AI models could not maintain data integrity or confidentiality in the EV fault detection system. Due to this, malicious attackers can easily forge the components of EVs, which can cause several types of faults, such as air tire pressure, temperature, and batteries, which further deteriorate the performance of the fault detection. Therefore, to strengthens the security of EV fault detection, in this paper, we propose a blockchain and deep learning-based EV fault detection approach for safe journeys. A blockchain platform incorporated with deep learning models strengthen the security and confidentiality during fault detection in EVs. Once data are appended to the blockchain network, they cannot be manipulated by malicious attackers, which can predict faults in EVs correctly without any delay (with the high data rates and a low latency 5G wireless network). Moreover, Table 1 shows the comparative analysis of several trending technologies, such as blockchain, 4G, 5G, and IoT, along with their associated benefits and challenges. Based on the benefits, i.e., high security, high data rate, and low latency features of blockchain and 5G networks, EV fault detection using deep learning models is proposed for the safety of users during the journey. Additionally, Figure 1 shows the evolution of blockchain technology, which started with the release of Bitcoin Whitepaper, released by Satoshi Nakamoto in 2009, and the deployment of cryptocurrency in 2011. Then, in 2013, smart contracts were deployed to overcome the security issues of IoT and machine learning models. Then, blockchain evolved by facilitating the deployment of decentralized applications in various sectors. Therefore, the evolution of blockchain technology impacts EVs in terms of better security, privacy, and reliability by modernizing the transportation system, which also helps to perform fault detection without any malicious attacks. For fault identification, we considered various types of faults (i.e., air tire pressure, temperature, and battery) to perform the prediction using CNN and LSTM anomaly detection models with higher accuracy. Blockchain combined with IPFS and a 5G network is advantageous for EV fault detection in terms of high security, reduced data storage costs, high reliability, and improved efficiency. detection implemented with a support vector machine (SVM). The fault detection system proposed by the authors applied various machine learning models to make the EV faultfree with strengthened privacy. However, the applied AI models could not maintain data integrity or confidentiality in the EV fault detection system. Due to this, malicious attackers can easily forge the components of EVs, which can cause several types of faults, such as air tire pressure, temperature, and batteries, which further deteriorate the performance of the fault detection. Therefore, to strengthens the security of EV fault detection, in this paper, we propose a blockchain and deep learning-based EV fault detection approach for safe journeys. A blockchain platform incorporated with deep learning models strengthen the security and confidentiality during fault detection in EVs. Once data are appended to the blockchain network, they cannot be manipulated by malicious attackers, which can predict faults in EVs correctly without any delay (with the high data rates and a low latency 5G wireless network). Moreover, Table 1 shows the comparative analysis of several trending technologies, such as blockchain, 4G, 5G, and IoT, along with their associated benefits and challenges. Based on the benefits, i.e., high security, high data rate, and low latency features of blockchain and 5G networks, EV fault detection using deep learning models is proposed for the safety of users during the journey. Additionally, Figure 1 shows the evolution of blockchain technology, which started with the release of Bitcoin Whitepaper, released by Satoshi Nakamoto in 2009, and the deployment of cryptocurrency in 2011. Then, in 2013, smart contracts were deployed to overcome the security issues of IoT and machine learning models. Then, blockchain evolved by facilitating the deployment of decentralized applications in various sectors. Therefore, the evolution of blockchain technology impacts EVs in terms of better security, privacy, and reliability by modernizing the transportation system, which also helps to perform fault detection without any malicious attacks. For fault identification, we considered various types of faults (i.e., air tire pressure, temperature, and battery) to perform the prediction using CNN and LSTM anomaly detection models with higher accuracy. Blockchain combined with IPFS and a 5G network is advantageous for EV fault detection in terms of high security, reduced data storage costs, high reliability, and improved efficiency.

Motivation
The objectives of this research work can be defined as follows: • Most of the existing AI-based EV fault detection frameworks mainly emphasize strengthening the privacy of EVs. However, there is no discussion on maintaining the integrity and confidentiality of EV data while considering diverse faults. • Considering the outlook of the literature, researchers [4][5][6][7][8][9] have highlighted the integrity and transparency challenges arising in EV fault detection systems. To overcome these issues, authors [13][14][15] have applied various AI models to ensure protected EV fault detection. However, they are still vulnerable to various security attacks due to the easy forging of data in AI models. Additionally, no literature discusses the combination of faults for EVs. • Thus, deep learning and blockchain-based EV fault detection frameworks are persuasive solutions to tackle multiple faults (air tire pressure, temperature, and battery) arising due to the intricate components of EVs. Moreover, the inclusion of 5G and IPFS strengthen EV fault detection in terms of reliability, storage costs, and scalability.

Research Contributions
The contributions of this research work can be explained as follows: • We propose a deep learning and blockchain-based EV fault detection framework considering faults, such as air tire pressure, temperature, and battery, which can occur due to the intricacy of components. Moreover, the inclusion of IPFS with the 5G network improves the scalability and reliability of fault detection for EVs. • Furthermore, the fault detection was performed considering the various EV faults using CNN and LSTM deep learning models to predict the output, which can be further classified as faulty or not. • The performance evaluation of the EV fault detection was estimated by implementing CNN and LSTM with the help of metrics, i.e., F1-score, precision, and recall. Then, we depicted the accuracy and loss curves for the various fault predictions of EVs.

Organization
The rest of the paper is organized as follows. Section 2 introduces the system model and problem formulation. Section 3 presents the proposed deep learning and blockchainbased EV fault detection framework. Section 4 presents the simulation result analysis. Finally, Section 5 presents the concluding remarks.

Related Works
Many researchers have proposed convincing solutions for EV fault detection (for safer journeys). For example, the authors of [16] presented a charging pile error detection mechanism based on the machine learning technique. Unlike the standard charging pile fault detection approach, the proposed mechanism generates data for common charging pile traits and builds a classification prediction framework based on the extreme machine learning algorithm. However, they needed to focus on the optimal charging aspect to perform the multiple faults detection for EVs' safety. Then, Basnet et al. [17] discussed the performance of the applied deep learning-based ransomware detection in supervisory control and data acquisition system (SCADA) for EVs. They enhanced the data integrity and privacy of the system by protecting EV data from malicious attacks, which were not discussed in [16]. Later, to address the data loss issues of [17], Li et al. [13] studied a data-driven approach for detecting battery thermal anomalies in EVs. However, identification of air tire pressure fault and data security issues were not discussed to that extent, which could cause hazardous situations for EVs when traveling longer. Then, the authors of [18] discussed a machine learning technique to perform sensor fault detection in an electric motor. The main aim of the proposed scheme is to attain improved accuracy by implementing various classifiers. However, the setup of the proposed scheme was not implemented in a dynamic real-time environment.
Furthermore, Javed et al. [19] presented a combinatorial framework of LSTM and a CNN deep learning model for anomaly detection in automated vehicles. Despite their improved performances, they need to identify multiple faults in automated vehicles, such as air tire pressure, battery, thermal, etc., for efficient fault detection. To overcome the security and privacy issues, which were not the main focus of the proposed scheme by authors in [19], Sani et al. [20] studied a survey on privacy preservation techniques for EVs with the help of machine learning and deep learning techniques. They also discussed various research challenges and future opportunities for privacy preservation of EVs. Further, a hybrid EV paradigm based on renewable energy resources was proposed in [21] to regulate the power supply and demand by utilizing various renewable energy sources, such as wind energy, solar energy, a supercapacitor, and a fuel cell. Then, the authors of [22] implemented an AI-based approach to perform fault detection for an electric powertrain to achieve a moderate accuracy for fault diagnosis. They should add detailed information on multiple features to improve the accuracy of the fault detection in the electric powertrain. Considering the outlook, most of the aforementioned researchers have incorporated machine learning or deep learning techniques for secure and accurate fault detection and diagnosis in EVs. However, they did not mention the identification of multiple types of fault detection in EVs (to ensure safe journeys for the users). Moreover, deep learning and machine learning techniques do not guarantee high security, privacy, and confidentiality during fault detection in EVs. Therefore, we propose a blockchain and deep learning-based fault detection framework for EVs. Blockchain technology overcomes the security and privacy data storage issues of the deep learning model by securing data transactions in an immutable and decentralized manner. Moreover, we predicted and identified three types of faults, i.e., air tire pressure, temperature, and battery, using CNN and LSTM models, which attain higher accuracies for efficient fault detection. Table 2 presents the comparative analysis of various state-of-the-art EV fault detection schemes with the proposed framework to highlight the research gaps, such as multiple faults, i.e., air tire pressure, temperature, and battery fault, security issues, and high data storage issues associated with the literary work, which motivated us to propose a blockchain and deep learning-based fault detection framework for EVs. Javed et al. [19] Proposed an anomaly detection framework for automated vehicles by combining LSTM and CNN Improved performance Needs to be implemented in a dynamic environment and also consider other types of faults

System Model
The blockchain-based EV detection system consists of a number of EVs along with the IPFS protocol integrated with the wireless 5G network. We consider several sensors equipped with EVs to detect faults in their components. For example, battery sensors are used for routine current and voltage values that could be used to detect battery faults in EVs. Next, a tire-pressure monitoring system (TPMS) sensor is used to obtain the air pressure values of the EVs. Moreover, the temperature sensor is equipped to yield fluctuation in temperature values of the EVs. After that, EV data extracted from these sensors should be approved by an authority so that EV data should be legitimate before IPFS accepts their requests for data storage. However, before enabling secure data storage through IPFS over a blockchain network, the extracted fault data from the sensors should be preprocessed and trained using deep learning models. We considered CNN, anomaly-based detection, and LSTM-based deep learning models to train the preprocessed air pressure, temperature, and battery (voltage and current sensors) data. The trained model predicts the output to classify data into faulty or no-fault. If predicted data are faulty, EVs should be informed about it to prevent any future accidents. Moreover, we introduced the blockchain network to enhance security in EV fault detection so that the correct message is forwarded to the EVs about the fault data. For that, a smart contract as a self-executable code was considered to verify the message forwarded to EVs, so that EV fault detection can be performed with strengthened security and privacy over the blockchain network.

Problem Formulation
In an EV fault detection framework, we included n number of EVs (δ 1 , δ 2 , δ 3 , δ 4 , δ 5 , δ n ) ∈ δ k associated with the number of entities E f ∈ {E a , E t , E b } in which E f is an entity, which represents the various faults detected by the sensors {S p , S t , S b } ∈ S e . Faults can be represented by E a , E t , and E b , which signifies the air pressure, temperature, and battery faults that can be detected in the EVs. The TPMS sensor can read various air pressure range values of the EV tires, which can be denoted by {P 1 , P 2 , P 3 , P 4 , P 5 , ...P n } ∈ S p , the temperature sensor reads the temperature data values, {T 1 , T 2 , T 3 , T 4 , T 5 , ...T n } ∈ S t , and finally, the battery sensor reads the data {B 1 , B 2 , B 3 , B 4 , B 5 ...B n } ∈ S b to detect fluctuations in the battery values of EVs, which are extracted using voltage and current sensors {S v , S i } ∈ S B , respectively. We take input parameters for batteries, as follows.
Moreover, variations in the air tire pressure, temperature, and battery values can cause faults in EVs. To understand the fluctuations in these values, we considered several scenarios to prevent faults in EVs for safer journeys. In the first scenario, EVs can suffer from a fault if maximum air tire pressure values generated from the TPMS sensor are generated. Considering the second scenario, temperature values associated with EVs tend to be maximum, increasing the vulnerability of the temperature fault. In another scenario, voltage and current sensors are considered to broadcast information about the battery fault to the EVs so that accidents can be prevented beforehand. Battery faults can occur based on the maximum fluctuation in the voltage and current values of the EVs.
We considered two more cases to represent the battery faults in the EVs. The foremost case is when voltage values tend to be maximum and current values tend to be minimum for the fault occurrence. In another case, measured voltage values should be minimum, while current values measured should be maximum to depict the battery faults in the EVs. Therefore, all the aforementioned scenarios explain the conditions based on which various types of faults can be detected in the EVs to ensure safe traveling for individuals. The association between fault detecting parameters, i.e., pressure, temperature, and battery, can be represented as follows.
{P, T, V, I} > 0 Therefore, the data obtained from the various sensors embedded with the EVs can be used to detect air tire pressure, battery, and temperature fault to inform about them antecedently to lessen the probability of accidents. Furthermore, the EV data acquired from the sensors should be preprocessed and trained using various deep learning models. Various deep learning models, i.e., CNN, anomaly detection, and LSTM, have been applied to the EV data to predict whether any fault is present or not to broadcast information about it to the EVs earlier. The deep learning models were trained on the EV fault data of air tire pressure, temperature, and battery, to securely perform fault detection. The input data of the various parameters (A input , T input , B input ) for the prediction using deep learning models can be represented as follows.
T input where ψ, χ, and ω signify the prediction of the air pressure, temperature, and battery data using CNN and LSTM deep learning models. Now, the prediction using deep learning models yields an output to classify EV fault detection as faulty or not faulty. However, EVs should obtain the correct information about the faulty data so, they can travel to their destinations without harming lives. Therefore, blockchain as a secure platform has been introduced in EV fault detection to avoid the broadcast of false information, reducing untimely accidents. However, the inclusion of an IPFS protocol with the blockchain decentralized network and the execution of smart contracts help to improve the security of the EV fault detection system by preserving the privacy of data [23]. Moreover, IPFS as an off-chain data storage uses content-addressing to store the data in the form of hashes, surpassing the blockchain by providing low costs for data storage. Finally, blockchain-based EV fault detection can be executed using deep learning models to warn beforehand about the faults in their components. Figure 2 shows the proposed framework consisting of three layers, i.e., EV fault layer, data analytics layer, and blockchain layer. The detailed descriptions of these layers are described as follows.

EV Fault Layer
This layer involves several EVs embedded with various sensors to acquire the relevant data to identify faulty data. EV data are initially processed, then feature extraction is conducted based on the kind and frequency of data flow from the specific data. We employed three sensors for each type of problem in our model. TPMS as a tire-pressure monitoring system sensor is used to measure the air pressure in the tires. This information allows us to identify whether the tire is flat or full of pressure. To monitor the thermal state of EVs, we employ a temperature sensor that produces a temperature measurement at regular intervals. Finally, for the battery, we employ current and voltage sensors to use the output of these values after a predetermined time interval to pre-process the relevant data.
The TPMS gives the output A i of air pressure in the unit of pressure per square inch (PSI). The minimum threshold for the data to be in the normal range is considered to be 45 PSI. Here, the input parameter for the model is taken as A input , and it is the data frame for the readings of TPMS after the specified time interval. The above-mentioned association can be represented as follows.
The temperature sensor output is given in either Fahrenheit or Celsius units. The EV temperature is utilized as an output and turned into a time series data frame T input , which is then used to train the proposed model.
where T i = {Time, Temperature}. Finally, for the battery fault detection, we obtain value from the voltage and current sensors associated with the battery for the specific time interval.
The units for the current and voltage measured are in amperes and volts, respectively. The incoming data are then converted into a data frame containing the values of the voltage V and current I for specific time stamps. The collections of data are represented by B input , as follows: The data obtained from these sensors should be passed to the data analytics layer for further pre-processing and training using deep learning models. Prior to that, the data should be approved by an authority who assigns them the token, which can be used to prove one's identity before data are pre-processed at the data analytics layer. Moreover, the security and privacy issues associated with the EV fault layer arises the need for the data analytics layer to perform the prediction of several faults in EVs. The main reason for security issues is due to the different sensors involved in extracting the information of faulty data from EVs that need to be tackled to ensure secure fault prediction.

Data Analytics Layer
Based on the type of EVs fault, the data analytics layer is separated into three stages, i.e., air tire pressure, temperature, and battery. We applied different deep learning models to the EV faulty data extracted from the EV fault layer. Therefore, we can consider three types of EV faults to apply CNN and LSTM to the data, which can be explained as follows:

Air Tire Pressure
We employ a CNN model to predict the air tire pressure for the detection of faults in EVs (as shown in Figure 3). CNN has been proven to produce the best results based on the considered image dataset [24]. The considered image dataset utilizes the images of tires for which the pressure is measured in PSI. It is trained on the image dataset, and subsequent predictions are produced for the prediction. Dataset D can be expressed as follows: where dataset D consists of each example E, which is labeled with the appropriate label L, which is then fed as an input to the CNN model. Table 3 shows the parameters considered to train the aforementioned model for the air tire pressure fault.

Temperature Fault Analysis
We consider the anomaly detection technique to identify the temperature fault in EVs. Unsupervised learning is used to train the model for this prediction, and we utilize the LSTM model to predict the data as faulty or not. EV temperature fault data are first preprocessed based on the requirement. The min-max scaler is used to preprocess the relevant parameters for training and testing the datasets for temperature fault detection. It transforms the temperature dataset T into a value range of [0, 1]. The dataset T is [22,695,5] in size. This dataset is then split into two parts, i.e., a training dataset and a testing dataset. T train and T test are created using different variables, such as prediction time, unroll-length, and test data size, which can be denoted by , (50), and k(1000), respectively. The above associations can be described as follows.
= + k + 1 (14) where the value of is calculated for splitting the dataset into train and test values.
The trained values of the temperature fault data are then passed to the LSTM model with the considered parameters. Table 4 depicts the parameters used for temperature fault prediction in EVs using the LSTM model. Optimizer RMSProp

Loss function MSE
The learning rate is defined as the root mean square propagation (RMSProp). It eliminates the requirement for learning rate adjustment by choosing it automatically for each parameter. Moreover, the RMSProp selects a different learning rate each time for different numbers of parameters. The detailed procedure for the RMSProp optimizer can be explained in the following steps.
where η is the initial learning rate, v t is the exponential average of squares of gradients and g t is the gradient at time t along with ω t . For each wrong prediction, the loss penalized can be defined as the mean squared error loss. The mean squared error (MSE) for each parameter can be calculated as follows.
The square element of the MSE ensures that no outlier prediction and error can occur in the trained model while detecting the anomalies in the EVs.

Battery Fault Analysis
The model deployed for EV battery fault analysis is the LSTM model. After preprocessing the input training data, the data B input are provided to the LSTM model for training and testing the data. The input sizes of the data, i.e., B input , are considered (34,866, 7) and Table 5 shows the relevant parameters considered for training the considered LSTM model along with the input data B input (34,866, 7). For the Adam optimizer, the parameters values, i.e., β = 0.9 and = e −8 , are considered. Furthermore, the activation function used for the dense layer of the model is the rectified linear activation function (ReLU) activation, which can be defined as follows: Each parameter in the dataset has an input value of x. If the input value is less than zero, the function returns to 0; if the input value is larger than 0, then the function returns x. The loss for the applied LSTM model on the battery fault data is determined using the mean absolute error loss function L(x, x ) to minimize the loss function. Therefore, the function can be defined as follows.
where x is the real value and x' is the predicted value of the LSTM model. Finally, the CNN and LSTM models can be applied to the air tire pressure, temperature, and battery fault for predicting the data as faulty or no-fault. Algorithm 1 shows the detailed procedure of three types of EV fault detection along with their input parameters that can be predicted with the time complexities of O(a), O(t), and O(on). Moreover, based on the output of faulty data, EVs can be warned beforehand to prevent any kind of severe accident beforehand. However, applied deep learning models cannot prevent various security attacks, such as data manipulation, data spoofing, and cyber attacks against the output of prediction of faulty data. For example, some malicious attackers can forge the output, which can transfer false information about the fault to EVs leading to the cause of an accident. Therefore, the blockchain layer is introduced to overcome the aforementioned security and privacy issues that occur while predicting the output of faulty data for EV safety.

Algorithm 1 Prediction model algorithm.
Input: Air pressure data (S p ), temperature data (S t ), battery data (S b ) Output: Prediction P 1: Take input data from three sensors 2: Load the input data for data preprocessing 3: for All EV(∆) do 4: for S p do 5: Generate input parameter A input for the CNN prediction model for S t do 10: Create input parameter T input for the Anomaly detection model 11: Data pre-processing(D) = change units, remove NaN/NULL values end for 15: for S b do 16: Create input parameter B input for the LSTM detection model 17: Data pre-processing(D ) = Feature extraction, min-max scaling

Blockchain Layer
The data extracted from the sensors in the EV fault layers are passed through the data analytics layer after applying CNN and LSTM models to perform the various types of fault detection analyses, i.e., air tire pressure, temperature, and batteries on EVs. Now, the predicted data of the data analytics layer may be vulnerable to various security and privacy attacks, which can disrupt the transparency of the system. Hence, to strengthen the security and transparency of fault detection in EVs, we introduced a blockchain layer to protect the predicted data from the data analytics layer to reduce the probability of EV accidents. The blockchain platform stores data in the form of a chain of blocks in an unalterable way to maintain the data integrity of the network. Furthermore, the blockchain utilizes a consensus mechanism, which ensures that all the nodes in the network should agree to add to that particular transaction. Otherwise, the transaction can be discarded, further maintaining the security of the system. Initially, EV fault analysis data can be secured by registering with an authority that assigns a token to the EVs to detect the faulty parameters of their components (e.g., battery, tire, or thermal).
Then, the IPFS is involved in the blockchain layer to validate EVs data, which are preserved by an authority. Now, EVs can issue a request to store their fault analysis data in the IPFS instead of a blockchain to ensure low-cost data access in a distributed manner for EVs. The data storage in an IPFS smart contract is written as a self-executable code that needs to be executed to check the authenticity of the EV data predicted from the data analytics layer. The data predicted from the data analytics layer seem to have security and privacy issues for data storage, which can be resolved with blockchain and IPFS. Furthermore, to allow the data storage of EV data in the IPFS, they need to return the respective hash keys to the EVs. Now, after attaining the data storage through IPFS in a cost-efficient manner, EVs can take advantage of the blockchain decentralized network to accomplish a secure journey (and preserve fault detection analyses for a safer journey). Blockchain as a distributed network provides a secure platform for EV fault detection by accessing the corresponding hash keys δ k generated from the IPFS protocol. To attain secure fault detection for EVs, asymmetric cryptography can be applied to authorize the EV data during the fault detection using public and private EV keys (Θ δ ky k , Ω δ ky k ), which can be described as follows [25].
where η dg denotes the hash digest to perform fault detection for EVs. λ

Dataset Description
In this paper, different datasets are referred to for various faults that need to be detected in the proposed model. The faults considered in the dataset are air tire pressure, thermal/temperature, and fault pertaining to the battery of EVs. The dataset [26] considered for the fault detection of air tire pressure consists of images of tires, which are labeled as either full or flat. For the prediction of temperature fault, we utilize the NAB dataset [27], which consists of data related to the anomalies. Finally, for fault prediction in electric car batteries, we utilize the dataset in [28], as it contains many metrics related to lithium-ion batteries that may be used for prediction. Each of the following datasets is explained in further sections, regarding data pre-processing and implementation. The datasets considered for these faults are as follows:

Air Tire Pressure Fault
The full and flat tire image dataset will detect air tire pressure faults in the EVs. An air tire pressure fault occurs when the TPMS sensor in the tire of the EV will not be able to communicate with the car. This warning generally does not appear when the tire pressure is either too low or too high. The normal range is around 45 PSI and a low PSI range is considered around 10 PSI. The dataset consists of images of the tire, which can be classified into three categories, i.e., full tire, flat tire, and no tire. There are a total of 900 images in which each labeled section consists of 300 images of size 240 × 240. A full tire is defined as a tire with 45 PSI and a flat tire is defined with 10 PSI. Figure 4a-c shows the different types of tires in which data have been preprocessed and trained to detect the faults associated with the air tire pressures in EVs.

Thermal/Temperature Fault
Thermal (or temperature) EV fault detection was analyzed using the Numenta Anomaly Benchmark (NAB) dataset [27]. The dataset consists of temperature sensor data of an internal component of a machine inside the electric vehicle. From the continuous input coming from the temperature sensors of the machine, it is possible that it may send us a record that may be an outlier. This outlier may cause difficulties if we want to work on these data further. Thus, we detect the outlier as an anomaly, considering it as a fault from the temperature sensor. The first anomaly is a planned shutdown of the machine. The second anomaly is difficult to detect and directly leads to the third anomaly, a catastrophic failure of the machine. The dataset consists of the machine's temperature in Fahrenheit along with the different timestamps.

Battery Fault
The definition of fault considered for fault prediction is the predicted battery state of health. We predict the state of the health of the battery and compare it with the original data. A fault is declared when there is a difference between the prediction and actual SOH. We considered the Nasa Li-ion battery aging dataset for battery fault detection. These data were gathered from the NASA Ames Prognostics Center of Excellence (PCoE) with the help of a custom-built battery prognostics testbed. With fluctuating temperatures, Li-ion batteries are subjected to three different operating profiles (charge, discharge, and electrochemical impedance spectroscopy). These data were collected from commercially available Li-ion 18,650-sized rechargeable batteries. As a result, the dataset comprises the following parameters, i.e., cycle, type, ambient temperature, time, data, the voltage measured, current measured, temperature measured, current charge, and voltage charge for charging as well as discharging period.

Data Preprocessing
We discussed the different datasets for various effecting parameters in the EV fault detection. Now, we need to understand the preprocessing of the aforementioned data so that data of various parameters can be trained and tested utilizing several deep learning models. Considering the first case of the air tire pressure dataset, there is no required preprocessing based on the image dataset's relevancy. We converted all of the given temperature units from Fahrenheit to Celsius in the thermal fault dataset for better understanding. As this dataset is mainly considered for anomaly detection, there is no requirement for the removal of NaN or NULL values.
On the other hand, we customized the battery fault analysis data by considering the relevant parameters only. The required parameters can be denoted by time, voltage, current, temperature, and capacity. Furthermore, we optimized the dataset by applying min-max scaling to every feature of the training dataset based on the set range of [0,1]. The min-max scaling (on each attribute of the training data) was performed with the help of equations, expressed as follows. X_std = (X − X.min(axis = 0)) (X.max(axis = 0) − X.min(axis = 0)) (23) We added a new attribute, i.e., SoH, which signifies the state of the battery in terms of aging; it indirectly reflects the probability of fault occurrence. Now, the data were prepared for training and testing using CNN and LSTM models, which were analyzed based on the type of faults.

CNN-Based Results for Air Tire Pressure Fault
We applied the CNN model to perform air tire pressure fault detection in the EVs. First, the CNN model is trained on the image dataset and then tested on the validation data and test data of the considered dataset. To analyze the performance of the proposed model, we identify different parameters, such as F1 score, accuracy, and losses of the trained model, which help us to analyze its performance and efficiency. Figure 5 shows the correlation between the prediction accuracy of the CNN model on the train and test datasets for air tire pressure fault detection. The train and test datasets were sampled based on the 64 Epochs with a step size of 8 per Epoch. Similarly, Figure 6 depicts the loss curve for the train and test datasets applied using the CNN model for air tire pressure fault detection in EVs. Furthermore, Figure 7 shows a generated confusion matrix for the test data to classify whether prediction by the trained CNN model yields correct output or not.

Anomaly Detection for Temperature Fault
Another result analysis involves EV temperature fault detection. We detected the abnormal temperature values for EVs by detecting the outliers from the given dataset. The outliers are detected by implementing the LSTM on the considered dataset of the temperature fault. On training the LSTM model on the dataset, the temperature values deviate from the predicted values that are detected as anomalies. The LSTM model is trained on the dataset by classifying it into training and testing data with a ratio of 80:20. Moreover, Figure 8 depicts the loss curve while training the LSTM for temperature fault prediction along with the batch size of 3000 and epochs of 50. Additionally, we observed that the loss between the training and validation set almost converges and the final loss in the validation test is 0.0349. The trained model is then used for the test dataset to find the predicted values for the temperature fault. After the training of the model, we attained the predicted values of the temperatures from the given values in the test dataset. In Figure 9, the final comparison, i.e., the difference between the predicted and original test set, is plotted. The comparison between the predicted and test values indicate the performances of EV temperature fault prediction using anomaly detection to warn about the predicted data beforehand. Finally, considering the differences between predicted and test values, Figure 10 depicts the anomalies detected for EV temperature faults. We can conclude that the values that are not on the regular curve are considered anomalies for the temperature values and we can visualize them from the graph (in red). For the evaluation of the model, we calculate the R 2 Score due to the presence of continuous values. The value of the R 2 Score is calculated as 0.8761, which is calculated with the help of an equation, defined as follows: where SSR is the sum-squared regression and SST is the total sum of the squares.

LSTM-Based Results for Battery Fault
To analyze the battery fault detection, we considered an additional parameter, i.e., SoH, to define the state of the battery of EVs. The other parameter of SoH is predicted with the help of neural networks to check the performance of the battery based on the standard parameters. The model is trained considering the input dataset along with the help of a parameter, i.e., the capacity of the battery calculated using the dataset. Then, SoH can be computed with the help of the aforementioned capacity of the battery. Finally, the calculated SoH can be appended to the training dataset while predicting the correct state of the battery for the improved performance and efficiency of EVs during the journey.
The training dataset is then passed into the model containing dense layers and a single dropout layer. The model is trained with 50 epochs and a batch size of 25. As a result, Figure 11 shows the predicted SoH that can be used to define the state of the battery. So, the poor condition of the battery can cause accidents or interrupt the journey of EVs. The evaluation of the LSTM model for battery fault prediction is estimated based on the root mean square error (RMSE) and the value of the R 2 score. The equation of RMSE can be mentioned as follows [29].
where n is the parameter values in the predicted and training datasets. The value of RMSE is calculated as 0.02108 and the value of the R 2 Score is calculated as 0.93753.

Blockchain and IPFS-Based Analysis
In the proposed framework, we incorporated a blockchain layer to enable secure (and preserve fault detection in the) EVs. For that, the fault data (air tire pressure, thermal, and battery) are extracted from various sensors equipped with EVs in the EV fault layer to predict the data as faulty or non-faulty using deep learning models, such as CNN and LSTM. Thus, the blockchain layer is further appended along with the IPFS immutable protocol to store and detect EV data securely and efficiently. In this section, we analyzed the efficiency of the blockchain with IPFS regarding computation time and delay comparison. These can be mentioned as follows.

Computation Time
The reliability of the blockchain network with the IPFS protocol in the proposed model can be measured by calculating the computation time required to perform the EV data storage or retrieval to the network. Initially, executing a smart contract based on the predetermined conditions decides the data storage of the EV fault data. Suppose, the smart contract permits the association of EVs with the blockchain for data storage purposes. In that case, the computation time of an EV to access the blockchain for data storage takes approximately 8 × 10 −2 s [30]. Alternatively, if the additional immutable IPFS protocol is used with the blockchain network for EV fault detection, then the computation time for data storage in the blockchain with IPFS can be calculated in 11 × 10 −2 [31]. The computation time associated with the mediator IPFS and blockchain network surpasses the computation time of data storage in the blockchain. Regardless of the higher computation time, the IPFS protocol is shown to be beneficial for EV fault detection data storage as it seems to be profitable in terms of cost-efficiency.
We discussed the computation times of EV data storage in blockchain with IPFS for fault detection. However, we also need to consider the data retrieving the time from the blockchain. For example, if data are retrieved directly from the blockchain, then it takes about 6 × 10 2 s [32] due to the applied SHA-256 algorithm. However, if we incorporate IPFS with blockchain, then the data retrieval time for the EV fault detection can be calculated at 0.075 s [30]. Thus, it can be perceived from the aforementioned scenario that the data retrieval time of EV data storage through the IPFS yields lower than the blockchain.

Data Storage Cost Analysis
In this section, we highlight the data storage cost analysis for the proposed EV fault detection. The proposed model consists of a blockchain and IPFS combinatorial framework that incurs a low cost to avail off-chain data storage of EVs. We need to focus on various aspects to analyze the EV data storage costs. Initially, we have to specify the gas price of a single word that can be denoted by G p Wd . Furthermore, the associated gas for 1 KB of data needs to be computed considering G p Wd , as follows: 1G p Wd = 20 × 10 3 Gas(σ = 20k) (27) gs kb = (20 × 10 3 ) × (2 10 /256) Gas Nevertheless, after calculating the gas for a particular amount of data (1 KB), the Ethereum price, i.e., Er pe bn = USD 232.96, and gas price, i.e., gs pe bn = gwei 23.186, can be combined to determine the EV data storage cost denoted by Dc T EV for T number of words in the blockchain. Hence, Dc T EV can be written in the form of the expression to store T number of words while considering 1E t = 10 9 , as follows: Thus, Dc T EV (in USD) to store T number of words utilizing parameters. Finally, the data storage costs of K words in USD can be determined by observing the parameters Dc T EV , gs pe bn and Er pe bn . These parameters can be expressed as follows.
Therefore, IPFS (as a content-addressing protocol with the blockchain network) leads to optimized storage costs Dc T USD EV for EVs with the help of access to data in the form of a hash [33].

Conclusions
This paper highlights a deep learning and blockchain-based EV fault detection framework to ensure safe and fault-free journeys. As per the literature, it has been observed that conventional EV fault detection systems with AI-based models do not guarantee the integrity and confidentiality of predicting the combination of faults due to the component intricacies. Moreover, the inclusion of IPFS and a 5G network with the fault detection system addresses the high data storage costs and scalability issues of conventional systems and detects the various types of EV faults, i.e., air tire pressure, temperature, and batteries. Furthermore, the aforementioned faults were detected utilizing the CNN and LSTM deep learning models to predict the output (fault or no-fault) with higher accuracy. The CNN and LSTM models were applied to perform EV fault detection with the predicted accuracy of 70% for air tire pressure fault, anomaly detection of the temperature fault, and battery fault detection with R 2 Scores of 0.874 and 0.9375.