Adaptive Home Automation System by Using Smart Phone Based Artificial Intelligent

The system of Home Automation consider nowadays as a promise technology for living a comfortable life and minimizing the cost of the user homeowner. The system might be accomplished by controlling the heating, ventilation, air conditioning, shading, and lightening. The energy consumed efficiency is get better also the protection system is exists. In this work, a Home Automation System is proposed, so that it performs automatically controlling to some of the appliances in the home. In addition, the proposed system will discover any undesirable movement or fire when the person is out of his home by taking a suitable decision instead of homeowner. The control unit uses a Smart Phone (Android Mobile). In this work, to gather readings of movements, heating, and lightening, a number of nodes are used (three nodes). Also a Microcontroller uses especial sensors to collect this information, after that sends them wirelessly through WIFI to the Smart Phone for manipulation and taking a convenience decision. Delta Neural Network Learning Rule is use for the first time as the intelligent algorithm to give the decisions for all the readings of sensors, so that it learned after 113259 which take 2280 seconds. In addition, it turns out the automated system to be further smart such that if there is fire or movement into the house, the application will distinguish if this movement for example dangerous or not. The mobile (through the application) then gives a command to send a message (GSM) to the homeowner (Police, or fire station) telling the new situation. Furthermore, the controlling of all convenient appliances at the home automatically for each state. JAVA Program is use for manipulation process, and then by employing Eclipse Juno IDE program it turn into to an android application that installed into the Mobile. The Microcontroller is Arduino with WIFI shield and Xbee.


Introduction
Smart home automation has many benefits like providing safety, security, and increased comfort to people so it can be a very promising area.Energy and other resources will be intellectual use, which gives a great savings in terms of time, and exceed the security.Therefore, the system is portable, scalable and affordable, such that you can added new devices easily in to it [Johri et.al., 2015].Different communication technologies can use by the system such as Wi-Fi (Wireless LAN), WiMAX, ZigBee, Bluetooth, and Global System for mobile communication (GSM) [Teymourzadeh et. al., 2013].
In addition, elderly and disabled can use home automation to obtain increased quality of life for men, women, and children who might otherwise need institutional nursing or attention [Javale et. al., 2013].In home networking, Wireless systems have become more and more common.Also, the use of wireless technique in building and home automation systems has many advantages that might not be accomplished using a wired network.These advantages like easy deployment, installation, reducing installation costs, easy extension, coverage, and integrated Smart Phones or other cell phones [Elshafee and Hamed, 2012].
In home controlling system, computers have some problems when using as a monitoring part for a remote control terminal, so that the cost is high, and the monitoring range is limited, and so on.These limitations can reduced by using smart phone as terminal unit, and by utilizing the Wi-Fi and Bluetooth, several devices may connected wirelessly with each other [David et. al., 2015].IEEE 802.15.4 standard may use by the WSN with ZigBee, that consider a standard radio frequency (RF) communication [Gill et. al., 2009].
In the proposed system, each node has two module with different types of design and implementation.The sensors/actuator module and wireless module, which uses a 9600 b/s as asynchronous wireless communication.In addition, to perform the connection between the mobile and the system a Wi-Fi shield is connect to the coordinator node.The home data will be collected from the nodes and then sent to the coordinator node in order to be gathered and sent to the Base station for processing.
Here Artificial Neural Network (ANN) learning rule is used for making the house thinking by itself and be more smart by giving the decisions automatically instead of homeowner.

Design of the Proposed System
In this work, the control device for the proposed system is the android mobile with the help of wireless sensor networks and Neural Network.The information of most environment is sensed at each Node, after that the coordinator collected all the data by using XBee.Then local IP is used to upload all the collected data onto the server.The data will read from the same IP by the Android smart phone that processing them via Delta Learning Rule.The control commends (decisions) then will send back to the home applications.
Four types of nodes distributed into two rooms is project consisting of; each node will have its position and name regarding on the task that they do in the system.There are three Hybrid nodes that controlling, sensing, in addition to Coordinator node (CRN).The hybrid nodes consist of some sensors to gather home data like temperature, illumination level, humidity, movement detection and gas level.The scheme and the block diagram of the proposed system can be state in Figure (1-a, b).By taking the practical requirement into account, the proposed system allow "The Home owner" to manage the sensing nodes at suitable places in the room.Each node (sensing/control) has the ability to gather the readings data form sensors, after that transmit these data wirelessly through ZigBee to the coordinator node.When all data collected by the coordinator from all nodes, then they will be send to the mobile smart phone through Wi-Fi shield.
The android mobile connected to the WSN through Wi-Fi shield, the sensed data then will be manipulate automatically by Artificial Neural Network (ANN) Delta Learning Rule (DLR) and display the sensed and result data on the Android mobile.The application that used to create the high level interface between the Android and Java is Eclipse program Hardware module and software module are the model that the proposed system is consisting of so that the first one is concerning with the equipment used in the proposed design, and the second one deals with Android mobile smart phone.

