You are on page 1of 4

Fuzzy Logic Based Algorithm for Context Awareness

in loT for Smart Home Environment

Arpit Patel Prof. Tushar A. Champaneria


Computer Engineering Department Computer Engineering Department
L.D. College of Engineering L.D. College of Engineering
Ahmedabad, India Ahmedabad, India
arpitpateI4232@gmail .com tushar.1985@gmail.com

Abstract- In Internet of Things, Context Awareness plays Here in this paper we had used the triangular membership
important role. Also it is important in Smart home environment function as the input variable of the fuzzy inference system.
where data from various sensors and input from user or user Further, this input is used in the fuzzy IF THEN rules, with the
action must be interpreted and corresponding commands to help of it we have produced a decision making function, which
actuators must be generated. There are various approaches produces some output based on the input given. Now this
available for context awareness, like supervised, unsupervised, output need to be converted into crisp set with the help of
rule based systems etc. But, these approaches have their own pros Defuzzification, where we have used the centroid function of
and cons depending on the need of an application. In the Defuzzification.
proposed approach we discuss the fuzzy logic based algorithm
with architecture. Various Smart home scenarios are identified This paper is further organized as, Section II, discuss about
and implemented. Two scenarios are discussed in detail by Literature survey of Middleware and Context Awareness
applying proposed algorithm. For the performance measurement Architectures that are already developed, Section III discuss
of proposed algorithm two parameters Response time and about the implementation of Proposed work, Next section
Accuracy are considered. Our implementation results show discuss about Result and then in next section we will discuss
reasonable improvement in response time and accuracy, while about future work needed to further improve this architecture
keeping our approach light weight on resources. and at last we conclude the research.
Keywords- Internet of Things, Context Awareness, Smart
Home, middleware. II. LITERATURE SURVEY
In this section, we will discuss about various approaches
1. INTRODUCTION proposed earlier, that are describing the concept of context
Internet of Things is a concept to connect each and every awareness. As per [2] the context awareness is defined as "A
object with each other and make them communicate with each system is context-aware if it uses context to provide relevant
other with the help of internet and many other technologies. information and/or services to the user, where relevancy
The devices should be ubiquitous, self-discoverable and self- depends on the user's task".
communicable[ I]. In loT, the important concept is of achieving
context awareness, where the system will react according to the
input given by the user and to produce suitable action, which is
convenient to user. Based on this concept we propose the

t._+1
architecture of context awareness in the middleware portion of Di!.~O" Conte ..
Modellnt

the loT, where we will apply fuzzy logic to achieve required


smartness and to have convenient output from the system.
Fuzzy Logic helps human brains a systematic calculus to ..........
deal with imprecise and incomplete sensory information Fig 1 Context Awareness Life Cycle[2]
linguistically, by performing numerical computations using
The paper also discuss about the context awareness life cycle
membership functions. In fuzzy logic we use fuzzy inference
as shown in Fig I, which consist of the four phase namely,
system as a procedure, in which the input from sensors is
converted in to fuzzy sets with the help of membership Context Acquisition phase where the data is acquire from the
functions like Triangular, Trapezoidal, Gaussian, sigmoidal etc. physical to virtual sensors, Context Modeling phase where the
We use this function for Fuzzy Reasoning procedure, in which collected data is reprsented so that it can be understood easily,
we use various rules called "Fuzzy IF- THEN Rules" to produce Context Reasoning phase where the dta is processed to acquire
the output, which we have to defuzzify it with the help of high level contex information from low level raw data, and at
various methods like Centroid, SOM, MOM, LOM etc. to use last Context dissemination phase where the high level and low
it further to perform various actions ofIoT. level information is distributed among various consumer who

978-1-5090-2597-8/16/$31.00 ©2016 IEEE 1057


