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

Authors: Mudita Uppal; Deepali Gupta; Nitin Goyal; Agbotiname Lucky Imoize; Arun Kumar; Stephen Ojo; Subhendu Kumar Pani; Yongsung Kim; Jaeun Choi
Journal: Complexity
 (2023)

---

## Abstract

The Internet of Things (IoT) is a platform that manages daily life tasks to establish an interaction between things and humans. One of its applications, the smart office that uses the Internet to monitor electrical appliances and sensor data using an automation system, is presented in this study. Some of the limitations of the existing office automation system are an unfriendly user interface, lack of IoT technology, high cost, or restricted range of wireless transmission. Therefore, this paper presents the design and fabrication of an IoT-based office automation system with a user-friendly smartphone interface. Also, real-time data monitoring is conducted for the predictive maintenance of sensor nodes. This model uses an Arduino Mega 2560 Rev3 microcontroller connected to different appliances and sensors. The data collected from different sensors and appliances are sent to the cloud and accessible to the user on their smartphone despite their location. A sensor fault prediction model based on a machine learning algorithm is proposed in this paper, where the k-nearest neighbors model achieved better performance with 99.63% accuracy, 99.59%F1-score, and 99.67% recall. The performance of both models, i.e., k-nearest neighbors and naive Bayes, was evaluated using different performance metrics such as precision, recall, F1-score, and accuracy. It is a reliable, continuous, and stable automation system that provides safety and convenience to smart office employees and improves their work efficiency while saving resources.


---

## Body

## 1. Introduction

The Internet of Things (IoT) defines a network of objects which can be identified distinctively in virtual cyberspace. It has embedded sensors, software, and other technologies which communicate and exchange data with other appliances. It processes data and creates techniques incorporating smart technology, radio frequency identification (RFID) [1], sensing equipment, and other technology advancements. Some other complementary technological developments can be used with IoT to enrich its abilities to lower the gap between the physical and virtual world [2, 3]. IoT sensors have been used in various applications for the last few years, such as predicting natural disasters, home/office automation, etc. [4–6]. One of the potential application areas of IoT is office automation, which has recently been proliferating. Office automation, also known as an intellectual office system, provides an assisted working environment to the users that enhance their quality of work [7]. Office automation exploits micro/nanoelectronic technology within the office environment to help and improve the quality of work as well as the life of its employees by increasing comfort and providing real-time monitoring and remote surveillance [8–10]. An intellectual office system needs a network, monitoring instruments, and office components. The main research motivation is to construct a smart office that predicts fault early in any appliance to increase the productivity of the work performed by employees.Smart office system implementation needs to be controlled centrally. So, cloud computing is used to save the data centrally [11]. Office automation involves controlling the electrical loads using the Internet, WiFi, and Android [12]. A modern office automation system consists of several appliances and sensors which can be interfaced with the user via a mobile phone computer through Internet cloud services. The existing office automation systems lack the reliability and response of operation, so Arduino, an open-source platform, is used nowadays to easily monitor the office appliances and sensors with the help of an Android application. WiFi-based office automation is easy to control and eliminates wires because data are sent via air in the wireless mode. In contrast, Bluetooth-based office automation operates for a very short range of distance as compared to the WiFi-based one. So, there is no need to replace the old appliances in the proposed model. Just only adding a few components will act as IoT sensor nodes.Fault prediction is an essential technology that assures a secure operation of appliances. Based on the investigation of recent research in the domain of fault prediction, an intelligent fault prediction model based on IoT is proposed in this paper [13, 14]. This model aims at enhancing the working efficiency of appliances and the intelligence level regarding fault prediction of appliances. First, the current values of the appliances are analyzed, and then the model continuously monitors the correct functioning of appliances, then reliable data transmission to the cloud, and its intelligent processing for fault prediction through a machine learning algorithm. The main objective is to predict faults in IoT devices before their occurrence so that replacement or repair can be conducted beforehand.


### 1.1. Contribution

This work exhibits the design and fabrication of a smart office model that uses everyday electrical devices for analysis using Arduino and does not operate on costly IP-based appliances. The ordinary lights, printers, coffee machines, and other electronic appliances can also be used in this system. A smartphone application is also being developed for the end-user to inspect and monitor the functioning of devices easily and interactively. Therefore, this smart office automation system is operated without much human intervention. The proposed model makes the following contributions:(i)
A microcontroller-based (Arduino) office automation system is fabricated in this paper, which syncs the data to the cloud and analyzes the current values of the appliances and sensors(ii)
The real-time monitoring of data collected from appliances and sensors is performed for predictive maintenance(iii)
A machine learning algorithm is developed, which helps the user check the status of appliances in an automated office


