CoT-Enabled Robust Surveillance System using Fog Machine Learning

Surveillance system is a method of securing resources and loss of lives against re, gas leakage, intruder, earthquake, and weather. In today’s time, people own home, farm, factory, oce etc. It has become more crucial to monitor everything for securing resources and loss of lives against re, gas leakage, intruder, earthquake. As a part of surveillance, monitoring weather is also essential. Climate change and agriculture are interrelated processes, Today's sophisticated commercial farming like weather monitoring, suffers from a lack of precision, which results huge loss in farm. Monitoring residential and commercial arenas throughout is an ecient technique to decrease personal and property losses due to re, gas leakage, earthquake catastrophes. Internet of Things make it possible and can be implemented separately for each thing or site. But it is very dicult to monitor each site and have centralized access of it across the world. This arises the need of heterogenous system which will monitor all IoTs and perform decision making accordingly. IoT itself a large-scale thing. For single IoT application, sensors used are more in number. These sensors generate thousands of records for an instance of time, some of those are valuable and some requires just analysis. This huge amount of data on servers requires better data processing and analytics. Maintenance is also a critical task. Cloud extends these functionalities but storing all the data on cloud entail users to pay tremendous cost to the cloud service providers. This problem is catered by “CoTsurF” framework. This paper presents novel and cost effective “CoTsurF” framework, CoT-enabled robust Surveillance system using fog machine learning, a Proof-Of-Concept implementation of heterogenous and robust surveillance system based on internet of things and cloud computing by leveraging a groundbreaking concept of Fog machine learning that is Fog Computing and machine learning in Cloud of Things.


I. Introduction
WITH the rapid development of internet and wireless technology, Wireless Sensor Networks (WSN) and Internet of Things (IoT) along with cloud computing generated an ampli ed interest in research perspectives. Today, world is surrounded by the sensors. We can nd sensors everywhere in smart phones, in vehicles, in factories, even in the ground monitoring soil conditions and lot more. A typical WSN is formed by large number of tiny devices which are termed as motes or nodes. Each node comprises embedded Central Processing Unit (CPU), limited computational power and some smart sensors. Nodes uses sensors to monitor surrounding environmental factors such as temperature, vibration, humidity, re, pressure. Typically, a WSN node comprises computing unit, power unit, transceiver unit and sensor interface. By the means of these units, each node can be able to communicate with other nodes to transmit data attained by their respective sensors. Communication among the nodes necessarily requires having a centralized system. The necessity of this system leads to development of the notion of internet of things (IoT). With the notion of IoT, immediate access to environmental data becomes feasible. So that in numerous processes, e ciency and productivity increases dramatically [1].

A. Internet of Things
In todays' era of internet, Internet of Things (IoT) is not at all a buzzword, it is the next big thing after the introduction of Internet itself. IoT is extremely proli c as bringing up new devices in Tech market. It is the interconnection of physical devices, home appliances, vehicles etc. with software, network connectivity, sensors etc. embedded in it that enables the objects to connect and exchange data. In IoT, "Things" refer to an extensive variety of devices such as connected cars, wearables, heart implants, farming etc. and "I" in IoT equivalently means "Intelligence" that is providing smartness to the devices. These devices gather valuable data and then data is own autonomously among other devices. Considerable amount of research has been carried out in this eld. IoT is expanding at a signi cant rate and producing huge amount of data, hence it has become essential to combine IoT with cloud. The use of internet has grown at a tremendous rate as compared to the past. The entire internet tra c used in 2008 is equivalent to the amount of internet tra c generated by 20 households in 2012 [1].
Millions of smart devices are connected to each other and share loads of data with each other through internet. IoT has revolutionized the technology and enhanced the future of connectivity and reachability.
From a smart device to a leaf of a tree or a bottle of beverage, anything can be part of Internet. The objects become communicating nodes over the Internet, through data communication means, primarily through Radio Frequency Identi cation (RFID) tags. Smart objects are the digital objects that performs some tasks for humans and environment to make human life easy. These objects play an important role in IoT. Therefore, IOT not only contains hardware or software paradigm but also involves social aspects also [4]. Network operators can provide services to the manufacturers, vendors, and end user to generate more revenue using IoT.
IoT works on the concept of M2M i.e., Machine to Machine interaction without human interruption, but it is not limited to it. Also, IoT involves non-connected things communicating by the means of devices like ZigBee, 6LowPan, RFID tag, Bluetooth, bar-code, or an RFID tags etc. In IoT, devices which do not have intelligence becomes the communicating nodes. [5] Figure 1 depicts large number of devices like smart homes, smart phones, smart vehicles that are bonded with Internet of Things.

