Context-Aware Mobile Sensors for Sensing Discrete Events in Smart Environment

Over the last few decades, several advancements in the field of smart environment gained importance, so the experts can analyze ideas for smart building based on embedded systems to minimize the expense and energy conservation. Therefore, propelling the concept of smart home toward smart building, several challenges of power, communication, and sensors’ connectivity can be seen. Such challenges distort the interconnectivity between different technologies, such as Bluetooth and ZigBee, making it possible to provide the continuous connectivity among different objects such as sensors, actuators, home appliances, and cell phones.Therefore, this paper presents the concept of smart building based on embedded systems that enhance low power mobile sensors for sensing discrete events in embedded systems. The proposed scheme comprises system architecture that welcomes all the mobile sensors to communicate with each other using a single platform service. The proposed system enhances the concept of smart building in three stages (i.e., visualization, data analysis, and application). For low power mobile sensors, we propose a communication model, which provides a common medium for communication. Finally, the results show that the proposed system architecture efficiently processes, analyzes, and integrates different datasets efficiently and triggers actions to provide safety measurements for the elderly, patients, and others.


Introduction
Recently, the concept of smart building is developed and researchers and other experts are trying to provide the best services to the people who live in such buildings. Since it is difficult to provide their best facilities in a real-time environment due to high cost of the home appliances [1], many researchers are using simulation environment that decreased the cost of test, design, and environment [2,3]. With a view to design smart building, the rapid growth of mobile sensors is required to be connected with each other with the help of the Internet that creates IoT. Such network generates enormous amount of data, usually termed as Big Data. Similarly, enabling seamless connectivity with existing networks and proactive operation based on different factors (context-aware computation) are mandatory in IoT. The goal of IoT is to let the computer identify information without human interaction. However, it depends on three factors, such as (1) understanding users and its appliances, (2) architecture and communication, and (3) analytical tools to support smart behavior. IoT and cloud computing can be considered as two major technologies, which have been developed in order to extend embedded computing. The embedded computing integrates different technologies with the daily life. Similarly, human-centric embedded computing focuses on the specific domain by means of whom should be benefited. The devices connected wirelessly have the ability to act as embedded sensors using MEMS and wireless communication. These devices are known as nodes in a mobile wireless sensor network (MWSN). Cloud computing uses the Internet to provide scalable, reliable ubiquitous computing by acting as a receiver of data from ubiquitous sensors.
IoT has been defined in multiple ways by multiple interest groups as IoT is a combination of middleware, sensors, and knowledge [4]. However, according to Radio-Frequency 2 Journal of Sensors Identification (RFID) group, IoT can be defined as a network in which objects are accessible uniquely via standard protocols [5]. In addition, things are associated with each other with the help of IoT that is able to sense and share information without human intervention. Hence, the researchers from various fields describe IoT as the interconnection of devices that share information among different platforms via standard platforms. Such facilities can be achieved via ubiquitous sensing, data analytics, and so forth in which various entities are involved that are RFID, WSN, their addressing schemes, data storage, and analytics.
To make IoT more appealing, a traditional application, that is, smart building, is considered where embedded devices (such as sensors and actuators) are considered autonomously and is remotely controlled my means of the Internet. The mentioned technology is used to empower monitoring application with the security features. The embedded devices are used to sense user activities and control electric appliances according to the information collected by these devices. Such development leads us toward the concept of smart building where the information is being processed processed, analyzed, and predicted or gives response to the outer stimuli based on the received information according to certain rules. The rules that are triggered by actions can be uttered as the form of condition action. For instance, an action can be defined as "working in a office in a bright light, and all the lights are switched on, the lights will become dim automatically." In designing smart building systems, rules are important components that provide flexible control. The basic ides of these rules is to distinguish between logic and data, which helps in making maintainable parts independent. Therefore, in the literature, many rules engines are designed that are used to reduce the cast of desiging, developing, and delivering software [6][7][8][9]. For instance, in a traditional wireless sensor and actuator network, different kinds of embedded sensors are deployed that are used to collect environmental data. Each device is equipped with actuator capable of receiving control commands. Consequently, results are contributing a lot of rule sets. These rules are generally quite complex to handle huge volume of big data; this cannot be directly applied to smart building systems.
Having understood the feasibility and potential of embedded devices, in this paper, we propel the concept of smart home to a further extent and introduce a notion of context-aware low power mobile sensors for sensing discrete events in embedded systems. In the proposed system, mobile sensors are deployed in a building that senses discrete events (such as temperature, user activities, and body area network for healthcare) and share this information using the same communication medium, that is, the Internet. The shared medium is supported by the Internet where a variety of devices are interconnected with each other. The nature of these devices is heterogeneous, which requires a unique platform to exchange useful information. Moreover, in order to achieve this, an architecture is also proposed in which an efficient communication among various embedded devices takes place in a smart building based on the contextual information. It can be viewed that these devices (such as smart watch, healthcare, Kinect Xbox 360, Internet of Vehicles, and GPS) continuously monitor the physical entities, and, when required, automatic or controlled physical system gives alert to the specific event to improve healthcare, security, accidents, fire brigade system, and so on. This system is connected to the Internet with the help of Wi-Fi (IEEE 802.11) and the third generation (3G) of mobile telephone.
The remainder of this paper is organized as follows. Section 2 presents a detailed description of the background and related studies. In Section 3, we described some of the IoT characteristics. Section 4 presents the proposed system architecture for context-aware low power mobile sensors for sensing discrete events. In Section 5, a detailed analytical and simulation analysis and a conclusion of the paper are presented.

