A Novel IoT Switching Model Based on Cloud-Centric RTDBS

INTRODUCTION: Over the past decade, a significant rise in the number of internet-connected devices was observed. The number of smart devices is continuously increasing. The expanding network of interconnected devices provided an impetus for rapid advancement in the domain of Internet-of-Things (IoT). IoT has recently become a centre of attraction for research community. The development of microprocessors and microcontrollers has supplemented advancement in IoT paradigm. The rapidly emerging paradigm of IoT is facing challenges which render significant impact on its performance and cost. OBJECTIVES: In this paper, a novel architecture based on Real-Time Database System (RTDBS) coupled with cloud functionalities is proposed for providing efficient and cost-effective IoT system. An efficient circuit design consisting of solid state technology has also been integrated with the proposed architecture for enhancing the feasibility of the model. METHODS: The proposed model leverages cloud-hosted RTDBS for developing IoT system. After an inspective analysis, the most appropriate RTDBS was selected. In this model, a User Interface (UI) is coupled with the selected RTDBS. The same RTDBS is connected with ESP8266 which is directly attached with switching circuit based on a proposed design. The UI is also retrofitted with the functionality of recognizing speech in both English and Urdu. After speech recognition, corresponding command is sent to RTDBS and RTDBS updates the relevant instance. The modification of state generates a signal that is sent to ESP8266, and ESP8266 triggers the switching circuit according the signal received from RTDBS. RESULTS: The proposed IoT system was implemented and tested for continuous switching transactions and it purported to be highly tolerant against the threat of malfunctioning which arises due to continuous switching operations. The implemented IoT system was subjected to voice commands both in English and Urdu, and it exhibited the quick responses. CONCLUSION: The results obtained from the scrutiny of implementation endorse the efficiency of proposed model.


Introduction
The world is getting revolutionized by the wave of fourth industrial revolution. The expeditiously escalating impact of Internet-of-Things (IoT) has substantially affected the world by implementing the technology of automation while making it more feasible as compared to the prior techniques. The industrial sector already relies on robotics for manufacturing and production processes. The domestic sector has also been started being influenced by the wave of automation. Smart home is one of the most useful applications of IoT [12]. The emergent domain of IoT is suffering from the threat of cyberattacks, yet its viability outweighs the security risks [18].
The applications of IoT mostly rely on real-time processing. Performing the task of real-time processing Sheikh Muhammad Farjad 2 certainly requires real-time data, and the job of storing and managing real-time data is executed by real-time database system. Real-time database system makes the complex operation of real-time processing feasible, and it reduces the amount of delay which may often occurs during processing the real-time data by using conventional technologies. This paper proposes how a real-time database coupled with cloud service can be exploited efficiently for designing the cost-effective and secure smart switches by integrating user-friendly interface which can be accessed securely from any location in the world. The practical implementation of this idea is also demonstrated in the paper along with the scope of the system. This must be clear that electric switching is not limited to conventional switch boards. This refers to any electrical circuit which is used for switching ON/OFF. This switch predicated on proposed model can be operated independently or this can be retrofitted with any appliance also. Firebase Realtime Database is used for demonstration along with NodeMCU ESP8266.

Real-time Database System
Most of the systems existing today are real-time systems which are characterized by timing constraint or the predictability of execution time. Real-time systems generate huge amount of real-time information which is required to be stored and retrieved in an efficient way. Conventional database systems fail to store and manage such huge amount of real-time data. Real-time Database System (RTDBS) integrate real-time systems with database systems while maintaining the constraint of time and efficient storage [22]. The timing constraint refers to the execution time of any transaction and it varies from application to application.
IoT consists of the network of nodes which are conventionally based on real-time systems. For example, temperature sensors keep recording the temperature of the environment, and temperature itself is an example of realtime data because it changes with the passage of time. In this paper, the proposed model is using RTDBS for keeping the storage as minimum as possible. Instead of adding a new record for every transaction, the same record is rendered to change its state. This approach of using RTDBS can exceedingly enhance the efficiency of IoT system. The development of real-time processing systems requires the integration of RTDBS while keeping the characteristics of data under consideration

