Real Time LDR Data Prediction using IoT and Deep Learning Algorithm

- This paper outfits artificial intelligence based real time LDR data which is implemented in various applications like indoor lightning, and places where enormous amount of heat is produced, agriculture to increase the crop yield, Solar plant for solar irradiance Tracking. For forecasting the LDR information. The system uses a sensor that can measure the light intensity by means of LDR. The data acquired from sensors are posted in an Adafruit cloud for every two seconds time interval using Node MCU ESP8266 module. The data is also presented on adafruit dashboard for observing sensor variables. A Long short-term memory is used for setting up the deep learning. LSTM module uses the recorded historical data from adafruit cloud which is paired with Node MCU in order to obtain the real-time long-term time series sensor variables that is measured in terms of light intensity. Data is extracted from the cloud for processing the data analytics later the deep learning model is implemented in order to predict future light intensity values.


Introduction
In the digital era, the technology has drastic development in information and communication mainly focused on the Internet of Things (IoT) [1]. In the real-world development, IoT enabled services advance the commercial and industry atmosphere. The IoT based automation is more popular and all electrical machines are interacted collectively which are able to monitor the operating condition without human involvement. IoT with artificial intelligence which enables us a smart monitoring along with the preventive and predictive analysis and to control such as refrigerator, TV, water tank, geyser and etc., using various sensors [2]. Especially the light control is crucial task. The proposed system customs Wi-Fi module and the sensor module to observe the illumination in the light system.
The real time operation about the device needs to be monitored in the globe either for easy access or security purpose. The information about the device's operations are send to the cloud via WIFI module with the support of Node MCU ESP8266 and router [3].
Adafruit cloud is used and cloud receives data in every 2 minutes once. The user can view the data in the Adafruit dash board and also authenticated to the public to view the operating condition of the connected devices [4]. All the sensors are almost having same configurations and suggested this work to monitor continuous data in any process by incorporating various sensors. The working model is developed as a prototype.

Methodology
The entire process of cloud-based data monitoring and control the process gets started by searching the connectivity process will check for the authentication of the connected device, if the device is authenticated then main is turned ON else it will wait until an authenticated device gets connected which is describes in below Figure 1. After the initialization of Wi-Fi, the it will be paired with adafruit cloud.
The LDR sensor which is connected with the NODE MCU module will measure the sensor data using ESP8266 which is an WIFI module as shown in Figure 1 and the data is send to the adafruit cloud for monitoring and controlling the gadgets also the data can be subscribed in adafruit IO dashboard. Cloud data which includes the live status of the device and live sensor value changes for every second, can be shared to other users by changing the user control from private to public so that, a user can monitor the gadgets from anywhere [5]. User can turn OFF the device by click the OFF button so the load goes to OFF state. If the lux level is more that can affect surrounding with heat dissipation so the user needs to turn off the device so the control goes back in search of device. If the lux level is sufficient under control then main can be turned OFF via an html page, checking for main ON or OFF state, the flow is directed to select the devices else if the main is OFF the process stops.

LSTM Algorithm
Long short-term memory was created as a solution to loss of gradient or learning rate as RNN suffered a vanishing gradient problem in which gradient is the value used to update the neural network weight by the given expressions. LSTM algorithm architecture is shown in Figure 2 The gradient vanishing stops the learning process in neural network and leads RNN to forget values in long sequences and thus having loss of gradient problem. As shown in Figure 3, LSTM has interior mechanism that world controls the stream of data and forget and output gate will acquire the information about the particular information in the arrangement which is essential and in order to decide the data is important or not.
The module learns to utilize relevant information in order to make accurate predictions. Long short-term memory algorithm is commonly used in speech recognition models, test generation and in many more applications. Categorization of vectors are processed individually and the information that is send along with the preceding variable to subsequent stage of the system. In an output state to access to network memory it holds data on preceding state, response and preceding output variables is shared in a module that particular module has data on the present contribution and the preceding state.

Fig 3: LSTM Architecture
Activation function is applied to benefit and to standardize the variables flowing over the system, it ranges values between -1 to 1 as it is a bipolar activation function. When vector following through the NN experiences numerous transformations owing to numerous mathematical procedures [6]. Tanh function regulates network output. LSTM would process the data sequentially transferring on the data as it disseminates the data flow, the module will decide whether to forget or to keep the information. The module has three gates input gate, output gate and forget gate along with the cell. Cell state performances a conveyance freeway that allocations the comparative data to the classification pipeline.
Cell can transmit the data through the sequence of system the information either included or excluded to upcoming state through this process, it contains sigmoidal activation function and the sigmoidal activation squashes value between 0 and 1 as it is a binary activation function which helps to forget data because the network can learn to keep the data or forget the data.

Prediction Using Deep Learning
Prediction includes various stages of processing as shown in the Figure 4. That includes pre-processing, data visualization, Algorithm modelling, splitting the data set into training and testing.

Fig 4: Various stages of processing
Pre-processing Pandas are used for data wrangling which is used to check for duplicate data values present in each column. Pandas library ensures there is no missing values per column and if duplication is found it is either filled or dropped. Data imported in CSV (Common delimited) the data is displayed in columns and rows [7].
The head () and tail () function are used to display the data in top and bottom of the data set, describe () function is used to find the data match up with the source data. Missing values can be found using. [11][12][13] isna() function. Feature selection the required column is dropped out using dropna function.

Data visualization
Data visualization is to understand data set and their correlation between each other, data visualization can be done using matplotlib as shown in Figure 5, pandas visualization, seaborn, ggplot, plotly. Matplot library is specially used to create graphs like histogram, boxplot.

Fig. 5: Visualization using scatter plot
Prediction modelling Prediction modelling involves two modelling algorithms LSTM algorithm. Linear regression modelling in which data is spitted for training the date set and for validating the model using the test data sets, the time is to train our algorithm. In order to model algorithm, the required library is imported, import LSTM module for processing, and define the fit () function laterally with the real time input data. Long shortterm memory is implemented to predict the forth coming values [8].
The model is essential to identify the predictable variables of the LDR analog data. In expressions of various epochs and structures. The output structure is a completely linked with NN for the potential numbers that provides an accurate prediction in the output side. Accurate model is to be created which can be validated by means difference between the training and testing variables [9].

Splitting training and testing
Data set is filtered as to make it convenient for processing, the data set are spitted into 75% for training and 25% for testing. Prediction model is built long short-term memory algorithms to predict upcoming 48 data. The necessary libraries are imported, statistical detail like shape and size of the date is viewed [10].

Prediction Results
The results of the upcoming LDR values are predicted as show in Figure 6. The actual and predicted values are plotted in Figure 7.  = where y j and y^j is the actual and predicted wind speed respectively. Obtained MAE value in LSTM model is 0.266.

Conclusion
The proposed work predicted data sets form the cloud the light intensity is been predicted using long short-term memory which is a deep learning algorithm mainly whose performance is validated using the mean absolute error. The obtained mean absolute error for the model is 0.266. Future exploration will emphasis on the accumulation of more features to escalation the system trustworthiness in an unconfined situation.