Skip to main content
. 2025 Mar 28;25(7):2146. doi: 10.3390/s25072146
Algorithm 1: Handle faulty sensors using anomaly detection during sensor-processing pipeline
  • Input:

  • Input data from RGB sensor (S1 RGB), Thermal (IR) Sensor, S2IR, Gas Sensor S3Gas, Smoke sensor S4Smoke and Flame sensor S5Flame.

  • Output: Normal and faulty Sensors Pre-processed output data received from Edge Computing On-Site Pre-processing server will be an input to a machine learning algorithm which are MobileNet CNN for RGB, efficientNet for IR, RandomForest for smoke, SVM for Gas and decision tree for flame.

  • Process:

  1. #Acquisition of Data: Data will be continuously received from RGB, IR, Gas, Smoke and Flame sensor:

    S1DA, S2DA, S3DA, S4DA, S5DA

    #Sensor Data Pre-Processing:

  2. #Check the HMAC Cryptographic Validation, Validate each sensor’s data using cryptographic techniques: Use a shared #cryptographic key to validate the integrity of the sensor data S1DA, S2DA, S3DA, S4DA, S5DA

  3. # Handle Fault tolerance: If cryptographic validation fails, attempt re-transmission request for invalid sensor data. If re-transmission fails, check #for redundancy by using data from other sensors and replace faulty data. Discard the S1DA, S2DA, S3DA, S4DA, S5DA #data if no redundancy is available

    for SensorData in [S1DA, S2DA, S3DA, S4DA, S5DA]:

    if not validate_hmac(SensorData):

    ReattemptTransmission(SensorData) # Re-transmission request for invalid data

    if not is_data_reliable(SensorData): # Check if redundancy mechanism can replace the failed data

    discard_data(SensorData) # Discard the data if no redundancy is available

  4. #Data Filtering, noise reduction filters applied to the RGB, IR, Gas, Smoke and Flame sensor data.

  5. #Identified and handled missing values, if missing values are found, removed the data which are affected

  6. #Normalized the sensor raw values (Ri, Gi, Bi, Ti, Gi, Si, Fi) received, S1Ni,, S2Ni, S3Ni, S4Ni, S5Ni.

  7. #Calculate Statistics, Mean and standard deviation

  8. #Calculate mean S1M, S2 M, S3M, S4M, S5M for the normalized data, For 5 sensor (Ri, Gi, Bi, Ti, Gi, Si, Fi) where i = 1 to n

  9. #Calculate standard deviation S1SD, S2SD, S2SD, S3SD, S4SD, S5SD for the normalized data for 5 sensor values ((Ri, Gi, Bi, Ti, Gi, Si, Fi) where i = 1 to n

  10. #Anomaly Detection, Implement Statistical Methods and calculate Dynamic Threshold for every sensor

    DynamicUpperThresholdi=Si M+2  SiStd

    DynamiclowerThresholdi=Si M2  SiStd

    #where i = 1 to 5 as 5 sensors are used, any reading that deviates more than 2 standard deviations from the mean #will be considered anomalous.

    if Si > DynamicUpperThresholdi or Si < DynamicLowerThresholdi, Si_anomaly = 1 for anomalies, 0 for normal

  11. #record the anomaly detected as this may be from faulty sensor. This find whether the sensor’s reading is #anomalous based on raw, untransformed data.

  12. #Check each normalized value for anomalies and abnormalities

    if (SiNi) > 3, set the Si AD = 1 else 0 where i = 1 to 5 sensors, #anomaly flag = 1

    #Further checks for sensor reliability and fault detection if anomaly detected

    if SiAD[i] == 1# If sensor is flagged as anomalous, further checks are needed

    # Check if the sensor’s historical failure rate (FR) exceeds a threshold

    if historicalfailurerate[i] > failurethreshold, SiAD[i] = 1 # Confirm the sensor as faulty

    # Check if the sensor’s calibration issue is out of acceptable range

    elif abs(SiNi[i]—expectedcalibration[i]) > calibrationthreshold,SiAD[i] = 1 # Confirm the sensor as faulty

    # Check the sensor’s signal-to-noise ratio (SSNR) if it’s below acceptable level

    elif SSNR[i] < ssnrthreshold, SiAD[i] = 1 # Confirm the sensor as faulty

    # Check if the sensor’s performance metrics (PSM) show a degradation (e.g., low response)

    elif sensorperformance[i] < performancethreshold, SiAD[i] = 1 # Confirm the sensor as faulty

    # Check environmental impact factors (EIF), like temperature or humidity affecting sensor

    elif environmentalfactors[i] > environmentalthreshold, SiAD[i] = 1 # Confirm the sensor as faulty

    else

    SiAD[i] = 0-- # If none of the checks indicate a fault, set anomaly flag to 0(normal) where i = 1 to 5 types of sensors

  13. #Send the transformed data to the machine learning algorithm Mobile Net CNN, Efficient Net CNN, Random Forest, SVM and decision tree.

    S1 DP = {“Anomaly detected”: S1AD, “mean”: S1M, “standard deviation”: S1SD, “normalized_data”: S1Ni, Auxiliary_data}

    S2 DP = {“Anomaly detected”: S2AD, “mean”: S2M, “standard deviation”: S2SD, “normalized_data”: S2Ni, Auxiliary_data}

    S3 DP = {“Anomaly detected”: S3AD, “mean”: S3M, “standard deviation”: S3SD, “normalized_data”: S3Ni, Auxiliary_data}

    S4 DP = {“Anomaly detected”: S4AD, “mean”: S4M, “standard deviation”: S4SD, “normalized_data”: S4Ni, Auxiliary_data}

    S5 DP = {“Anomaly detected”: S5AD, “mean”: S5M, “standard deviation”: S5SD, “normalized_data”: S5Ni, Auxiliary_data}

  14. END