Design of the Hardware
In order to sense and control physical world an Arduino board can be used.The programming durability, flexibility and scalability are the reasons that were dependent in selecting this microcontroller [Faris and Mahmood, 2014].For home temperature and humidity sensing a DHT11 sensor is selected, which is a low cost sensor [Jabbas et. al., 2016].LDR (Light Dependent Resistor) sensor is used for sensing the illumination level in room, PIR (Passive Infra-Rad) sensor is used for sensing the human movement within the sensor range, Ultrasonic sensor is used to measure the distance and MQ2 sensor is used for sensing the gas level and to detect the smoke existence [Latha et. al., 2015].
The designed system is consisting of sensing nodes where a microcontroller of Arduino UNO type is used in each node of them and for the coordinator node a microcontroller of ATmega2560 type is used, each one of these Arduino platforms can be shown in figure (2.a) & (2.b) respectively.The wireless communication between the system nodes is achieved by using the ZigBee networking protocol.In wireless network, the using of the combination of both xBee and Ardunio works very well.In the designed system, the end nodes and the coordinator node are connected with each other using xBee so as to collect the home data and then transmitting these data from the coordinator to the base station (Android mobile) wirelessly through Wi-Fi.The module of the xBee series 2 (S2) is shown in figure (2.c).In order to connect the xbee to the Ardunio board a wireless SD shield is used through serial pins.
Four modes of operation of the xBee is used in this system and these modes are: Transmit, Receive, Idle and Sleep.During the operation of the design system, it will go through all these modes, where it starts by transmit and recieve the data between the coordinator and the end-nodes, idle mode when they are not transmitting or receiving any data and sleep mode that is used only in the end nodes so as to reduce the consumption in the power when they are not connected to the coordinator.Various programming for mobile language is used to develop a Wi-Fi based Home Automation System (HAS) and platform of mobile cross such Java Me, Windows, MoSync, Android, and other technologies [Jivani et. al., 2014].Wi-Fi uses 2.4 GHz radio waves, and it is a local area wireless technology.For connecting the system to the Internet or in elctronic devices for data exchanged, the Wi-Fi is used and the specifications of this technology are being: wireless, transmitting data at high rate, having wide coverage area and capability of anti-jamming is high [Wang et. al., 2015].
Arduino Wi-Fi shield that is shown in figure (2.e) was used in the designed system for connecting the base station (Android Mobile) wirelessly with the sensing system through the use of static IP address by uploading the data from the sense system and then receiving them by the base station through this IP and Vice versa.
For system operating, the android smart phone is selected to be used.An android application is required to be performed in order to operate the system and finally installing this application on actual android mobile.

Design of Android Program
The Java application of the android mobile was designed using the Eclipse Juno IDE.The platform of the android is an open source development that enable designing of android application.The open screen of the designed system is containing two button to start and stop the system operation and view to the received data from the sensing system as shown in figure(3).When the start button is clicked, first it checks that the device is connected to the local network if so, then it will attempt to connect to the server of the sensing system that is represented by the static IP otherwise the program will not works.In case that these two condition are exists and after connecting to the server the coordinator will sent order to the end devices to collect the data and send them back to it.These data will be send from the coordinator to the base station through the IP in order to be processed and finally sending the control commends the the end nodes through the coordinator.

Figure (3): The main program GUI.
After receiving the readings of sensors by the base station, these data will be processed using the artificial neural network with Delta learning rule by using the database that has been learned early and also they will be displayed in the main GUI of the designed program.The displayed data are: temperature value in two rooms and it is in percentage degree, the humidity values in each room, Light illumination level at rooms in case if the lamps are ON or OFF in both rooms depending on the reading of the LDR sensor, the gas situation if its level is normal or not and at last the movement case in each room and if there is motion detected or not.