Background and Related Studies
In this section, we provide the background of WoT that could be integrated with the IoT along with the related studies in the field of IoT and smart home. Much of the research work has been done in the field of smart buildings and smart home. However, still the short holes are there to fill the gap. Therefore, the researchers are still working to make building smarter in order to take a smart and intelligent decision in the case of any emergency and disaster.
Asimakopoulou and Bessis [10] work in sensing of building and crowd in order to handle disasters and serious problems occurring in the building. Do disaster management. They took the concept of crowdsourcing to utilize it in smart buildings and cities in order to effectively manage the disasters. Some other research LABs and organizations tried to build a practical testbed of the smart building in order to measure and sense the internal environment of the building. A testbed place in the University of Southern California [11] is selected to build because of its diverse nature of mix spaces and classroom usage and scheduling. The testbed was facilitated by advanced indoor sensors actuators and intelligent building management systems, suitable for broad range of research activities. The complete communication infrastructure is built to manage the whole transmission between sensors and a centralized server. The centralized server controls the actuators by sending signals to them. The number of sensors is deployed to get the real data related to building environment and other things such as lighting conditions, airflow, temperature, and CO 2 and other toxic gases. Similarly, Lee et al. [12] and Ahmad et al. [13,14] also design a smart building and smart society by focusing on the energy aspect while considering smart grids in building. They investigated getting and controlling data by accessing the energy resources in a smart building through smart grid infrastructure. However, they did not focus on the energy service interface (ESI), which is considered as the main communication gateway for a smart building. They provide the illustration of interactive energy services between the grid infrastructure and smart buildings.
Some of the authors also provide the conceptual simulation of smart building and smart homes. Bidhandi and his research colleagues [15] divided their simulation process into two phases. In the initial phase, the person can make design planning their home floor or building floor manually or through CAD software. Later their design allows adding home appliances and equipment to the building design. In the next phase, that is, phase two, they provide the simulation by two methods while defining scenario and analyzing the building reaction on various scenarios. They claimed to increase the features of flexibility and usability increased for the user to easily simulate any type of smart building with various features and ideas by reducing the overall costs. Moreover, in [16], authors developed new simulator based on the context information of smart homes by focusing on the main goal of context-aware system design. In [3,[17][18][19] also is presented a multipurpose simulator based on the scenario for the smart house atmosphere which again is an object oriented one and is capable of defining various sensors and placing them on the floor plan of the building. The user is also able to sketch the plan of the house. In [18], a configurable context-aware simulator for smart home systems is presented, in which the open service gateway initiative is considered for being operated in the framework of the smart house. And with such framework, we can make sure of the completion over time and also a connection to the outer world. Remote controlling, trouble diagnosis, and management are supported too. In [20], there is a full, conclusive survey about the architecture of service oriented simulator for smart house management. That is a service oriented perspective of making and using a simulator founded on reality and also a perspective of virtual integration with devices in a building model. In rule based system in the smart building, broad work has been done, especially in processing schemes [21,22]. In the terms of the rule engine, they mainly consist of two aspects: the RETE algorithms and the complex event processing mechanism. RETE is a customary algorithm for the rule engine developed by Forgy [23,24] and first engaged in production systems and more M2M and V2V event engines shall be considered later [25][26][27].

Context-Aware Low Power Based Mobile Sensing System
In this section, we discuss the breakdown of the proposed system into two parts, that is, communication model and the architecture for context-aware low power mobile sensors for sensing discrete events in embedded systems. Before propelling toward the architecture for context-aware low power mobile sensors for sensing discrete events in embedded systems, it is worth presenting the overview of the proposed architecture.

3.1.
Overview. The proposed context-aware low power mobile sensors for sensing discrete events in embedded systems consists of three major units, such as application unit, data analysis unit, and visualization unit, as shown in Figure 1. The application unit is comprised of the healthcare system, home security system, and smart building system. In the healthcare system, we have employed source ID/locationbased 6LoWPAN wireless body area network mobility management scheme as shown in Figure 2. In the architecture, a group of 6LoWPAN sensors are considered, which are attached to human body. In this group of sensors, there is one coordinator that is used for exchanging control messages with Primary Mobile Device (PMD). Each PMD and sensor have a 128-bit global unique device identifier (GDID) [28]. GDID establishes end to end communication provided with the link-layer addresses as the Access IDentifier (AID). The GDID has the information about its home domain. However, Local LOCators (LLOC) and Global LOCators (GLOC) identify location of PMDs within the home domain.
Since the GLOC denotes the IP address of Access Gateway (AGW) that is used for interdomain communication. In the given scenario, each AGW contains home GDID and visitor GDID register. HGR contains the mapping information about the GDID-LOC and VGR contains GDID-LLOC mapping information for the visited PMDs.  In the proposed architecture, only one-time Router Solicitation (RS) and Router Advertisement (RA) messages are sent by the coordinator and thus reduce lots of control messages. Initially, the PMD communicates with correspondent PMD (C-PMD) in the previous AGW (p-AGW) domain. Now, the PMD moves to a new AGW (n-AGW). Finally, the proposed smart building is equipped with the electronic appliances, which are interconnected with each other with the help of Bluetooth and ZigBee technologies.

Communication Model.
We propose a couple of different technologies for communications in the smart home. The ZigBee technologies are used to cover the entire smart home because the ZigBee technology is considered as better than IEEE 802.11n in providing LAN services and advantages of ZigBee include low power and low duty embedded systems. Hence, in the same way, we use Bluetooth Low Energy (BLE) device inside a smart home for covering an entire room. The actual purpose of using BLE is that it works efficiently for Personal Area Network (PAN). Therefore, we present an overview of the communication model of both technologies in the following subsections.

Bluetooth Low Energy (BLE). Bluetooth Low Energy
(BLE) is considered one of the latest versions of the Bluetooth v4.0, which is designed for the low power consumption devices, such as sensors and wearable devices. The Bluetooth Low Energy (BLE) consists of two layers, that is, upper and lower. The upper layer provides the functionality of error control and flow control and lower layers handle the transmission of bits over the physical medium. The upper layer is again divided into three types, that is, Logical Link Control and Adaptation Protocol (L2CAP), Generic Access Profile (GAP), and Generic Attribute Protocol (GAP). The Logical Link Control and Adaptation Protocol (L2CAP) is used for fragmentation and reassembling of large packets and the multiplexing of the data from upper layers. The Bluetooth Low Energy (BLE) is using Adaptive Frequency Hopping Spread spectrum (AFHSS), which is similar to classical Bluetooth. However, the BLE uses 40 channels, each of 2 MHz, bit rate of 1 Mbit/s, and transmit power equal to 10 mW. As BLE uses a bit rate of 1 MHz, it is unable to provide the voice capability. Because of these features, the BLE is considered in low energy devices such as mobile phones and wearable devices.
The BLE devours 90% (0.01 to 0.05 W) of the vitality on the advertising and examining process, though we talk about the advertising and examining process in detail. The BLE works in three distinct ways, that is, notice of the BLE devices, filtering of the accessible devices, and starting the connection, not at all like the classical Bluetooth. The BLE has three unique channels for advertising, that is, 37, 38, and 39. The BLE has 40 channels out of which three channels are utilized for the promotion purpose. Thus, the BLE continues sending the messages utilizing the ADV IND packet data information units over the three channels during the event. An arbitrary measure of deferral is utilized between the notices of the channels to avoid the crash between two advertisers. The BLE standard characterizes the advertisement interval for each of the three channels, and the notice ought to be somewhere around 20 and 10.24 ms having a number different of 0.625 ms. Likewise, the delay should be under 10 ms [29]. Once the advertisement stage is over, BLE will listen to the reactions from the accessible devices on the same channels. Along these lines, the gadget will go into filtering mode after add stage. The scanner responds to the advertisement message. The standard characterizes window time of 10.24 s for filtering the accessible gadgets. Keeping these attributes of BLE innovation, we use it in the proposed smart building design.

ZigBee Protocol.
The ZigBee protocol is based on the IEEE 802.15.4 standard and can be used to transfer data over a distance of 10 to 100 meters. In addition, ZigBee is considered for low power devices since it requires less energy for their communication. Correspondingly, ZigBee consumes more energy on the transmission of data. Similar to BLE, ZigBee also operates on 2.5 GHz, that is, unlicensed band worldwide, which uses 16 channels with a 5 MHz space and 2 MHz bandwidth. The ZigBee uses direct-sequence spread spectrum (DSSS) coding technique. Moreover, there are two types of communication modes that are present for data transmission, that is, beacon-enabled and non-beacon-enabled. In the case of beacon-enabled approach, the network coordinator periodically broadcasts the beacon message in the PAN Network. The devices in the PAN network synchronized with the coordinator upon receiving the beacon messages. In the case of the non-beacon-enabled communications, randomly broadcast the beacon messages. If a device wants to send  data it waits for a random amount of time and then senses (CSMA-CA) the channel; if the channel is available, it starts the data sending; otherwise it switches to waiting state. The framework of the beacon-enabled and non-beacon-enabled communication is shown in Figures 3 and 4, respectively [30]. In the case of beacon-enabled communications, the PAN coordinator periodically broadcasts the beacon frames. However, in the case of non-beacon-enabled communication, the PAN coordinator randomly sends beacon frame. The PAN device has to wait until the channel is available in idle state; otherwise it waits for a random amount of time.
Whenever a device is not sending data, the ZigBee protocol turns off its radio interface to save the energy. Similarly, a node can be in the active state whenever it is transmitting a beacon message. The beacon interval depends on the data rate, and it is usually ranging between 15.36 ms and 251.65 ms at 250 kbits/s. Keeping in view the communication model, we proposed that the BLE is an excellent choice for using it in the room coverage while using ZigBee for the entire house.

Proposed Smart Building
System. The proposed system architecture is composed of different embedded devices, such as mobile sensors, healthcare system, and security system, located in a large geographic area. Also, these embedded devices are deployed in home, police station, and fire and brigade centers. These devices are interconnected with each other with the help of Internet using short range communication technologies, that is, Bluetooth and ZigBee, or long range technologies such as WLAN and cellular, as shown in Figure 5.
In Figure 5, different electric appliances are interconnected with the help of Internet. These appliances are also connected with the home server that helps in storing the  data for our analysis purposes. Electric appliances include healthcare system for elderly people, wearable devices, social network, and Kinect Xbox for a security system. In the given figure, these devices are connected to the actuator with the help of ZigBee. ZigBee device is then transmitting these signals to the home server. In our proposed system architecture, actuator acts as an intelligent device that provides a medium of communication among various electric appliances using ZigBee or Bluetooth. For instance, various electric appliances, such as smart meter, water usage meter, and lights, are connected to the actuator. These electronic devices perform accordingly when the user is at home or not. Moreover, also, it depicts the level of the water that is used by each user in a home. Similarly, all the electric appliances are controlled remotely. For instance, if a user is not in a home, the user can access home server with the help of 3G/4G data network and can send instructions to the devices to perform a particular task. Moreover, a surveillance system is designed for elderly people and small kids in a home. In the case of elderly people, wearable devices are used that could detect the body gestures of the object and could decide the position of the object using body area network in integration with BLE. Similarly, for small kids in a home, our designed system could be used to find out the current location of the kids. To elaborate the finding of the small kids in a home, the following technique could be applied, which shows the registration phase among coordinator, PMD, and AGW.
As delineated in Figure 6, coordinator is attached to PMD that sends router solicitation (RS) message to PMD. The RS message has the coordinator ID (GDID) and link-layer address (AIDs). The PMD sends a response message to the coordinator upon receiving RS message, and then it generates RA message again back to the coordinator. Afterward, PMD sends Location Update Request (LUR) to AGW as shown in Table 1. Upon establishing connection with the AGW, the PMD sends device ID request to the AGW. Afterward, AGW authenticates whether GDID fits in the same domain or not. Since GDID has the information about its home domain, after authentication, location discovery message is sent to the c-AGW. Afterward, c-AGW will first check the HGR mapping table and then will generate response to AGW that contains location discovery message. Upon receiving this message, the AGW adds this information to its mapping table and then sends device ID message to PMD. As a result, data message is forwarded to C-PMD as shown in Figure 7.
The proposed smart building system architecture is equipped with the healthcare embedded system that helps in assisting users in aj home. There are various conditions of health that are considered from various datasets, which are diabetics, blood pressure, and other activities, such as climbing stairs; these embedded sensors are attached to the human body that constantly monitor various parameters in a human body, such as diabetes and body temperature. The proposed system architecture welcomes the incoming data that helps in processing the data by the designed algorithms. For example, if a patient condition is dropping or elevating more than a particular threshold, then the system generates alerts and warning messages. These messages and alerts are sent to the home server; the home server is connected to the Internet that sends the data to the concerned department. The sensors attached to the body of the patients communicate locally using the BLE technology. Moreover, the communication with the home server is done using the ZigBee technology. Similarly, the data from the home server is sent to the remote department using WIFI or cellular technology. The concerned department initiates the emergency conditions upon receiving the alert and sends the ambulance or doctor to the patient location. Similarly, other emergency conditions such as in the case of fire, gas leakage, and water pipe leakage can be controlled using the same architecture. The web server plays a vital role in this situation by sending the information to the other web servers for more efficient recovery and timely services.

Analytical Results and Discussion
The proposed system architecture is provided with the algorithm that helps in monitoring fire level in the home. Moreover, the designed system is also used for monitoring the patient heartbeat rate in a home. Initially, the system is provided with the information of flashlight and temperature since this information is used for the setup of the initial threshold to check whether the system generates an alarm or  not-depending on the values it received from the embedded sensors. For our analysis, we have tested the proposed algorithm many times in order to check the system accuracy. We have noticed that the proposed system generates zero-degree false alarm. Moreover, if the system is taking measurements and it is within the limits for a longer time, then the system calculates the mean, standard deviation, and maximum value readings. Similarly, the corresponding action is taken while  considering the above values. The same analytical results have been measured in the case of the chronic patient. The thresholds are set on the lower and upper limits of the blood pressure. In case of the higher blood pressure or lower blood pressure as compared with the threshold, the alarm is generated and sent to the concerned department. A pseudocode is given in Algorithm 1.  For our analysis, various datasets are considered, such as temperature datasets (118 MB), ECG datasets (227 MB), and heartbeat rate datasets of 1.7 GB. These datasets are taken from [29,[31][32][33]. We have performed analysis using Hadoop ecosystem by considering MapReduce function. Beside these, other parameters, such as activity parameters and medical health parameters, are taken into account in single datasets. In order to validate the proposed system architecture, we have performed analysis on the above-mentioned datasets to check the throughput and processing time as shown in Figure 8. In this figure, the size of the temperature datasets is taken as minimum; therefore, greater throughput is noticed. However, if we increase the size of the datasets, the throughput of the designed system drastically decreased.
In order to extend our simulation analysis up to further extent, we have considered a scenario of the house with five members. The average energy consumption by the BLE and ZigBee sensors attached to different appliances is calculated for a duration of 12-hour time (duty cycle is 100%). The duty cycle is the time in which the radio interface remains in the active state. The energy efficient communication stack has a duty cycle less than 1%. However, we want to utilize fully the effect of both the technologies; therefore we keep the radio interface always in on state. The sensor embedded in each device operates on a pair of AA batteries (3000 mAh). The BLE-enabled sensor consumes an amount of 6 mA of current in the active state. Similarly, the ZigBee is consuming an amount of 13 mA current. The member of the house randomly moves around the house and randomly switches on/off the device available in the house. The BLE is only used in the room environment while the ZigBee is used in the entire house. The security system and door opening and closing are also controlled through remote control operating via ZigBee. Similarly, different appliances like TV, refrigerator, washing machine, light bulbs, microwave oven, and so forth are also controlled through sensors both using ZigBee and BLE (only rooms). The communication in the range of 50 m is carried out using BLE and more than 100 m using the ZigBee. The average energy consumption values of both technologies for 12-hour time (50% duty cycle) are graphed in Figure 9. Similarly, the total energy consumption of both technologies in the 12-hour time (100% duty cycle) is also computed as shown in Figure 10.
Different types of embedded sensors are deployed in different locations of the home, such as in a kitchen, for human body, and for security services. We have calculated the energy conception of each sensor as shown in Figure 11. The sensors that are deployed in a room usually consume less energy since these sensors are using their transceiver for less duration of time because of the daylight, whereas the usage of these sensors increases in the evening that generally results in increasing the battery usage of the sensors. However, there are some particular times in which the sensor is in the sleep state. At that point, the sensor node does not consume energy. Moreover, the duty cycle of sensors is shown in Figure 12. In this figure, the graph shows that less amount of energy is consumed by the sensor because of the daylight. Therefore, the sensor turns off its transceiver. However, as the light becomes dim, the duty cycle of the sensor increases.

Conclusion
In this paper, we provide a new concept of smart building that is proposed to integrate the concept of the IoT based on the Internet using low power mobile sensors. Furthermore, we define a communication model for sharing data using the same medium. The communication model provides a common medium for the communication of all the heterogeneous devices. Furthermore, a system architecture is also proposed based on the Internet application. The Internet application concept is used to send or receive action message over the network. The proposed architecture provides the application, analysis, and visualization aspects where various devices are integrating various electronic devices. The performance of the system architecture is tested on Hadoop using UBUNTU 14.04 LTS Core6 i5 machine with 3.2 GHz processor and 4 GB memory. Similarly, the energy consumption of the sensors installed in the proposed smart home is also computed. The energy consumption of the sensors using the proposed architecture is significantly reduced. The final evaluations show that the performance of the proposed network architecture fulfills the required desires of the users connected to it, whether the input data is a real-time as well as offline while taking actions at real time. For future work, we are planning to develop a system for disaster management in smart building. The disaster management will be based on the user and appliances' data. The system will decide how to guide its user at the time of disaster.