B. Cloud Computing
Cloud computing, the hot bias in IT, which abstracts away the IT complexities and taken computing world to top level, where user need not to worry about maintenance and managing all the resources. Now the Internet is devoted to access content-based IT resources made available by the World Wide Web. On the Other hand, Cloud environments provide IT resources which are capable to provide back-end processing capabilities and user-based access to these capabilities. The only fact user needs to accept the cost of usage of services or resources, which is called pay-as-you-use in cloud computing terms. With the cloud computing, one can interface to huge data centers with even smart phones. Cloud computing is extended form of distributed computing, grid computing and parallel computing. Without bothering large computing and storage devices, cloud computing provides universal access to the content. Cloud computing is emerged recently and grown up like anything and will become more and more ubiquitous in future. Adoption of cloud computing is getting upward rapidly.
Per user's requirement and affordability, cloud computing platform provides highly scalable, manageable, and schedulable virtual servers, storage, computing power, virtual networks, and network bandwidth. [3]. Since data management and processing is one of vital characteristics of cloud computing, it is conceivable to store, manage, and share huge amounts of data. Cloud computing is a convenient solution for processing content in distributed environments.

C. Machine Learning
Machine learning is a sub-eld of arti cial intelligence that gives the computer the ability to learn without being explicitly programmed [12]. Using machine learning, Intelligence is given to machines by which machines can learn from past experiences. Different machine learning algorithms are used to take accurate decisions.
In this paper, we present the survey of Internet of things and Cloud of Things. Rest of the paper is organized in such a way that section II presents the integration of Internet of Things (IoT) and cloud computing, which we term as Cloud of Things and its need. Section III presents method for CoT -enabled robust surveillance system based on Fog machine learning. Section IV presents results and analysis of CoTsurF system. We conclude this paper in section V.

Ii. Cloud Of Things
World is moving towards the web3, an abundant computing web. Since 2012, due to the rapid technological growth, it has been estimated that the number of connected devices to the internet has already surpassed the number of human beings on the Earth. Already, connected devices have reached 9 billion and according to estimations, approximately 54 billion devices having distinct IP address are expected to connect by 2020 [10]. As exponential growth in connected devices will generate lots of data, it is not possible to store this data locally and temporarily. This results to requirement of rental storage space and proper utilization of huge amount of data. Processing of data must not only form the information but moving further it should form a knowledge. This needs more processing and IoT, have low cost and light weight devices, enough is de cient to handle it. Again, processing and computation must also be available there on rental basis. Cloud computing offers a more attractive alternative which makes it possible for the things (devices) even with limited processing and computational pro ciencies, perform complex computations and processing of data. The devices require to have only sensors and actuators and cloud facilitates decision making capabilities. IoT and cloud computing working in integration makes a new paradigm, termed as Cloud of Things (CoT) [11], [12].
The Cloud facilitates more elegant features and bene ts that out ts for IoT. For example: The key feature of cloud is "scale as you go." That means, you can start deployment with a low-cost, low-capacity and then easily upward to more capacity, powerful devices (server, other hardware etc.) when your solution grows. This is like how you pay for your domestic utilities in day-to-day life per your use.
IoT devices are mounted and located at different places. These devices are needed to connect to the servers from variety of places. Clouds are accessible at anytime and anywhere on the Internet.
High Speed and quality of services are provided by the cloud service providers to streamline the process.
IoT data can be utilized by different tools for data mining, analytics and moving further for decision making, once it is on cloud.
Both Internet of Things and Cloud of Things has interdependent characteristics. These are listed in Table  1. there is a need to monitor everything like home, Farm, O ce and securing resources and loss of lives against re, gas leakage, intruder, earthquake is becoming more crucial.
Climate change and agriculture are interrelated processes, Today's sophisticated commercial farming like weather monitoring, suffers from a lack of precision results huge loss in farm.
Monitoring residential and commercial arenas throughout is an e cient technique to decrease personal and property losses due to re, gas leakage, earthquake catastrophes. Internet of Things make it possible and can be implemented for separately for each thing or site for example home, farm, o ce etc. But It is very di cult to monitor every site or thing and taking control of it from single point of contact. This arises the need of heterogenous system which will monitor all IoTs and perform decision making accordingly.
IoT itself a large-scale thing. For single IoT application, sensors used are more in number. These sensors generate thousands of records for an instance of time, some of those are valuable and some requires just analysis. This huge amount of data on servers requires better data processing and analytics. Maintenance is also a critical task. Cloud extends these functionalities but storing all the data on cloud entail users to pay tremendous cost to the cloud service providers. This problem is catered by "CoTsurF" framework, proof-of-concept implementation, by leveraging a groundbreaking concept of Fog Computing in Cloud of Things.
As shown in Fig. 4 IoT sites. Fog agents contain application logic which extends the task of data processing from cloud computing. Fog agents monitors all the servers and keeps itself asynchronously updated with cloud to exchange data values. Threshold for every sensor is set by fog agent in application logic. Once the sensor values cross this frequency, noti cation will be sent to the raspberry pi for activating alarms and immediately values will be pushed on the cloud.