ANN Learning Rule
Neurons or nodes, which known as interconnected are represent a set of processing elements that ANN consists of.It might be qualified as a directed diagram so that each neuron carry out a transfer function (activation function) as in equation (1).
Output of node i.
Weight of the connections between nodes i and j.
is that activation function which is nonlinear usually, such as a Gaussian function , Sigmoid or Heaviside [Yao, 1999].
The Delta learning rule is one of the algorithm of ANN.This algorithm is a supervised training mode also it uses a bipolar continuous activation functions as shown in figure (4).Equations ( 2) to (9) shows the learning algorithm [Zurada, 1992].the gradient in error is shown in equation ( 9).
x j j=1, 2, 3, …, n … ( 7) … ( 8) i=1, 2, 3, … R … ( 9) Here r represents the learning signal, d is the supervisor signal of neuron i, whereas x appears as the input vector.f( ) is the neuron i output, while w is the weight of neuron i, and  is a learning positive constant that fasting the learning process, moreover t is the training or iteration number of the new weights.f(net) represents the activation function whereas ( ) represents f(net) derivative, and here net = ..

Implementation of the Proposed System
The node of coordinator represents the main part in the proposed and designed system.It is considered as the central node of the system and if it is not works the system will be useless and inactive because all the end-device nodes in the system will remain waiting to have the permission to perform orders or to read sensors data.The components that the coordinator node is consisting of are: Arduino ATmega 2560, Wi-Fi shield, xBee and wireless SD shield as shown in figure (6).

Figure (6) the central node (Coordinator node)
Main tasks that the coordinator node was performed were including: starting ZigBee networking, communication managements between the nodes of the system, collecting the data of the sensing nodes and then arrange these data in order to be sent to the base station (Android mobile) through Wi-Fi connection performed by Wi-Fi shield.the coordinator works start by sending packet to the end devices so as to start collecting the data and then receiving these data from each node.The data will be arranged and then send wirelessly through Wi-Fi connection to the base station.The connection between the sensing system and the base station (android mobile) is performed by using the Wi-Fi shield where both of them are connected to the same router using the IP server.
In the designed system, the Base station is represented by Android smart phone, which can be used in the range of the router coverage area.The software program that used for this system is Java program using the Eclipse Juno IDE.The system can be controlled automatically using the designed program install in android mobile which is exists in the router range.
The operation of the proposed system can be summarized as following:- Connecting the base station (android mobile) with sensing system coordinator node through Wi-Fi. Wake up packets is send to the end-devices in order to get the sensors readings. The sensors readings of each end-device will be sent back to the coordinator. After receiving the data from all end devices by the coordinator it will be arranged together in order to be sent through Wi-Fi to the base station. In base station, the received data are manipulated using the Delta learning rule of Artificial Neural Network (ANN) in order to make decision to control the system using Android Java program.These decisions will be sent from base station to be performed also sending alarm SMS messages.
 The alarm messages are to tell the home owner about the dangerous situations including theft and fire.
The control commends that are sent to the coordinator will be send back to the end-devices in order to be performed.

Results with Discussion
The brain of the proposed system was represented by Artificial Neural Network, which trained by almost cases that might the homeowner face, then take the final decision about these different cases.Delta learning rule may consider the intelligent element that makes the proposed system smarter (thinking) so that it is used to take the decisions of several cases if its dangers or not, and control some of home devices.Here the homeowner is not necessary at home or the proposed system works automatically.The system will send an SMS message as a notification to police or his phone number if there is a dangers case.In the test of the proposed system, several cases have taken and they can summarized by automation control case study security case study and study.
Each case consist of the readings of 11-sensor so that 78 cases are taking into account after that the data will trained by the DNN as you can see in figure (7). Figure (7) shows the learning of inputs data from coordinator, also, the process required about 2280.78 seconds to give an error 0.001.The training stopped after 113259 iterations.

Normal Case
In room (1), Node (1) and ( 2) are placed, while in room (3) there is Node (3).The normal conditions can be represented by the normal case that was based according to the readings of all sensors, which may consider as the desired values.

The Cases of Temperature
The temperature sensor readings are splitted into three values.The first one taking when the value of temperature is lower than 17 o , so that its viewed as a blue color in the screen of mobile.The second value taking is when the temperature exceed than 25 o , so that it is viewed as a red color in the screen of mobile.The last value taking is when the amount of temperature is between 17 o -25 o , such that it is shown as a green color in the screen of the smart phone.
The program of ANN in the Android application is used for controlling the temperature.If the temperature is low, a control commends will be sent by the program to the system to turn ON the heater.The heater case is illustrated in figure (9) where a green LED represents the heater.Here for room 1 the LED is placed in Node 2, while in room 2 the LED is implemented in Node 3.
When the value of temperature is high, the system will turn the air condition ON.This operation is happen because the ANN program in the android application was trained earlier for this condition to send a control commend to it.

