Wireless Sensor Network, 2009, 1, 365-369
doi:10.4236/wsn.2009.15045 Published Online December 2009 (http://www.scirp.org/journal/wsn).
Copyright © 2009 SciRes. WSN
An Application of Context Middleware Based on Fuzzy
Logic for Wireless Sensor Networks
Ye NING1,2, Ruchuan WANG2,3, Shouming MA2, Zh ili WANG1
1Department of Information Science, Nanjing College for Population Program Management, Nanjing, China
2Institute of Computer Science, Nanjing University of Post and Telecommunications, Nanjing, China
3State Key Laboratory for Novel Software Technology, Nanjing University, Nanjing, China
Email: cathery163@163.com
Received May 25, 2009; revised July 22, 2009; a ccepted July 25, 2009
The research of context-aware computing based on wireless sensor network (WSN) aims at intelligently
connecting computers, users, and environment. So its application system should be flexibly adaptable to dy-
namic changes of context and application requirements and proactively provides the information satisfied
with current context for users. The middleware can be very effective to provide the support runtime services
for context-aware computing. In this paper we propose middleware architecture for context processing. This
architecture is based on fuzzy logic control (FLC) system for context reasoning and sensor fusion. We pro-
pose a formal context representation model in which a user’s context is described by a set of roles and rela-
tions correspond to a context space. A middleware prototype has been developed, which detect tourist’
physical context and provide reminding. The experiments prove that the model and approach proposed are
Keywords: WSN, Context-Aware, Middleware, FLC, Pervasive Computing
1. Introduction
Context-aware has re cently beco me a hot topic in the areas
of pervasive computing, which was introduced by Schilit
and Theimer [1]. With the development of wireless sen sor
networks (WSNs), the space and physical context informa-
tion can be obtained by a large number of sensor nodes.
How to intelligently i ntegrating multiple sensors and sensor
fusion is a crucial technology for context processing in
To avoid increasing complexity and allow the users is to
concentrate on his tasks, applications and services must be
aware of their contexts and automatically adapt to their
changing contexts-known as context-awareness.
In most situations, humans react opportunistically,
switching among a set of possible goals, abandoning and
adding new goals in response to events and opportunities.
One of the most difficult challenges in designing context
aware systems is to recognize and allow for such unpre-
dictable behavior [2]. In this respect, middleware can be
very effective to provide the support if they can reduce the
effort required to develop distributed software and runtime
services for applications with the abovementioned charac-
teristics, in addition to providing the normal services, such
as interoperability, location transparency, naming service,
etc [3].
In this paper, we present the design and implementation
of a middleware approach for context-awareness, and
adopted fuzzy logic [4] as an intelligent reasoning method
for selecting data dissemination protocols in the design of
the decision mechanism.
The remainder of the paper continues as fo llows: in Sec-
tion 2 discusses related work and main problem. In Section
3 we describe our formal context representation model and
the structure of FLC system for Context processing. Sec-
tion 4 describes an application we have developed for our
middleware prototype. Finally, the paper ends with conclu-
sion in Section 5.
2. Relate Work and Problem Formulation
We are not aware of any integrated middleware platform
that aims to achieve all of the goals described above.
As early as in 2002, Huadong Wu etc. proposed a con-
textual information model and built a generalize-able sen-
sor fusion software architecture that can support mapping
sensors’ raw output data into the contextual information
hierarchy [5].
The Gaia project [6] developed at the University of Illi-
nois is a distributed middleware infrastructure that provides
support for ubiquitous computing.
The EasyLiving project [7] from Microsoft focuses on
development of an architecture and technologies for intel-
lige nt en vir onm en t s.
Work at Illinois has developed the Universal Interoper-
able Core (UIC) which is a reflective middleware platform
designed for handheld devices [8].
Recent research work has focused on middleware exten-
sions for pervasive computing by standardizing on web
services and service discover-oriented technology [9].
To sum up, it is important that middleware for con-
text-aware application should be able to fulfill the follow-
ing functionalities and objectives.
1) The middleware architecture should be modular and
2) The middleware should be based on a service-oriented
architecture, in which ea ch application and device is repre-
sented as a service entity.
Based on the above-mentioned study, we developed a
middleware for pervasive computing, which adopted fuzzy
logic as context processing method.
3. Fuzzy Logic Based Context Processing
3.1. A Formal Context Representation Model
We use a context space theory model shown in [10] for
model fundamental nature of context and enable context
and situation awareness for context processing. Our con-
text model gives a common representation for context
that all entities in the environment use of pervasive
computing. Instead, it provides a common base on which
various reasoning mechanisms can be specified to handle
Definition 1:
We define a attribute value as any type of data that is
associated with Contextual information, include physical
contexts, environmental contexts, informational contexts,
personal contexts, social contexts, application contexts
and system contexts [11].
Definition 2:
For a context state, defined over a
collection of N attribute-values, where each value
corresponds to an attribute’s value at time t.
),,( 21 t
Definition 3:
Let be a context space in an environment of per-
vasive computing, describes the application’s current
state in relation to chosen context. In our model, context
spaces are represented as first-order calculus. The basic
model has the form of predicate(subject,Catt), in which
-: set of the expression entity of context
information, e.g. visitor, locatio n, etc.
-: set of predicate name, e.g. is located
in, has status, etc.
-: set of all values of context state in , e.g.
warm, cold, open, close, empty, etc.
For example, Location (Marry, laboratory) means
Marry is located in the laboratory.
The basic context model can be extended to form a set
of contexts by combining the predicate and Boolean al-
gebra (union, intersection and comple ment).
For example, y,90)Pluse(Marry,38)ature(MarrBodyTemper repre-
sents physical signs about Marry.
3.2. Fuzzy Logic-Based Context Processing
Fuzzy logic was proposed by Lotfi A. Zaheh in 1965 [12]
to emulate the way that the human brain processes un-
certainty, uncertainty, imprecision, and vagueness. Fuzzy
logic is suitable for context management because it is
capable of processing imprecise and unreliable informa-
tion coming from pervasive computing, and it can de-
scribe a problem in a common sense format in which
expert knowledge, instead of differential equations, can
be applied [13].
For , be an input is applied to a FLC
system, the inference engine computes the output set
corresponding to each rule. On analyzing the context
processing of various potential services, we use singleton
fuzzification and “IF-THEN” rules of form [14].
C,  ii aa
Rl: IF is and is and and is ,
THEN y is .
Assuming singleton fuzzification, when an input
is applied, the degree of firing corre-
sponding to lth rule is computed as
)(T)(**)(*)( '
121 i
FFF aaaa l
* and T both indicate the chosen t-norm. In this paper,
we focus on the height defuzzifier and used trapezoidal
membership ship functions to represent low, high, very
strong, very weak to represent moderate, medium, strong,
and weak.
In this paper, we are primarily interested in developing
middleware based on the structure of FLC mentioned
above. We design a FLC system for travels services,
which is one of component in our pervasive computing
prototype Tourist Reminder.
The FLC system in this paper receives context infor-
mation from sensor equipments as the inputs of the FLC
and the fuzzification module converts inputs into fuzzy
linguisti c vari able inputs.
Copyright © 2009 SciRes. WSN
On analyzing the data requirements of travels services,
four linguistic variables were defined, representing the
physical sign of tourist. The membership functions of
these input parameters of the fuzzy logic are illu strated in
Figure 1.These member functions have been determined
based on the simulation result. The labels in the fuzzy
variables are presented as follows.
Age= {infant, youth, midage, old};
BodyTemp= {Normal};
Pulse= {t1, t2, t3, t4}; //different intervals of nor-
mal pulse
R= {N (Normal), L (Lower), H (Higher)};// degree
of reminding for physical signs
Based on above fuzzy variables, we can define
fuzzy IF-THEN rules such as follows.
1) If (Age is infant) and (Pulse is t1) then (R is N)
2) If (Age is infant) and (Pulse is t2) then (R is H)
3) If (Age is infant) and (Pulse is t3) then (R is H)
4) If (Age is infant) and (Pulse is t4) then (R is H)……
A sample fuzzy calculation at a value of context in-
formation point is described in Figure 2.
4. Fuzzy Middleware Protoype Implementation
We have evaluated the context processing mechanism
that based on fuzzy logic system by developing a simple
prototype application called Tourist Reminder. As Figure
3 shows, we use medical sensors (body temperature sen-
sor, pulse sensor and blood oxygen sensor, etc) and
GPS/RFID in detecting tourist’s physical signs/location
anywhere and anytime. All sensor data are transmitted by
ZigBee wireless sensor nodes to the middleware running
on PC or PDA for analyzing and providing reminding
message to tourist.
Figure 1. Membership functions for input context (physical
Figure 2. A sample fuzzy calculations.
Figure 3. The process of prototype application.
4.1. Middleware Architecture
To create Tourist Reminder, we developed generic ref-
erence architecture applicable to pervasive computing
space. As Figure 4 shows, the middleware contains
separate physical, sensor platform, service, knowledge,
context management, and application layers. Physical
Layer: contains a variety of sensors and actuators which
monitor and gather context information about the perva-
sive environment.
Context Acquire Layer: integrates the sensors and
actuators from the layer beneath and export their service
representations to the layers abov e, which includes query
processing component that can process filters and queries
for sensor readings sent to it from the query processor in
the service layer.
Context service layer: contains the Open Services
Gateway Initiative (OSGi) framework, which maintains
leases of activated services. The layer provides the ser-
vice discovery, compositio n, and invocation mechanisms
for applications to locate and make use of particular
Copyright © 2009 SciRes. WSN
Figure 4.The architecture of middleware.
(a) UbiCell node
(b) physical sign sensors and PC
Figure 5. The hardware of Tourist Reminder.
sensors or actuators. It holds the registry of the software
service representation of all sensors and actuators con-
nected to the hardware nodes and FLC system as infer-
ence engine.
Context application layer: sits at the top and con-
sists of the execution environment that provides an API
to access and control sensors, actuators, and other ser-
vices. It contains a service authoring tool to enable rapid
and efficient development and deployment of services
and applications.
4.2. Middleware Prototype Implement
We develop sensor node called UbiCell[15], which in-
grate models of GPS and physical sign sensors. The
hardware of middleware prototype is composed of PC,
UbiCell and sink nodes (Figure 5).
In this project, the develop platform of software was
based on J2sdk1.4+Ecli pse3.2.
As shows in Figure 6, the main function of Tourist
Reminder include subscribed service, query service,
message reminding, GIS location, etc.
Client as the user of tourist service subscribes the
services to Server (middleware) according to the ID
about tourist.
After sampling and aggregating the physical con-
text about subscribed tourist, Server realizes reasoning
based FLC system and returns the relevant messages of
services (reminding/query).
Figure 7 is one of the capture images about sampling
data of body temperature. As shows in Figure 7, the
trend of data is stability.
5. Conclusions
Context-aware computing has been a key issue for
pervasive computing based on WSN. In a pervasive
computing environment, Services should be intelligent
Figure 6. The interface of Tourist Remind er.
Copyright © 2009 SciRes. WSN
Copyright © 2009 SciRes. WSN
Figure 7. The capture image of sampling data.
enough to understand the real world. Our study in this
paper demonstrates that fuzzy logic based middleware is
feasible for facilitate context processing. A key feature of
our model is the presence of FLC based context archi-
The work of this paper is a part of our ongoing mid-
dleware prototype for pervasive computing which pro-
vides the reminding service to tourist. Now we furthering
work are to apply in practice trade.
6. Acknowledgements
This work is supported by the National Natural Science
Foundation of China (No. 60773041), Science Founda-
tion of Jiangsu High School (No. 09KJB510020) and
sponsored by Qing Lan Project.
7. References
[1] B. Schilit and M. Theimer, “Disseminating active map
information to mobile hosts,” IEEE Network, Vol. 8, No.
5, pp. 22–32, 1994.
[2] P. Dourish, “What we talk about when we talk about
context,” Personal and Ubiquitous Computing, Vol. 8, No.
1, pp. 19–30, 2004.
[3] A. Helal, “Programming pervasive spaces,” The Stan-
dards and Emerging Technologies Department, IEEE
Pervasive Computi ng magaz ine, Sumi He lal, Dept. E ditor,
Vol. 4, No. 1, January–March 2005.
[4] H. J. Zimmermann, “Fuzzy sets theory and its applica-
tions,” Second, revised edition, Kluwer Academic Pub-
lishers, 1991.
[5] H. Wu, M. Siegel, and S. Ablay, “Sensor fusion for con-
text understanding,” Instrumentation and Measurement
Technology Conference, IMTC/2002, Proceedings of the
19th IEEE, Vol. 1, pp. 13–17, May 2002.
[6] M. Roman, C. K. H., R. Cerqueira, et al, “Gaia: A mid-
dleware infrastructure to enable active spaces,” IEEE
Pervasive Computing, pp. 74–83, 2002.
[7] Microsoft Research, “Easy living,” 2009,
[8] M. Roman, F. Kon, and R. H. Campbell, “Reflective
middleware: From your desk to your hand,” IEEE DS
Online (Special Issue on Reflective Middleware), 2001.
[9] S. Ou and K. Yang, “An effective offloading middleware
for pervasive services on mobile devices,” Pervasive and
Mobile Computing, Vol. 3, No. 4, pp. 362–385, 2007.
[10] A. Padovitz, et al, “An approach to data fusion for con-
text awareness,” Fifth International Conference on Mod-
elling and Using Context, CONTEXT’05, Paris, France,
July 2005.
[11] M. Korkea-aho, “Context-aware applications survey,” 2009,
http://www.hut.fi/~mkorkeaa/doc/cont ext-aw ar e.htm l.
[12] L. A. Zadeh, Fuzzy sets, Information and Control, pp.
338–353, 1965.
[13] M. Marin-Perianu, C. Lombriser, et al, “Distributed ac-
tivity recognition with fuzzy enabled wireless sensor
networks,” Technical Report TRCTIT-07-68, Enschede,
September 2007.
[14] E. Hisdal, “The IF THEN ELSE statement and inter-
val-valued fuzzy sets of higher type,” International Jour-
nal Man-Machine Studies, Vol. 35, pp. 385–455, 1981.
[15] Wireless Sensor Network Research Center of Nanjing
University of Post and Telecommunications, “UbiCell
product manuals,” 2009, http://www.wsns.net.cn.