### 1.2. Paper Organization

The remaining paper is organized as follows: Section2 illustrates the related work. The prototype development, including overall system architecture, design, fabrication of smart office, and hardware specification, is described in Section 3, whereas the working methodology is expressed in Section 4. Implementation and results are given in Sections 5 and 6, respectively, and the conclusion and future scope are presented in Section 7.


## 1.1. Contribution

This work exhibits the design and fabrication of a smart office model that uses everyday electrical devices for analysis using Arduino and does not operate on costly IP-based appliances. The ordinary lights, printers, coffee machines, and other electronic appliances can also be used in this system. A smartphone application is also being developed for the end-user to inspect and monitor the functioning of devices easily and interactively. Therefore, this smart office automation system is operated without much human intervention. The proposed model makes the following contributions:(i)
A microcontroller-based (Arduino) office automation system is fabricated in this paper, which syncs the data to the cloud and analyzes the current values of the appliances and sensors(ii)
The real-time monitoring of data collected from appliances and sensors is performed for predictive maintenance(iii)
A machine learning algorithm is developed, which helps the user check the status of appliances in an automated office


## 1.2. Paper Organization

The remaining paper is organized as follows: Section2 illustrates the related work. The prototype development, including overall system architecture, design, fabrication of smart office, and hardware specification, is described in Section 3, whereas the working methodology is expressed in Section 4. Implementation and results are given in Sections 5 and 6, respectively, and the conclusion and future scope are presented in Section 7.


## 2. Related Work

Office automation has been in great need for the last few years. So, plenty of commercial systems and ample research work can be found. The research work closely related to the current study is discussed as follows.Jabbar et al. [15] developed an IoT@Home system for real-time monitoring of home devices. Many actuators and sensors were linked to the controller named NodeMCU for data updation on IoT servers. The data obtained from the sensors were observed via the MQTT dash phone application and Adafruit IO web via laptop. The end-user gets messages on the phone via the IFTT server regarding the abnormal condition of any device in their home for security reasons. Verma and Tripathi [16] implemented a digital security system that consists of a door lock system using RFID passively. To manage and transact operations, a centralized system was deployed. This system operates in real time as if a tag is put in contact with the reader by the user, the door unlocks, and the check-in details are saved on the server. The RFID technology used in the system provides a solution for safe access to a place while maintaining the user’s record. Oke et al. [17] illustrated a low complexity and low-costmicrocontroller-based security door system that uses a smart card to allow and refuse access to the building. A real-life prototype was also created with minimum cost. Naveed et al. [18] recognized the importance of identification, whether it is a person, animal, or object. According to them, RFID is the best solution to this problem of authentication and identification. It was a low-cost system that was deployed at building doors. It was also chaperoned by desktop interfacing to check the authentication details with real-time data.Saravanan and Vijayaraj [19] proposed a remote home automation control system based on wireless technologies. The proposed architecture contributes to home network service and automotive hospital and office services. The focus of the architecture proposed was its security improvement. Felix and Raglend [20] considered the home environment a quick introduction to network-enabled digital technology. It helps in increasing device connectivity within the home for automation. With the help of the Internet, it can be remotely controlled and easily monitored. Sharma and Reddy [21] used a wireless sensor network to design home automation. The main purpose of this work was to survey different wireless sensor networks for home automation. They presented a flexible and simple model for the automation of water leakage, light, temperature, fire, and gas leakage with the help of sensor nodes observed via the master node of the connected laptop. Darianian and Michael [22] proposed an automated system of energy saving that tracks people while entering and leaving the room and automatically turns off the fan and light. Room temperature was sensed to increase or decrease the speed of the fan. If the temperature is not decreased, then another AC or fan is turned on. The light intensity was decreased or increased based on sunlight intensity. A microcontroller was used to save electricity on the basis of human activity.Rehman et al. [23] used a machine learning-based scheme for intrusion detection and network support in the IoT. Also, they explored machine learning methods to identify IoT devices coupled with cyber attacks. The authors of reference [24] presented the effectiveness of using recommender systems in IoT and discussed various IoT-based recommendation technologies that recommend future solutions. Kumar et al. [25] surveyed blockchain for industrial IoT. Some issues and research directions in blockchain and industrial IoT were also summarized in this paper. Gopikumar et al. [26] designed an effortless robotic waste segregation device controlled by IoT devices. Specifically, they developed the leach bed reactor combined with an up-flow anaerobic sludge blank reactor merged with IoT devices. The authors of reference [27] proposed architecture based on the convolutional neural network for recognizing month names in Gurumukhi. The authors [28] proposed a framework that balances a load of fog nodes to handle the requirements of smart real-time applications. The authors of reference [29] used natural language processing as an interface between humans and machines to control devices at home for a disabled person, whereas the authors of reference [30] proposed a detailed architecture of DePaaS that solves the challenges of software defect prediction. The authors of reference [31] emphasized on a fault predictor model that helps in lowering expenses that occurred during the development as well as maintenance. Nath et al. [32] proposed a device for the security of bicycles and the health analysis of bicycle riders. A mobile application has also been developed that stores and displays real-time data from the device. The authors of reference [33] examined the issue of coalition formation, resource management, and interest in smart IoT applications. In order for M2M devices to indicate their communication preferences based on the IoT application involved, the idea of interest ties is presented. A distributed resource management system is proposed to determine the best transmission power for each M2M device in order to meet its QoS requirements. Through modeling and simulation, the proposed approach’s effectiveness is assessed and its superiority to alternative state-of-the-art methodologies is demonstrated. Ashraf et al. [34] designed and implemented an automation system with user and admin modes. The appliances were controlled via a smartphone application developed in Android Studio. The devices can be controlled by the user locally and remotely. The Microsoft Azure cloud database server provides access to all home appliances. Data logging is conducted to recover sensor data in case of an electricity breakdown. Besides, the preferences of the user can be set, and those requirements can be fulfilled. The notifications are sent to the users if any device runs over 2 hours. This system provides simplicity, affordability, and reliability.