c. Cloud layer
The cloud Layer includes a remote Cloud platform that performs all those tasks that fog agents cannot execute. The activities cloud performs tasks requiring high computational resources or long-term historical data. Cloud executes data analytics that can be utilized for different purposes, including: to notify users regarding the event, to improve the Agents' operations and their behavior, Decision making etc. Data collected on cloud can be utilized to support the demands of external applications. e.g.
collected data from factory can be used by energy service companies for reliable forecasting.
As shown in Fig. 5. CoTsurF system has SW-420, KY-026, PIR Motion, MQ-2 and DHT22 sensors are deployed at IoT Layer. Modules implemented with these sensors are Gas Leakage Detection, Fire Detection, Theft Detection, Earthquake Detection and Rainfall Prediction, respectively. Data generated from these sensors are stored in Fog middleware. Fog Middleware contains Wamp Server to store these data. When fog agent detects critical event or the sensor value crosses the threshold, it sends email noti cation to user. This event is logged on cloud. This system uses Gmail for email noti cation and ThingSpeak cloud for analysis of data.
Below modules are implemented in CoTsurF System.

Module 1: Gas leakage detection
The dangerous gases are very injurious to human life as they may cause explosions and poisoning. It is surely conceivable that the gases may leak, so the system may need to be monitored continuously to prevent any disaster happen. Thus, Gas detection module is invented to detect the presence of those harmful gases within an area.

Module 2: Theft Detection
Theft detection module is designed to detect intruder inside home, o ce, factory etc.

Module 3: Fire Detection
Fire detection module is designed to detect re and ensure safety of lives present in the house, o ce, company, or factory wherever this module is implemented. As Fire is an undesirable event that needs to be handled as early as possible to save great loss of lives.

Module 4: Earthquake detection
Earthquake detection module is designed to detect earthquake. This module helps to monitor residential and commercial arenas in earthquake prone zone to avoid great losses.

Module 5: Rainfall Prediction:
The management of weather and climate risks in agriculture are turned into an important issue due to climate change. Rainfall is a random event, and the cause of its occurrence is very complex. Even under the same weather conditions, it may be possible that it will rain at this moment but not at another moment. Rainfall prediction can help develop reduce losses and risk. Also, it will be useful for sustainable and economically viable agricultural systems, improve production and quality, decrease costs, increase e ciency in the use of water, labor and energy, conserve natural resources, and decrease pollution by decreasing use of agricultural chemicals or other agents that contribute to the degradation of the environment.
The proposed system uses Random Forest classi er to predict rain and avoid great losses.
Rainfall prediction in this system is implemented as 1. Building a Model -Machine learning technique.
2. Predict rainfall -Input data from IoT 1. Building a Machine Learning model: Below libraries are required to implement machine learning model: 1. datetime-datetime is a standard library used for date and time.
2. collections-collection is a standard library used for structured collection of data 3. pandas -pandas is a third-party library used to process, organize and clean the data 4. requests request is a third-party library used to make networked requests to the API .
5. matplotlib -matplotlib is a third-party library used for graphical analysis 6. plotly -to plot samples on graph. 7. Scikit-learn-A Scikit-learn is a third-party machine learning library for Python. It provides machine learning algorithms classi cation, regression and clustering algorithms including support vector machines, random forests, gradient boosting, k-means and DBSCAN, and is designed to interoperate with the Python numerical and scienti c libraries NumPy and SciPy.
In proposed system uses random forest classi er to predict rainfall. Figure 6 shows Rainfall Prediction Process ow.
Below steps are carried out to build model:

Data Collection
Weather Underground is a company that collects and distributes data on various weather measurements around the globe. To predict rain, data is collected from Wundergrounds API, provides hourly weather data in JSON format. After knowledge discovery process, it has been found that data has poor quality. For this reason, data is carefully cleaned to get accurate and correct results. For this prediction model, we used rainfall data from January 2016 to December 2016.

Normalize and Preprocess data
This step builds consistent data model by normalizing and preprocessing raw data collected in rst step. stage, Data transformation is applied in order to nd missing data, nd duplicated data, and truncating poor data. Finally, raw data becomes structured and machine learning algorithms can be applied to predict accurate results. The raw rainfall dataset was having 23 measured parameters. Out of these 23 features we have used 5 features. We ignored less relevant features in the dataset for model computation.
After cleaning the raw data, dataset contains ve columns: Step 3. Visualize and classify samples in labels: Plotted Blue: Rain Plotted Red: No Rain Step 4. Divide data into training and testing set.
Training set = 75% of data Testing set = 25% of data Step 5. Create a random forest Classi er and train the Classi er to take the training features and learn on it.
Step 6. Calculate accuracy score and confusion matrix.
This is how rainfall prediction model is built and used to predict rain based on the sensor values.

Predict rainfall using IoT generated data
To predict rainfall, pass temperature and humidity sensor values as a input to the model. Temperature and Humidity is captured by the DHT22 Digital Humidity and Temperature sensor. Once model predicts rain, email noti cation is sent to the user.
The algorithm for heterogeneous smart surveillance system is shown below in Algorithm 1. Iv. Results And Analysis Figure 9 shows the completed hardware setup for CoT -Enabled robust surveillance system which has been integrated with Raspberry Pi All sensors are connected to Raspberry Pi using GPIO pins as shown in the Fig. 4 for monitoring purposes. Once sensor detects critical event, it light ups the LED and issues the alert by starting the buzzer. Output of the sensor is passed on to the raspberry pi. Raspberry pi stores the data on Fog agents as well as on cloud and immediately sends noti cation to the user regarding the event.

Gas Leakage Detection
Below dashboard shows analysis of gas leakage data on ThingSpeak cloud. Result is plotted on this dashboard with Gas value and time.
Mail will be sent automatically once gas leakage gets detected.

Theft Detection
Below dashboard shows analysis of theft detection data on ThingSpeak cloud. Result is plotted on this dashboard with theft value and time.
Mail will be sent automatically once theft gets detected.

Fire detection
Below dashboard shows analysis of re detection data on ThingSpeak cloud. Result is plotted on this dashboard with re value and time.
Mail will be sent automatically once re gets detected.

Earthquake detection
Below dashboard shows analysis of earthquake detection data on ThingSpeak cloud. Result is plotted on this dashboard with earthquake value and time.
Mail will be sent automatically once earthquake gets detected.

Rainfall Prediction:
Below dashboard shows analysis of rainfall prediction data on ThingSpeak cloud. Result is plotted on this dashboard with rainfall prediction result value and time.
Mail will be sent automatically once rainfall predicted.

V. Conclusion
The paper presents CoT-enabled robust servielliance system using fog machin learning is implemented using CoTsurF framework. Most of the existing IoT systems are using clouds which are slow in latency as well as quite expensive as IoT generated data is huge and requires huge storage to store it, in this work we have proposed a novel architecture CoTsurF which is implemented using groundbreaking concept of fog computing.
The proposed CoTsurF system is generic and deployed at home, o ce, farm and factory etc. which provides centralized access to user. The proposed CoTsurF system can alert the user ragrding the events: Theft detection, Fire Detection, Earthquake detection, Gas leakge detection. As a part of survilliance, this system also uses machine learning to monitor the environment conditions of rainfall and reduces the great losses in farm due to rainfall. This system sends email noti cation to user regarding the event so that user can get know regardig the event irrespective of his location anywhere across the world.
As discussed in results, the CoTsurF system also offers real time realization and analysis of data present on cloud which can be used across the world.

Declarations -Ethical Approval and Consent to participate
Not applicable -Consent for publication All the authors of this paper have shown their Participation voluntarily.
-Availability of supporting data  Alert -Earthquake Detection Noti cation Figure 18 Dashboard -Rainfall Prediction