needs this information. So context Awareness is always guarantees to have a better accuracy and response time with
dicussed based on this life cycle to achieve proper results. the requirement ofless number of processes.
Now we will discuss about various architecture of Context
A. Proposed Architecturefor Context Awareness in smart
Awareness in the fo llowing paragraph.
home scenario
The approach shown in [3] is unsupervised based method,
where the middleware contains the appliance controller (take Fig 2 shows the architecture of Smart home environment
charge of communication between appliance and middleware) ; and its components. Proposed architecture is discussed in detail
a context aware agent (Use OSGi as a framework of the home with top down approach. The top level is device layer which
network) and a scalable browser (recognize properties of all consists of the types of devices from device I to N where we
have various sensors, AC, Heater, Fan, Light, Kitchen
rendering and measure their screen size). From this we can
Appliances etc. Device layer sends raw data to the next level
conclude that, context aware agent work on six basic data i.e.
and accepts commands from context detection unit. Then the
pulse, body temperature, facial expression, room temperature, next level consists of an agent which will check whether the
time, and location. These six commands construct the context data of device is available or system needs to gather the
model used by the context manager. The result here shows that information for that device like device id, device name, room
the pattern of individual preference can be effectively id, input range and type of device i.e. sensor or actuator.
evaluated by adopting proposed model. But this approach is Further, next level has a context detection and appropriate
difficult to implement for all kind of devices. action module whose work is to generate the context based on
In another approach shown in [4] which is a kind of the fuzzy logic and accordingly it will give a notification or
supervised based approach. It discusses about the activity command to the device layer about what to do in terms of its
recognition(AR) as an essential part for the context-inference operation and to users.
model in the smart home environment, because the user
activity monitoring generates lots of data and from that data
--------------------------------1
I laver(Sensorsand IDevice Actuators}

we have to find the context aware information and decide


about what to perform on various kind of activity. So to
: D[eVkjl
1 __ -
]~ t Vke : ] [ De~t ] . [DeVki n ]i
achieve context awareness, we can use semi supervised
learning method, which require small instance to label activity
or no new instance required to label for small change in habit,
hence the effort require in labeling the habit for generating the
pattern of human activity is less, so this approach is accepted.