## 3. Background and Materials

### 3.1. Overall System Architecture

The proposed architecture consists of Arduino, sensors, electrical appliances, and a smartphone application used in office automation. This system contains multiple electrical appliances such as AC, printer, TV, coffee machine, light, and CCTV, and digital sensors such as temperature and humidity, motion, air quality, and fire. The proposed office automation system comprises 4 modules: Arduino, Cloud, a smartphone application, electrical appliances, and sensors, as shown in Figure1. The arrows present in the figure illustrate data flow from one module to another.Figure 1
Proposed architecture of the office automation system.The current sensors added in electrical appliances and some other digital sensors present in the architecture send data to the Arduino IoT Cloud through WiFi based on the status of the pins where corresponding loads are to be active and in the appropriate range. The dataset is generated by the sensors present in the prototype which are collected on Arduino IoT Cloud through WiFi. The Internet connection through WiFi is used to observe, analyze, and predict the faults in appliances present in the office environment using the smartphone application. The sensors installed inside the office update their data continuously every 2 sec and respond to any change that occurs to the user via smartphone with the help of a machine learning algorithm.Many wireless technologies are present in the market, such as Bluetooth and WiFi. Bluetooth is basically used for short-range communication, whereas WiFi is used for data transfer over longer distances with high data rates. Table1 presents the comparison of Bluetooth and WiFi in detail.Table 1
Comparison of wireless technologies.
S. no.StandardBluetoothWiFi1RangeLow (10 m)High (100 m)2SecuritySecuredMore secured3Transmission rate1 MbpsUpto 54 Mbps4Latency200 ms150 ms5Bit rate2.1 Mbps600 Mbps6Time for network communication10 sec3 sec7Standby current200µA20µA8Number of nodes720–2509Nominal TX power0–10 dBm15–20 dBm10Channel bandwidth1 MHz20–25 MHz11ApplicationCable replacementData network and Internet monitoringDifferent parameters of Bluetooth and WiFi are calculated, and the effectiveness is measured using the wait age factor. Figure2 shows the standard prioritization of wireless technologies with the help of a radar graph, whereas Figure 3 shows various standards of wireless networks graphically.Figure 2
Prioritization of the standards of wireless technologies with a radar graph.Figure 3
Graphical representation of various standards of wireless networks.


### 3.2. Design and Fabrication of the Smart Office