Relational Vs. Non-Relational Databases
The application of IoT switching depends upon the realtime data. A real-time database system can be implemented by using either SQL (relational database) or NoSQL (nonrelational database). While selecting the more appropriate database architecture for the implementation of our project, following points must be considered [4]:  Semantic Interoperability: The data in real-time database must be suitable for being used by external agents and applications, this is why it should be easier for a user to understand database and this can be achieved by unifying formats, data modeling, etc. Nonrelational database can handle this issue in more satisfying way as compared to relational database.
 Scalability: Our system must be capable of handling large requests with low response time. Relational database relies on vertical scalability which is costly and time-consuming because it depends on hardware and it is impractical due to the hardware limitations. The non-relational database is preferential as it relies on horizontal scalability.
 Cloud: Relational database is not an appropriate choice for cloud-based system because it does not exhibit the characteristic of full content data search, while the NoSQL database exhibits all the characteristics which are well-suited for cloud environment.
 Complexity: Storing and managing data in tables makes the relational database complex and slower for data retrieval. NoSQL database has the capability of storing unstructured data and this makes NoSQL database more suitable for real-time applications.

Firebase Realtime Database
Firebase is a mobile and web application platform which consists of different services provided by Google including authentication, hosting, cloud storage, ML (Machine Learning) kit, cloud functionalities, real-time database, etc. The service which our application requires is real-time database coupled with cloud functionalities. Firebase Realtime Database is a cloud-hosted NoSQL database having the feature of synchronizing data in real-time for all clients connected to it. The clients connected with the same Firebase Realtime Database instance receive updates automatically. If any value in Firebase Realtime Database changes, this modified value become accessible for every client possessing the API key. API key is selected wisely and it comprises of relatively lengthy string for ensuring the feature of security.

Hardware Design
For making an interface between the real-time database and switching circuit, a middle hardware component is required. This requirement is fulfilled by using ESP8266. ESP8266 is a cheap and efficient Wi-Fi module which has made the realm of IoT deployment feasible and efficient. For demonstration, NodeMCU board is used. NodeMCU is an open-source IoT platform which has the firmware of ESP8266 and hardware based on ESP-12 module. A switching circuit is also required. The proposed system does not use conventional electromechanical relay (EMR) for switching operations because EMR is a less efficient solution for IoT switching because it may suffer coil failure or the contacts can get melted due to heavy load, and EMR also produces arc during the phase of switching. A better alternative of EMR is solid-state relay.

Solid-state Relay Circuit
The reasons for preferring solid-state relay over conventional relay has been mentioned, a solid-state relay circuit is designed for 220 volt while keeping different safety measures under consideration. A proposed schematic of the circuit can be seen in Fig. 1. This design is compatible with high power appliances also. These high power household appliances include electric motors and washing machines.

TRIAC Specifications
It can be observed in Fig. 1 that the solid-state relay requires TRIAC and opto-isolator along with current limiting resistors and voltage smoothing capacitors. The prime component of the solid-state relay is TRIAC. TRIAC can be used for switching DC and AC appliances. There are primarily two major families of TRIAC, that is, BT136 and BT139. The more suitable option for high power electric appliances is BT139 series.

Safety Components in Circuit Design
In order to isolate low voltage component from high voltage load, an opto-isolator is used which isolates the lower voltage part of the circuit from high voltage load. This protects the ESP8266 from getting burnt. The suitable and appropriate opto-isolator for our design is opto-triac. The proposed schematic contains MOC3021 opto-triac.
TRIAC-based circuits often suffer from "Rate Effect" which arises due to the switching noise or transient in the AC line. In order to tackle with this problem, snubber circuit is connected in parallel with the TRIAC. This snubber circuit consists of a capacitor and resistor connected in series. This snubber circuit does not let the TRIAC divert from its functions by suppressing the surges.
After parsing through all these steps, an optimized TRIAC-based switching circuit is designed by following the schematic diagram of the circuit mentioned in Fig. 1. This switching circuit is adequately compatible with the load of 220 volt, and it is more efficient in term of power loss and cost also.

System Architecture and Prototype
After elucidating main units of the system, it is the time for demonstrating the implementation. The architecture of RTDBS-based IoT switching consists of following primary components:  Figure 1.