.
But, due to no change in instance for some amount of time
'---------
1
may lead to poor result.
I IUd:-bn.me."type:1\.;;;,e
-oi~ ~. _
The problem with above architectures is that they become I Input Require, Depid
heavy weight for smart home environment in number of I
I
processes. The advantages and disadvantages of various I
I Conte... Detection
methods are shown in Table I. I And Appropri.te
I _~ I
L ______ ________ ________________ J
TABLE l. COMPARISON OF CONTEXT AWRENESS METHODS[2]
Fig 2 Proposed Architecture
Advantage Disadvantage
Gives Precise Re~ult It is having a long B. Fuzzy Logic based Context Aware Algorithm
. d
S upervlse with the help of functIOn . . . d d'
d . d fr . . trammg perlO an IS
dertlve
a a.
om trammg hard to understand.
Fuzzy Logic Based Algorithm
It ha~ no edrrors due to no it is complex and difficult
. trammg ata so no . Input: Did, Rid, Device Value.
Unsupervised 'bl ' . to validate and outcome
POSSI e outcomes. d ' bl Output: On, Off, Set Value
defined. IS unpre Icta e.
I: Starting the begin timer as TS;
It is the simplest and Mistakes can be made
R I straightforward method during writing the rule 2: Get the values from the Device:
u es with less resource and no method of
3: [INITIALIZE]
requirement. validation defined.
Allow Complex Data should be in a OWL 4: vall .... Did;
Ontology reasoning and file format and also this
5: vaI2 .... Rid;
Based representation with more method has low
meaningful results. performance. 6: val3 .... Device Value;
Probabilit It . allows combine It reasons numerical 7: Get Information from Database (DBl):
b d Y eVidence and can handle values only and should
ase uncertain situations. know probabilities. 8: IF
Simple and easy to
. I Prone to have a manual 9: FOUND val2, val3 + - False;
. exten d reqUire ess .
Fuzzy LogiC ' d t d entry mistakes from 10: THEN
resource an represen e develo ers
In natturallanguage. p
II: Write (,Device not Found');

III. PROPOSED WORK 12: Wait: For user input and store to database

In the previous section we have discussed about various 13 : Return (Rid, Did, Dname, Type, Range, Input
approaches of context awareness and also seen the advantages Require) from Room and Device table
and disadvantages of it. Now we will discuss the Fuzzy logic 14: ELSE IF
based approach to achieve context awareness in smart home IS: FOUND val2, val3 +-True;
environment. The reason for choosing the Fuzzy logic is that it

1058 20161££E Region 10 Conference (T£NCON) - Proceedings of the International Conference


18: THEN Retum (Dna me, Type, Range, Input Require) Here Fig 4 shows the PIR scenario where person is moving
from Room and Device table between the rooms, the door and the light are opening (ON)
20: Send this data to the Context detection module
and closing(OFF) automatically by looking at intensity of light
in the room. Similarly, in Fig 5 while detecting the pressure on
21 : Fetch the database DB I: the bed and while looking at the time, the morning schedule is
22: Return (Depid) from the Dependency table eastablished and various activities like tum on geyser, coffee
23: Apply the Fuzzy Logic Procedure: machine etc are done based on the user movement and activity.
Likewise many other scenaraios are eatablished using this
24: A. Define the Linguistic Variables and
smart home and we can apply our architecture in that and
terms (Initiali ze) achieve some context awarenes based on that.
25: B. Construct Membership function (Initialize)
26: C. Convert Crisp input data into Fuzzy values using
Membership function (Fuzzification)
27: D. PROC I to VIlI (Inference)
28: E. GOTO PROC (Inference)
29: F. Combine a Result and convert output data to non-
fuzzy values (Defuzzification)
30: Based on Output from Scenario generate the Gion Input for
Apply1na
lOIJc
Command for the Device:
3 I: Retum (VaI4) from database DBI
32: SEND vaI2~ vaI4;

33: End of timer and store the value in TF;


34: Total Time (TR) = TF - TS; Fig 4 Motion Detection
35: Exit; For the implementation of above algorithm, we have used
raspberry pi B+ model for controlling whole environment. The
programming language is python and database is mongo db for
C. Implementation Details storing data.
Implementation of our architecture is based on smart home In these scenarios the Raspberry Pi, takes the input from the
layout shown in Fig 3. Various scenarios are discussed below sensors and gives output to the actuators like in Fig 5 it takes
namely; PIR based Scenario, where sensor detects the input from Door, PIR and Intensify sensors and give output to
presence of person and accordingly tum ON/OFF device . User the light to tum ON and OFF.
activity based Scenario, where based on time and bed sensor
data, the web service is being called automatically and the to-
do list fetched from it and when the user is doing exercise
Geyser and Coffee machine will tum on automatically.
Sprinkler based Scenario, where based on soil moisture and
environment sensor we tum ON/OFF a sprinkler. Cleaning
based Scenario, where it will detect the presence of human and
door lock and according to that start cleaning machine.
Temperature based Scenario, where based on the environment Gtvelnput
FOf Applyin,
temperature and room temperature it will start AC, Heater or u.a;<
Fan inside the room. In this paper we have discussed only
about two scenarios i.e. PIR based and user activity based
scenarios for understanding the Architecture and Algorithm.

PIR Bed and its sensors Bed and Its sensors Fig 5 Morning Schedule
Temp
TV Set
TV Set lilhts
IV. RESULTS
Bed Room 2 Bed Room 3 The result of the research proposal is taken by
Kitchen lights
considering all the 6 scenarios of Smart Home discussed in
Temp
Appliances section III-C. We are considering response time and accuracy


Temp
PIR
eater
PIR .
Heate(-
PIR . as the two parameters for the measurement of our proposed
Uahts architecture. The accuracy is calculated after running the
AC Temp lights AC
algorithm for each scenario 1000 times and then the final
graph is created. Response time is also calculated in the

EJ
TV Set PIR Bed Room 1 similar way. Also, we have used traingular MF and the
Heater TV Set centroid defuzzification method to produce the above result.
The two graphs (Fig 7 and Fig 8) shows the overall accuracy
Temp and response time, of our architecture for each Scenarios.
Intensity Bed and its sensors
Individually, the result is calculated by measuring the two
Fig 3 Smart Home Layout
parameters for each cycle of the Algorithm, which gives the
values in particular range. After that the average of all that
result is calculated and then the above graphs are prepared.
20161£££ Region 10 Conference (T£NCON) - Proceedings of the International Conference 1059
By seeing this graph we can see that the overall accuracy millisecond compare to other architectures and the accuracy
gained by this architecture is around 95.14 percent. The achieved is 95.14%. As in loT Response time is very crucial
Response time for the same is achieved around 6.98 as user is moving continuously and we have to perform right
millisecond. activity at right time. The proposed architecture is lighter in
Average Accuracy for all Scenarios weight in the sense of number of process, time taken for the

1.. .
completion of one cycle is very optimum as shown in Fig 9.

FUTURE WORK
, The above implementation is based on the Fuzzy Logic based

l
""
. Algorithm. Where we have achieved the accuracy of 95 .14%
and the response time of 6.98 ms. but still we can improve it
e:~ ..... - AvcrlJC Accancy by combining this technique with other Context Awareness
::t
~
~
I ...
methods. Furthermore, CPU utilization can be taken as a
a:. parameter for evaluating above algorithm.
~ .. ,
~
</..t,/ ,.
../1'/
l .. / ' ../ ' /)
.
.t-'
~.. ~"

Scenari os

REFERENCES
Fig 7 Result of Accuracy

Av~ ra,~ R~s ponse Time for all Scenarios [1 ] A. Whitmore, A. Agarwal, and L. Da Xu, 'The
u Internet of Things : A survey of topics and trends," In!
Syst. Front., vol. 17, no. 2, pp. 261 - 274, 2015 .
1'0 [2] C. Perera, A. Zaslavsky, P. Christen, and D.
Georgakopoulos, "Context aware computing for the
¥
¥ 0
internet of things: Asurvey," IEEE Communication

l .
1= . A, n ."lt~vTi_
Survey Tutorials, vol. 16, no. I, pp. 41~54, 2014.

'"
&'.
. [3] 1. Choi, D.Shin, and D. Shin, "Research and
implementation of the context-aware middleware for
controlling home appliances," IEEE Trans. Consum.
j 0/, .l' .i' /-1 ~.,. ./ Electron., vol. 51 , no. 1,pp. 301- 306, 2005.
/1 ./ ./" [4] C. L. Wu, Y. S. Tseng, and L. C. Fu, "Spatio-temporal
Sc ~na r i o $ feature enhanced semi-supervised adaptation for
Fig 8 Result of Response Time activity recognition in loT -based context-aware smart
homes," Proc. - 2013 IEEE Int. Con! Green Comput.
Commun. IEEE Internet Things IEEE Cyber, Phys.
Soc. Comput. GreenCom-iThings-CPSCom 2013 , pp.
460-467,2013 .

[5] "Python Programming Language." [Online].


Available:
https:llen.wikipedia.org/wiki/Python_{programming_ l
anguage).

[6] "Mongo DB Database." [Online]. Available :


https:llen.wikipedia.org/wikilMongoDB

Fig 9 Time taken to complete one cycle

CONSLUSION
Since, other approaches of context awareness methods like
supervised and unsupervised learning have more accuracy
than fuzzy logic, but they lack in the response time. We can
say that our proposed architecture, which is based on the fuzzy
logic, has gained lot of reduction in the response time of 6.98

1060 20161££E Region 10 Conference (T£NCON) - Proceedings of the International Conference

You might also like