The proposed model contains a microcontroller named Arduino Mega 2560 Rev3, which is the fundamental part of its working. This model performs real-time monitoring of the electrical appliances and sensors present in the office that can be remotely controlled. The experimental materials include various sensors, power supply, LCD, real-time clock, SD card, and MP3 player mounted on a cardboard. Figure4 illustrates the block diagram of the office system, which consists of Arduino, devices, sensors, smartphones, and so on.Figure 4
Block diagram of the proposed smart office.The design of the proposed prototype is developed using the Coohom tool. The prototype contains 3 offices, one waiting lounge, one storeroom, and a pantry. Figure5 shows the 2D and 3D layouts of smart office development.Figure 5
Design of a prototype using the Coohom tool. (a) Top view of 2D layout and (b) top view of 3D layout.
(a)(b)


### 3.3. Hardware Specifications

Many electronic appliances and sensors are used to design the current system. The component list and its description are shown in Table2.(i)
ACS712 current sensor is used to calculate AC as well as DC using the following equation:(1)Current=adcVoltage–offsetVoltagesensitivity.Here, ADC voltage = (analog read (current pin)/1024.0)∗ 5000 offset voltage = 2.5 volt sensitivity = 66 mV/A for a 30 A sensor or 100 mV/A for 20 A sensor or 185 mV/A for 5 A sensor.(ii)
DHT11 sensor is a basic and low-cost temperature and humidity sensor. DHT object returns the value of temperature in Celsius (°C) and converts it into Fahrenheit (°F) using equation (2), and relative humidity is calculated using equation (3).(2)T°F=T°C×95+32,(3)RelativeHumidity=watervapordensitywatervapordensityatsaturationx100%.(iii)
MQ-135 gas sensor calibration is calculated by locating the value of Ro in the fresh air, RL is 10 KΩ, and Rs through equation (4). Rs = (Vcc/(VRL − 1)) × (RL)(4)Rs=5VsensorValue∗5/1023−1∗RL.(iv)
A flame sensor is used to detect the presence of fire at a place.(v)
HC-SR04 ultrasonic sensor measures distance using equation.(5)Distance=TimexSpeedOfSound2.Table 2
Hardware components with specifications.
ComponentsSpecificationsArduino Mega 2560 Rev3Microcontroller based on the ATmega2560, 16 analog inputs, 54 digital input-output pins, 5 V operating voltage, 256 KB flash memory, 8 KB SRAM, 4 KB EEPROMACS712 current sensor66 to 185 mV/A output sensitivity, 2.1 kVRMS voltage isolation, 80 kHz bandwidthDHT11 temperature and humidity sensor4 pins, 3 V–5 V power and input-output, low cost, 2.5 mA max current, body size 15.5 mm × 12 mm × 5.5 mmMQ135 air quality sensorDetect a wide range of gases, high sensitivity, detection range of 10–300 ppm, heater voltage: 5.0 VHC-SR04 ultrasonic sensor5 V voltage, 15 mA current, 40 KHz frequency, 2 cm–450 cm rangeFlame sensorOperating voltage is 3.3 V to 5 V, and the detection angle is 600, LM393 comparator usedESP8266 WiFi module2.4 GHz WiFi, 17 GPIO pins, 10-bit ADC, 64 KB of ROM, and 96 KB of RAMSmartphone mobileAndroid supported


## 3.1. Overall System Architecture

The proposed architecture consists of Arduino, sensors, electrical appliances, and a smartphone application used in office automation. This system contains multiple electrical appliances such as AC, printer, TV, coffee machine, light, and CCTV, and digital sensors such as temperature and humidity, motion, air quality, and fire. The proposed office automation system comprises 4 modules: Arduino, Cloud, a smartphone application, electrical appliances, and sensors, as shown in Figure1. The arrows present in the figure illustrate data flow from one module to another.Figure 1
Proposed architecture of the office automation system.The current sensors added in electrical appliances and some other digital sensors present in the architecture send data to the Arduino IoT Cloud through WiFi based on the status of the pins where corresponding loads are to be active and in the appropriate range. The dataset is generated by the sensors present in the prototype which are collected on Arduino IoT Cloud through WiFi. The Internet connection through WiFi is used to observe, analyze, and predict the faults in appliances present in the office environment using the smartphone application. The sensors installed inside the office update their data continuously every 2 sec and respond to any change that occurs to the user via smartphone with the help of a machine learning algorithm.Many wireless technologies are present in the market, such as Bluetooth and WiFi. Bluetooth is basically used for short-range communication, whereas WiFi is used for data transfer over longer distances with high data rates. Table1 presents the comparison of Bluetooth and WiFi in detail.Table 1
Comparison of wireless technologies.
S. no.StandardBluetoothWiFi1RangeLow (10 m)High (100 m)2SecuritySecuredMore secured3Transmission rate1 MbpsUpto 54 Mbps4Latency200 ms150 ms5Bit rate2.1 Mbps600 Mbps6Time for network communication10 sec3 sec7Standby current200µA20µA8Number of nodes720–2509Nominal TX power0–10 dBm15–20 dBm10Channel bandwidth1 MHz20–25 MHz11ApplicationCable replacementData network and Internet monitoringDifferent parameters of Bluetooth and WiFi are calculated, and the effectiveness is measured using the wait age factor. Figure2 shows the standard prioritization of wireless technologies with the help of a radar graph, whereas Figure 3 shows various standards of wireless networks graphically.Figure 2
Prioritization of the standards of wireless technologies with a radar graph.Figure 3
Graphical representation of various standards of wireless networks.


