Research Article

A Real-Time Data Monitoring Framework for Predictive Maintenance Based on the Internet of Things

Algorithm 1

Monitoring and fault prediction of devices in a smart office.
Require: monitor office conditions and check the status of appliances and sensors remotely and locally.
Input: Real-time monitoring of current sensors in (AC, Coffee Machine, CCTV, TV, Light, Printer), Temperature & Humidity Sensor, Motion Sensor, Air Quality Sensor, Fire Sensor, On/Off Switches For Particular Appliances, Static IP address, WiFi Access Point Username/Password, Arduino kit and its pins, Arduino IoT Cloud Server.
Initialization:
(1)A: AC value//fetched from the ACS712 sensor where the threshold value is between 9 A to 11 A
(2)C: Coffee Machine value//fetched from the ACS712 sensor where the threshold value is between 5 A to 7 A
(3)CC: CCTV value//fetched from the ACS712 sensor where the threshold value is between 1 A to 3 A
(4)TV: TV value//fetched from the ACS712 sensor where the threshold value is between 2 A and 4 A
(5)L: Light value//fetched from the ACS712 sensor where the threshold value is between 0.5 A to 1.5 A
(6)P: Printer value//fetched from the ACS712 sensor where the threshold value is between 1 A to 3 A
(7)AQ: Air quality value//from MQ135 sensor (either 0 or 1)
(8)U: Ultrasonic value//from HC-SR04 sensor (either 0 or 1)
(9)TH: Temperature & humidity value//from DHT11 sensor (either 0 or 1)
(10)F: Fire value//from IR sensor (either 0 or 1)
(11)D: Door value//from motion sensor (either 0 or 1)
(12)S1: 0/1 value//AC state is ON/OFF
(13)S2: 0/1 value//coffee machine state is ON/OFF
(14)S3: 0/1 value//CCTV state is ON/OFF
(15)S4: 0/1 value//TV state is ON/OFF
(16)S5: 0/1 value//light state is ON/OFF
(17)S6: 0/1 value//printer state is ON/OFF
(18)Sensors and all appliances are connected to Arduino which sends the data to the cloud server through a WiFi Access Point, which sends the data to the Arduino IoT cloud server.
Steps:
(1)for each round do
(2)Fetch values of A, C, CC, TV, L, P, AQ, U, TH, F, D, S1, S2, S3, S4, S5, and S6.
(3)Upload data from Arduino to Arduino IoT cloud server through WiFi and update the status of sensors and appliances on the cloud server.
(4)Data went through the machine learning model, i.e., k-nearest neighbors and naive Bayes for fault prediction and synced to the mobile application from the cloud server.
(a) Read data and load all libraries and dependencies required.
(b) Preprocess data to make it useful for analysis.
(c) Visualize various sensor values over time and in comparison to others.
(d) Split the data into two sets: training and testing with 70% and 30% data, respectively, and visualize class distribution in training and testing datasets in the same.
(e) A list of classifiers and their respective functions from Scikit-learn is made to pass to the pipeline function.
(f) The purpose of the pipeline is to ensemble several steps like a list of transforms and a final estimator.
(g) The training dataset fits the pipeline to train data for various classifiers and calculate accuracy scores and other evaluation metrics.
(h) Tested the model on testing data and saw how well it performed by comparing using evaluation metrics such as accuracy, F1-score, precision, AUC, specificity, sensitivity, and recall.
(i) Get the predicted values for the next values of the sensors.
(5)The predicted data is divided into the following cases to recommend solutions
Case 1 (ACS712)
(a) If (FA)//fault in AC
 Notify user via notification “repair or replace AC.”
 break;
(b) If (FC)//fault in coffee
 Notify user via notification “repair or replace coffee machine.”
 break;
(c) If (FCC)//fault in CCTV
 Notify user via notification “repair or replace CCTV.”
 break;
(d) If (FT)//fault in TV
 Notify user via notification “repair or replace TV.”
 break;
(e) If (FL)//fault in Light
 Notify user via notification “repair or replace light.”
 break;
(f) If (FP)//fault in printer
 Notify user via notification “repair or replace printer.”
 break;
(6)User checks data of sensors and appliances in real-time remotely via a smartphone app that recommends solutions to user.
(7)end for
Output: Working status of each and every device and sensor.