Figure 2. Mobile Application for Switching Interface
The aforementioned four stages make it possible to turn the switch ON or OFF while being geographically distant from the physical switching circuit. The user needs to interface with a mobile app or web app for sending the command. The architecture for IoT switching model based on cloud-centric RTDBS is shown in the Figure 3. "SWITCHES" in the Figure 3 refers to solid-state switching circuit whose description has been discussed in Section 3.  There are many factors which contribute to better performance of IoT systems. The immunity towards continuous switching operations and total response time for a switching transaction are two primitive factors on which the performance of IoT system mainly depends. The Total Response Time (TRT) can be calculated by using Eq. (1). The parameters involved in Eq. (1) mostly depend upon the services and utilities which are being used for the implementation of IoT system. This is why these parameters may vary from system to system.

TRT = T S + T A + T R
(1) T S = Time consumed in speech to text conversion.
T A = Time consumed in sending request to database and updating the instance.
T R = Time consumed by real-time database in sending request and executing switching operation at ESP8266 node.
The intuitive description of timing delays involved in Eq. (1) is elucidated in Figure 5.

Application Scenarios
IoT has started influencing different domains of life. The IoT switching model proposed in this paper can be leveraged in many of these domains. Following are some of the prominent application areas:  Smart Healthcare Systems: Smart healthcare systems are immensely benefiting from emerging domain of IoT. The patient monitoring systems are being integrated with IoT to provide more detailed assessment to the patients [11]. Personalized healthcare gadgets are being developed for monitoring different body parameters [5]. The proposed switching model can be integrated with healthcare devices for remotely operating the devices in a secure way. The communication can be secured by enforcing encryption functionality provided by the cloud service [2].

 Home Automation:
Home automation is one of the major areas which came under the impact of emerging IoT paradigm [12]. Smart homes not only provide automation but save the energy consumption also [13]. The switching model, which is presented in this paper, can exceedingly enhance the performance and security of the smart home systems while providing the remote control to the owner of the house. The efficient design of switching circuitry reduces the power consumption and overcomes the threat of circuit malfunctioning that can result in electric shocks.

 Smart Cities:
The paradigm of IoT can be leveraged for development and modelling of smart cities. The traffic management, surveillance systems, energy monitoring, sanitation, pollution control and water supply management can use IoT for ensuring security, safety and cleanliness in cities [9]. The proposed model can augment all these aforementioned functionalities by providing a remote switching that can be retrofitted with advance algorithms for managing the traffic and other issues of smart cities from a centralized control.

 Smart Agriculture:
There are many applications of IoT in the domain of agriculture [7], [8]. The irrigation systems can be automated for increasing the productivity. Precision farming and monitoring can leverage IoT for improving the quality of crops [14], [19]. The domain of data analytics coupled with IoT can further improve the efficiency of smart farming systems by exploiting different techniques of data analysis. The proposed switching model can be leveraged by farmers for remotely controlling water nozzles and other smart irrigation functionalities from their homes.
Besides aforementioned application areas, the proposed model can be integrated with wide range of systems in different domains. The IoT switching can be used for controlling any IoT device remotely. The only requisite is the availability of Wi-Fi signals.

Results
The model proposed in this paper was implemented for testing and calculating average Total Response Time (TRT). It has already been mentioned in section 4 that TRT depends upon the specifications of the services which are used in the implementation of IoT system. Average TRT may change for different implementations and it can be calculated by using previously mentioned Eq. (1). The implemented model was subjected to 100 continuous switching transactions, and it was tested with voice commands in both English and Urdu. In our implementation, Firebase Realtime Database and Google"s Speech-to-Text APIs were used.
The implemented model successfully withstood the continuous switching transactions without demonstrating any degradation in hardware components. The average TRT for English and Urdu commands were found to be 1.5047 and 2.0457 seconds respectively. The timing graphs for English and Urdu voice commands are shown in Fig. 6 and Fig. 7.