## 3.2. Design and Fabrication of the Smart Office

The proposed model contains a microcontroller named Arduino Mega 2560 Rev3, which is the fundamental part of its working. This model performs real-time monitoring of the electrical appliances and sensors present in the office that can be remotely controlled. The experimental materials include various sensors, power supply, LCD, real-time clock, SD card, and MP3 player mounted on a cardboard. Figure4 illustrates the block diagram of the office system, which consists of Arduino, devices, sensors, smartphones, and so on.Figure 4
Block diagram of the proposed smart office.The design of the proposed prototype is developed using the Coohom tool. The prototype contains 3 offices, one waiting lounge, one storeroom, and a pantry. Figure5 shows the 2D and 3D layouts of smart office development.Figure 5
Design of a prototype using the Coohom tool. (a) Top view of 2D layout and (b) top view of 3D layout.
(a)(b)


## 3.3. Hardware Specifications

Many electronic appliances and sensors are used to design the current system. The component list and its description are shown in Table2.(i)
ACS712 current sensor is used to calculate AC as well as DC using the following equation:(1)Current=adcVoltage–offsetVoltagesensitivity.Here, ADC voltage = (analog read (current pin)/1024.0)∗ 5000 offset voltage = 2.5 volt sensitivity = 66 mV/A for a 30 A sensor or 100 mV/A for 20 A sensor or 185 mV/A for 5 A sensor.(ii)
DHT11 sensor is a basic and low-cost temperature and humidity sensor. DHT object returns the value of temperature in Celsius (°C) and converts it into Fahrenheit (°F) using equation (2), and relative humidity is calculated using equation (3).(2)T°F=T°C×95+32,(3)RelativeHumidity=watervapordensitywatervapordensityatsaturationx100%.(iii)
MQ-135 gas sensor calibration is calculated by locating the value of Ro in the fresh air, RL is 10 KΩ, and Rs through equation (4). Rs = (Vcc/(VRL − 1)) × (RL)(4)Rs=5VsensorValue∗5/1023−1∗RL.(iv)
A flame sensor is used to detect the presence of fire at a place.(v)
HC-SR04 ultrasonic sensor measures distance using equation.(5)Distance=TimexSpeedOfSound2.Table 2
Hardware components with specifications.
ComponentsSpecificationsArduino Mega 2560 Rev3Microcontroller based on the ATmega2560, 16 analog inputs, 54 digital input-output pins, 5 V operating voltage, 256 KB flash memory, 8 KB SRAM, 4 KB EEPROMACS712 current sensor66 to 185 mV/A output sensitivity, 2.1 kVRMS voltage isolation, 80 kHz bandwidthDHT11 temperature and humidity sensor4 pins, 3 V–5 V power and input-output, low cost, 2.5 mA max current, body size 15.5 mm × 12 mm × 5.5 mmMQ135 air quality sensorDetect a wide range of gases, high sensitivity, detection range of 10–300 ppm, heater voltage: 5.0 VHC-SR04 ultrasonic sensor5 V voltage, 15 mA current, 40 KHz frequency, 2 cm–450 cm rangeFlame sensorOperating voltage is 3.3 V to 5 V, and the detection angle is 600, LM393 comparator usedESP8266 WiFi module2.4 GHz WiFi, 17 GPIO pins, 10-bit ADC, 64 KB of ROM, and 96 KB of RAMSmartphone mobileAndroid supported


## 4. Working Methodology