The Cases of Light
In the room, the illumination level is designed in the proposed system to sense and control by turning the lights automatically OFF or ON according to LDR readings value with the aim of ANN program.Here the lights in the room will turned ON when the illumination level is below a specific value set by the homeowner, otherwise the lights will turned OFF. Figure ( 10) states the situations of lambs so that the lights is replace by a yellow LED.
For example, in room 1 when the level of illumination is low, Node 1 will receive a control command through the coordinator to turns the lights ON, as seen in figure (11) for Rooms 1, and 2.
In this project, the proposed system can manipulate more than one case at time as depicted in , which shows that there are two cases in room 2. The first case, the light is low, while the second case the temperature is large, so two emitted LEDs are seen in Node 3.

The Cases of Gas
In each room, the Gas level is being monitored such that the program of ANN examine if there is a state of fire when the Gas reading exceeds a specific threshold.In this case, SMS message will be sent to the owner via android program or to the Fire Station near the homeowner as you can see in figure (12).
Figure (12) shows that when the Gas in one of the room is above the specific value (normal), the Temperature is checked by the ANN program such that if the value of temperature exceeds 60 o , then a Fire case is happened, otherwise if the level of Temperature is normal or below 60 o , then a Gas case exist.From figure (13-a), the android mobile application pointed a red color in the screen of mobile if there is a motion in room 1, while in the second room there is no motion.Similarly, Figure (13-b) states a motion in room 2; while Figure (13-c) shows the response of the system when there is a motion in both rooms.
In the paper of [Jivani, 2014] you can see that a voice control massage sending by the application of android mobile inverter to the home GSM system for controlling the appliances of homeowner manually.For a comparison with the system proposed in this project, the proposed system controls all appliances of the home by a smart way automatically because of utilizing the intelligent algorithm (ANN) as depicted in the results.
The project of [Kumar and Vasu, 2015] control through internet functions like (smoke detection, light controlling, and temperature sensing) through an android mobile so that the main screen consist of a list of almost functions but without movement detection.To control them, the user can select any one, and he can if he wish disable or enable the intended device.As compared with the system proposed in this work, the proposed system has good security because the existing of the movement sensor, which can detect any movement in each room.In addition, it is smarter so that if there are two or three cases at time, then you can see the system gives a suitable decision for it like the case of fire that depicted in section (4.5).
78 different cases trained by ANN Delta Learning Rule so that if any case happened, then the case will manipulate and the decision will taken quickly.

Conclusion
In this paper, an automated home system was proposed and implemented using ANN and wireless sensing network.It composed of some sensors, ZigBee network, Arduino, android mobile and Wi-Fi shield.Android mobile phone is use for controlling and monitoring the home.Furthermore it is utilize Wi-Fi for system connection.Light, doors and windows, temperature, also movement, and fire detection and movement are auto controlled by the Android application which utilizing ANN to take the decision automatically for each state.Different mobiles are used to test the Android program.It is found that it works fine in each of them, also most cases are trained and tested.Android and Arduino platforms that used by the proposed system is considered as a Free Open Source Software such that their price is very suitable for a common person and the implantation cost is low.
With the help of ANN Learning Rule, the system proposed here manipulate the interred data (sensor readings) and gives the suitable decision for each case automatically.Fortunately, it is found that the system can give a decision despite of there is more than one case at time as the Fire case, so it become smarter.

Future Works
You can improve the system by using some of the following aspects: 1) To improve the security of the system IP cameras can use, and through the web you can access these cameras.2) Beagle bone or Raspberry pi can be use instead of Arduino to make the manipulation process faster.
Figure (2) a) board of Arduino UNO b) board of Arduino ATmega2560 c) Module of XBee series 2. d) shield of wireless, SD e) shield of Arduino, Wi-Fi.
Figure (8)   shows the GUI of the two rooms for normal case.

Figure
Figure (8) Normal Case Figure (10) shows these commend as a red LED light in both Node 2, and Node 3 The detector of Motion case Ultrasonic and PIR sensors are used for motion detection in the proposed system by measuring the range (distance) for windows and doors and check if they are open or closed; also, they monitor any movement in each room.When the homeowner is out of his home, ANN program also manipulate these data to accomplish the home security by sending an SMS messages to him and using an alarm system.Figure (13) shows the tested cases of the two rooms.