Related Work
The paradigm of IoT is a rapidly emerging domain of computer science. IoT is not only being used for accomplishing the task of automation at different levels, rather it is being used for reducing the energy loss that arises due to manual control of different devices. A significant amount of IoT researches and developments has been observed in last decade. There are many applications of IoT predicated on automation. Many models have been proposed for the implementation of automation systems coupled with IoT paradigm.
Abidi et al. [1] and Husain et al. [10] used Bluetooth module for implementing smart home system but Bluetoothbased models are restricted to indoor communication due to low range. Bai et al. [4] proposed the idea of using fourquadrant User Interface (UI) coupled with Bluetooth module for the development of smart home system which can be controlled by mobile application through Bluetooth interface.
Zungeru et al. [26] presented the idea of smart home system based on Wireless Sensor Network (WSN). The proposed design consists of a centralized hub which is connected with three nodes: socket, sensor and switch. Authors mentioned Raspberry Pi microprocessor as centralized hub and discussed the design of switching circuitry based on conventional relays. Moreover, the authors coalesced the functionality of energy harvesting into their IoT model.
Portaluri et al. [20] used OpenMotes for integrating Industrial Internet of Things (IIoT) with cloud functionalities. In their mode, the data records garnered from IIoT system are stored in real-time database on cloud.
Yildiz and Burunkaya [25] used Consumer Internet of Things (CIoT) paradigm for developing smart home system. Their proposed design consists of Arduino Nano and NodeMCU ESP8266, and the monitoring of energy consumption is also performed by WiFi-based CIoT network. Similarly, Alves et al. [3] also used ESP8266 for automating the powering operation of lightening and air conditioning units of smart home for reducing the energy consumption. The authors claimed to save 20% of energy during the period of 30 days.
While most of the proposed IoT systems rely on Bluetooth for indoor environment and Ethernet for outdoor environment, the IoT systems based on Wi-Fi were not found optimized to higher extent. The use of intelligent nodes consisting of microprocessor causes burden on management and energy saving paradigms of IoT. ESP8266, a low-power and cheap Wi-Fi SoC (system-on-chip), has shifted the IoT paradigm to the next level of advancement. This SoC is a cost-effective, feasible and more reliable solution for integration of IoT in small and large scale products. This paper further optimizes the IoT based automation system by embedding it with the features of cloud-hosted RTDBS, ESP8266 low-power Wi-Fi SoC and a feasible design of switching circuitry based on solid-state technology. These three features are integrated with a user-friendly UI which possesses the functionality of receiving voice commands and these voice commands can be received from the user in any native language by integrating the mobile application with suitable Application Programming Interfaces (APIs).

Conclusion
In this paper, we proposed how a cloud-centric real-time database system can be utilized for implementing a feasible, cost-effective and stable IoT switching system. This paper also highlighted the efficient hardware interface with the real-time database system and proposed the optimized solution for switching circuitry which can be implemented for long-term systems. The proposed IoT switching system is cost-effective, and this feature makes it an affordable solution which can be retrofitted with existing home automation systems at large scale.
The solid-state technology makes the switch highly compatible with high power appliances as well. The switch can be connected or retrofitted with any type of household appliances for controlling the switching mechanism remotely from any place. There is no need to deploy separate components for in-door and out-door environments and this is another advantage which reduces the size of the switching circuitry. The proposed switching model can also be integrated with any electric appliance at the time of manufacturing.

Future Research
The analysis and management of large scale real-time databases is still a challenge for IT professionals and different techniques can be used for accomplishing this task. Statistical model checking is one of the techniques that are used for the analysis of real-time database [6]. The rapidly emerging domain of artificial intelligence can be integrated with real-time database for improving the performance measures of real-time systems [24].
Since the impact of IoT is spreading rapidly while affecting the different domains of life, there is the need of more secure and reliable implementation of IoT based systems having minimum loopholes. The current IoT technology is significantly subjected to security and stability threats. Many approaches can be considered for ensuring security in IoT systems, and the use of cloud-centric realtime database system is one of them [23]. The IoT architecture based on cloud-hosted RTDBS can leverage different security services which are provided by the cloud. The integration of Software Defined Networking (SDN) can exceedingly enhance the resiliency and robustness of IoT systems [15]. The security in IoT can also be tightly enforced by using deep learning models [21].
The proposed IoT switching model can be utilized for further applications in future. It can be used as an efficient sub-system in large-scale production.