Arduino and Arduino IoT cloud database servers are the two primary elements of the proposed system that monitors the data received by devices and sensors. The user can monitor the correct working of devices present in the office using the smartphone application.Figure6 represents the architecture of the proposed methodology, and it is divided into two steps. The first step is to calculate the fault prediction, get data from the devices, and save it into the cloud database. This step contains devices, sensors, Arduino, server prediction algorithm, and cloud database. The data of devices and sensors are captured using sensors connected to Arduino. Now, Arduino is responsible for sending the data to the server through a WiFi module with the help of APIs or server endpoints encoded with embedded C in the circuit. After receiving data from the server, it sends the data to the fault prediction model, which identifies the fault in devices, responds to the user with an appropriate solution, and stores corresponding data in the cloud database. Then, the second step is to display that data on the smartphone. The server sends data from the cloud database to the smartphone in a graphical manner. If some fault occurs within the values of the database, it will be seen in the form of notifications on the smartphone.Figure 6
Architecture of the proposed methodology.The flowchart of system operation is shown in Figure7. First, we initialize all devices and sensors with the help of particular device switches. Then, we collect all of the data with the help of Arduino, which further sends the data to the server via a WiFi module. Once the server saves the data, now it sends the data to the fault prediction model to check and predict the faults. If the fault is identified, then solutions will be recommended and saved to the cloud database. If there is no fault, the data are saved to the database again. At last, data are taken from the cloud database and sent to the smartphone to display on the smartphone application.Figure 7
Flowchart of system operation.


## 5. Implementation

This paper describes implementing the proposed fault prediction system for office employees to monitor the electric appliances and sensors and save energy automatically. This model is better than other existing models because(i)
The office is unit-wise monitored instead of the whole office space at once(ii)
This model is economical and cost-efficient as an Arduino Mega 2560 Rev3 microcontroller is deployed(iii)
The time and status of sensors are shown on a 16 × 2 LCD(iv)
The WiFi module sends an alert notification regarding the solution recommendation of fault predicted on the user’s smartphoneFigure8 shows the circuit diagram of the smart office that monitors the appliances and sensors present in the office by checking their status of working.Figure 8
Circuit diagram of the proposed design.The prototype is prepared using the board and joined by glue as per the layout, as shown in Figure9(a). After completing the design of the prototype, the model is populated with electrical appliances, sensors, and furniture, as shown in Figure 9(b). Figure 9(c) displays the final prototype with all its sensors and devices. Figure 9(d) represents the final working prototype of the smart office. The cost of the prototype build lies between INR 28 k and 30 k. The main entrance door is opened and closed using a sliding motion. The motion sensor present on the door detects the motion of a person.Figure 9
Implementation of a smart office prototype. (a) Front view of the initial design. (b) Top view of design. (c) Final prototype with all devices and sensors. (d) Working prototype of the smart office.
(a)(b)(c)(d)The algorithm for monitoring smart office and fault prediction based on IoT is proposed and shown in Algorithm1.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 rounddo(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 solutionsCase 1 (ACS712)(a)
If (FA)//fault in ACNotify user via notification “repair or replace AC.”break;(b)
If (FC)//fault in coffeeNotify user via notification “repair or replace coffee machine.”break;(c)
If (FCC)//fault in CCTVNotify user via notification “repair or replace CCTV.”break;(d)
If (FT)//fault in TVNotify user via notification “repair or replace TV.”break;(e)
If (FL)//fault in LightNotify user via notification “repair or replace light.”break;(f)
If (FP)//fault in printerNotify 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 forOutput: Working status of each and every device and sensor.


## 6. Results

A sensor fault prediction model based on a machine learning (ML) algorithm is proposed in this paper. The fault prediction block is implemented in the sensor to achieve immediate output after collecting data. A total of 1300013 records are used, of which 910009 records are used for training and 390003 records for testing. There are many ML methods, but amongst all, K-nearest neighbor and naive Bayes are best suited for classifying records as fault-prone and nonfault-prone. Some other models such as support vector machine (SVM) and decision trees (DT) are not fit for the proposed work as the SVM requires a large training time and memory space for storing support vectors of large datasets and DT are not suitable for predicting continuous characteristic values. K-nearest neighbors (kNN) and naive Bayes (NB) are supervised machine learning techniques where labeled data are used. KNN predicts on the basis of a specified number (k) of the nearest neighboring data points [34]. The value of k should be carefully selected as a high value than optimal influences prediction accuracy and a lower value leads to bias. The NB algorithm is based on Bayes’ theorem which calculates conditional probability on the basis of prior knowledge and assumes that each pair of feature is independent of one another. The performance of the two adopted algorithms is evaluated by a confusion matrix as depicted in Figure 10 for kNN and NB, respectively.Figure 10
Confusion matrix for kNN and NB, respectively.The receiver-operating characteristic (ROC) curve is a commonly used graph for exhibiting the performance of the classification model for all of its thresholds. Two parameters are plotted by this curve, namely, false-positive rate and true-positive rate. The ROC curve of kNN and NB is plotted in Figure11.Figure 11
ROC curve for kNN and NB, respectively.Different metrics are used to analyze the performance of ML models, as represented in the following equations. Equations (6) and (7) represent specificity and sensitivity, respectively. Accuracy, F1-score, precision, and recall are represented in equations (8)–(11). The area under the ROC curve (AUC) calculates the whole 2-dimensional area under the ROC curve. It has two parameters, namely, true-positive rate, which is the recall and false-positive rate defined in equation (12).(6)Specificity=TrueNegativeTrueNegative+FalsePositive,(7)Sensitivity=TruePositiveTruePositive+FalseNegative,(8)Accuracy=TrueNegative+TruePositiveTruePossitive+FalsePositive+TrueNegative+FalseNegative,(9)F1−score=2TruePositive2TruePositive+FalsePositive+FalseNegative,(10)Precision=TruePositiveTruePositive+FalseNegative,(11)Recall=TruePositiveTruePositive+FalseNegative,(12)FalsePositiveRate=FalsePositiveFalsePositive+TrueNegative.The precision-recall curve (or PR Curve) is a curve that incorporates recall and precision in a single visualization. In other terms, a PR curve possesses TP/(FP + TP) on thex-axis and TP/(FN + TP) on the y-axis. Two parameters are plotted by this curve, namely, positive predictive value and true positive rate. The PR curve of kNN and NB for four cases, namely, off, fine, repair, and replace are plotted in Figure 12.Figure 12
PR curve for kNN and NB, respectively, for four cases.The comparison between the time complexity for training different ML classifiers to fit data is shown in Figure13. The time taken by kNN (2.94 sec) and NB (1.02 sec) is comparatively very less as compared to SVM (253 sec) and DT (3.87 sec). The time complexity of kNN and NB is compared with SVM and DT, and due to this only, kNN and NB are chosen over the other two. The performance of the two models, i.e., kNN and NB, are analyzed in terms of specificity, sensitivity, accuracy, F1-score, precision, recall, and AUC, and NB is considered the best out of the two. Figure 14 depicts the comparison of the performances of kNN and NB. The kNN model performs better than the NB model. The kNN yielded the highest recall, specificity, and F1-score values at 0.996, 0.995, and 0.995, respectively. KNN also outperformed NB in terms of accuracy: 99.6% with a test size of 0.3, whereas NB achieved only 92.3% accuracy with the same dataset.Figure 13
Time complexity of different ML classifiers.Figure 14
Performance parameters of kNN and NB.


## 7. Conclusion and Future Scope

This paper presents the design, fabrication, and implementation of a low-cost and user-friendly smart office. The proposed methodology can be easily implemented in a real office that monitors the conditions of the office in real time. An interactive GUI-based smartphone application is developed to monitor the appliances and sensors available in the smart office. The appliances and sensors are connected to Arduino, which updates the data to a cloud server. The data fetched from several devices (AC, TV, printer, and so on) and sensors (temperature, humidity, fire, motion, and so on) are monitored via a smartphone application and server for fault prediction using a machine learning algorithm. KNN and NB techniques were applied to the dataset, and kNN performed better in terms of accuracy, recall, specificity, andF1-score. KNN scored 99.63% accuracy, whereas NB has only 92.3%. Also, the specificity is 0.99 for kNN and 0.83 for NB. So, the performance of kNN is better than NB. The limitations of the proposed model are that the data security of IoT devices on the cloud is not considered. The user gets a notification on their smartphone about any abnormal condition of the device or sensor present in the office. The proposed system increases the safety and comfort of users by informing them regarding early fault occurrence. In the future, solar panels can be used to power the control system instead of batteries so that the proposed system can be environment-friendly and energy-efficient. Also, intruder detection information can be directly forwarded to the police station and fire information to the fire station.



---

*Source: 9991029-2023-03-13.xml*