<figure><img src="image_1.png" /></figure>

HAL
open science

# Design of Wireless Sensor Network Middleware for Agricultural Applications

Liang Zhao, Liyuan He, Xing Jin, Wenjun Yu

► To cite this version:

Liang Zhao, Liyuan He, Xing Jin, Wenjun Yu. Design of Wireless Sensor Network Middleware for Agricultural Applications. 6th Computer and Computing Technologies in Agriculture (CCTA), Oct 2012, Zhangjiajie, China. pp.270-279, 10.1007/978-3-642-36137-1_33. hal-01348241

HAL Id: hal-01348241

https://inria.hal.science/hal-01348241

Submitted on 22 Jul 2016

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_2.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
Design of Wireless Sensor Network Middleware for
Agricultural Applications

Liang Zhao<sup>1,2</sup>, Liyuan He<sup>2</sup>, Xing Jin<sup>1</sup>, Wenjun Yu<sup>1</sup>

<sup>1</sup>College of Science, Huazhong Agricultural University, Wuhan 430070, People's Republic
of China

<sup>2</sup>Resources and Environmental Science, Huazhong Agricultural University, Wuhan 430070,
People's Republic of China

{Liang Zhao, Liyuan He, Xing Jin, Wenjun Yu}, zhaoliang323@mail.hzau.edu.cn

**Abstract.** Typical WSN(Wireless Sensor Network) applications in precision agriculture include production process management, plant growth optimization, farmland monitoring and so on. Middleware, which can connect hardware, applications, and enterprise systems, is required to construct ubiquitous agricultural environment combining WSN technology with different agricultural applications, but there have been insufficient studies in the field of agricultural-oriented WSN middleware compared to other industries. This paper proposes a middleware to process data collected from agricultural environment by applying WSN technology, analyzes the data and standardizes different data forms, and provides intelligent diagnosis service and event service. One of the advantages of the proposed middleware is to build a model library which will guide the agriculture production process, such as irrigation control and disease prevention. In addition, a web-based remote login is provided to all users around the world to browse agricultural environmental parameters and to reference for intelligent decision.

**Key words:** WSN; Agricultural application; Middleware; Intelligent diagnosis; Web service
# 1 Introduction

WSN technology is increasingly common in all sectors because of its small size node and low cost advantages. Typical applications include agricultural production process management, precision agriculture, optimization of plant growth, farmland monitoring and so on [1]. In these applications, the acquisition of farmland environmental parameters, such as air temperature, humidity, light intensity, wind speed, soil moisture information, are important foundation of the practice of agriculture and farmland information management.

Due to the inherent diversity, variability, dispersion and continuity of farmland environmental parameters, there are some difficulties to get these parameters continuously and quickly, the same to farmland managers and agricultural decision-makers to make accurate decisions timely. With the maturity and popularity of WSN technology, a large number of heterogeneous wireless sensor nodes deployed in the fields, which can be organized into a multi-hop intelligent network to realize the distributed farmland environmental information acquisition timely and continuously.

While WSN can solve the problem of data acquisition, but there are still several contradictions in most applications: First, the data collection and storage of heterogeneous sensor node; Second, how to convert these raw data into meaningful information and decision-making; Third, System maintenance, deployment and development of WSN applications subject to specific environmental constraints, there is no universal solution mode [2]. To solve these problems, the WSN middleware has become a research hotspot in recent years, but the study of WSN middleware for agricultural applications is less due to its specific application-oriented, which makes research more difficult.

# 2 WSN middleware research review

WSN middleware is a software layer between sensors, gateways and application systems which support the flexible integration of them, in addition to providing services such as distributed computing, network, a main purpose is to shield the heterogeneity of the underlying components and the complexity of the distributed
environment, and it's a better solution to the interoperability of applications across different platforms [3],[4],[5].

According to the location in the system, WSN middleware can be divided into the node-side model, server-side mode and mixed mode [2]. Simultaneously, according to the task and design methods, WSN middleware is divided into virtual machine, database, tuple space, event-driven and adaptive middleware [6]. Such as Mate [7], Impala [8], and Agilla [9], all belong to the node-side mode and virtual machine-based middleware. Cougar [10], SINA [11], and MiLAN[12] belong to server-side mode, is also database-based middleware. TinyDB [13] belongs to the database middleware due to its core function, including the COSMOS [14] and DSWare [15] are typical mixed-mode.

Many scholars study WSN middleware for different application areas to provide different services and different architectures[16],[17],[18]. Such as the SOM service-oriented middleware architecture, which consists of the user application layer, the sink node level and the sensor node layer, each provides different services. MiSense, is a service-oriented component-based middleware, which can support different performance needs of distributed sensor applications. In the literature [2], a context-sensitive middleware for greenhouse was proposed, which made the interactions between user application services and the heterogeneous WSN more smoothly, handled sensor data more effectively and provided context-sensitive services more intelligently.

## 3 Architecture design of the proposed middleware

Agricultural application-oriented middleware(AAOM) systems can collect heterogeneous sensor data through gateways, such as light, humidity, soil moisture, temperature and so on, which are stored in database after pretreatment. At the same time, agricultural models and expert knowledge are stored in model database. Based on these data and knowledge, alert service, intelligent diagnosis-making service and feedback control can be conducted to guide agricultural production process. Users can access these services through Web interface, then let users control equipment and monitoring environment parameters manually or automatically more better. The system hierarchy is shown in Fig.1.
<figure><img src="image_3.png" /><figcaption>Fig. 1. Hierarchy chart of the proposed middleware</figcaption></figure>

The architecture of the middleware is divided into five layers, namely, the network interface layer, the data preprocessing layer, the data storage layer, the data processing layer, and the Web service interface layer.

The main function of network interface layer is to interact with the heterogeneous WSN, continuously access to sensor data, and at the same time, to manage functions for the states of various sensor networks.

At data preprocessing layer, there are two main functions, that is data filtering and data standardization. The data filtering does not store data delivered from the sensor network interface in the sensor data DB if the data is a duplicate, or stores data only when the data is changed. At the same time, the received sensor data may be not continuous or even missing because of nodes faulty or interference in the transmission process which will impact on the analysis of data. In order to reduce the impacts by the missing data, the corresponding missing value estimation algorithms are used to predict the missing data if the missing data is found when the sensor data is delivered from the data acquisition engine. Data standardization module is called to analyze the missing data and standardize the heterogeneous sensor data forms.

The data storage layer's main task is to store the heterogeneous sensor data preprocessed in data preprocessing layer and then be deposited in the sensor DB. In addition, crop models are stored in crop model DB. Each crop may have more than one crop model, and each model may have one or more rules. A data access controller is placed in the data storage layer to support various forms of queries.

The data process layer plays the role of providing various query processing functions for sensor data and crop model data. In data processing layer, there are two functions, including intelligent diagnosis and real-time alerting. An aggregation
engine is called to calculate sensor data, such as the average value, the maximum value and the minimum value during per aggregation cycle, which makes intelligent diagnosis possible by comparing with the rules, in advance to notify the intelligent service management module if it is identical or exceeds some threshold value. In addition, if the data entered has the same value as the level requested by an application, it notifies the real-time alerting service module to process the event services, otherwise the sensor data is stored into the sensor data DB through DB controller.

The Web service interface layer is an open interface, which is the top layer of the proposed middleware, supports connections with the outside users through browse and query processing. The specific data flow chart and structure of the proposed middleware is shown in Fig. 2.

<figure><img src="image_4.png" /><figcaption>Fig. 2. Specific data flow chart of the proposed middleware</figcaption></figure>
# 4 Implementation of the proposed middleware

## 4.1 Data requirement

The main data repository of the proposed middleware is RDBM and is built on MySQL. Fig.3 depicts the entity relationships of the RDBM, composed by 11 tables [19].

<figure><img src="image_5.png" /><figcaption>Fig. 3. Entity Relationship chart of the proposed middleware</figcaption></figure>

The main table is called Sensor and it is the most basic device generating data in the network. In the table, sensor type, the collected data value and others such as date, the remaining battery capacity and other information are stored. Each device is also classified according to a user specific management zone. This is accomplished by using the table Gateway, in which the field place stores a relevant location within the zone, and Plant table records some crop planted in this zone. At the same time, there are different types of sensors in one zone, all the sensor types information is stored in Sensortype table. Rules of operation are described through the table Rule, which contains trip point values that are used by the crop model and real-time alert. In addition, crop types are stored in Crop table. There are diagnosis results and real-time
alerts in diagnosis table and alarm record differently. The control information is
stored in control table if the devices in a zone needed feedback control. Z shows zero
or multiple relationship, P expresses one or multiple relationship, and FK is foreign
key of a table.

## 4.2 Intelligent Diagnosis Algorithm

The intelligent diagnosis engine is started to parse crop model and match the rules
according to real-time sensor data and the history data in sensor data DB. A diagnosis
is arrived if all the rules are successfully matched. Otherwise, the probability of
occurrence is calculated if there is a part of rules matched. Intelligent diagnosis
algorithm is as follows:

(1) Get data;

(2) Start intelligent diagnostic threads;

(3) Determine the current status of the environmental parameters based on the rules and sensor data;

(4) If The current state and the historical state are different then

(5) The current status is regarded as historical status, and current time is recorded;

(6) Else

(7) Compute the state duration and determine;

(8) If The duration reaches the prescribed time limit then

(9) Add a rule item;

(10) If All rules were met then

(11) Intelligent diagnosis is delivered;

(12) Else

(13) Probability of occurrence is computed;

(14) End if

(15) Else

(16) Go to (1)

(17) End if

(18) End if

A simple disease probability monitoring subsystem was developed, when the
real-time data is received, each rule is checked against the aggregated sensor data.
The example is based on rice blast prediction model. If the temperature has been within 10°C to 35°C, especially within 24 °C and 28 °C, and relative humidity has stayed above 90%, and if this situation lasts 6 to 8 hours, serious rice blast is easily to cause occurrence, and the rules have been consistently triggered throughout a certain number of days, a warning is generated.

## 4.3 Application of the Proposed Middleware

The proposed middleware in this paper was implemented with Java and JSP languages, and provides services through Web, users can remotely login to the system via internet, browse and query all the information, including historical sensor data and alerting information, real-time sensor data and alerting information, expert knowledge, intelligent diagnosis and other services. Fig. 4 shows the main functions' UI of the integrated system applying the proposed middleware. The system UI (a) shows historical sensor data that can be queried according to users' real requirement. (b) and (d) display real-time sensor data fluctuations such as illumination, temperature, humidity, etc. collected from the environment, at the same time, if an intelligent diagnosis or a real-time alerting is occurred, warning information is respectively displayed in the interface (b) and (d). In addition, (c) was implemented so as to allow managers to directly set a range of environmental parameters and event services so that it could provide intelligent diagnosis service such as automatic control of the environment, etc. and the notification service for dangerous situations.

<figure><img src="image_6.png" /><figcaption>(a) Historical data query</figcaption></figure>
<figure><img src="image_7.png" /><figcaption>(b) Real-time alerting</figcaption></figure>

<figure><img src="image_8.png" /><figcaption>(c) Environmental parameters setting</figcaption></figure>

<figure><img src="image_9.png" /><figcaption>(d) Real-time intelligent diagnosis</figcaption></figure>

<caption>Fig. 4. Main functions of the integrated system</caption>

## 5 conclusion

This paper proposed and developed an agricultural application-oriented middleware to efficiently process data collected from the environment applying WSN technologies and to implement combined services through Web, which was designed to bridge the
gap between sensors and intelligent diagnosis. It allows local and remote users to access the middleware through Web service to access sensor data and other information. The middleware runs a data analysis engine and performs intermediate level data processing, through which real-time alerting and intelligent diagnosis are provided. The test results showed that the middleware could access and process heterogeneous sensor data smoothly and provide more accurate intelligence services. In future studies, an expansion of different models is needed to enrich the model DB, which will make the middleware more versatile, and simultaneously expression of crop models and associated expert knowledge needs to be improved. In addition, as middleware, more perfect and optimization functions also needed to access wireless sensor network and network's nodes.

## References

1. W.S. Lee, V.Alchanatis, C.Yang, M.Hirafuji, D.Moshou, C.Li: Sensing Technologies for Precision Specialty Crop Production. Computers and Electronics in Agriculture. 74,2--33 (2010)

2. Jeonghwang, H., Hyun, Y.: Study on the Context-Aware Middleware for Ubiquitous Greenhouses Using Wireless Sensor Networks. Sensors. 11, 4539--4561 (2011)

3. Luca, M., Gian, P. P.:Middleware for Wireless Sensor Networks: An Outlook. Journal of Internet Service and Applications. 3,31--39(2012)

4. Soma, B., Munmun, S., Souvik, M., Subhajit, D.: A Survey of Middleware for Internet of Things. Communications in Computer and Information Science. 162, 288--296 (2011)

5. Mauri, K., Marko, H., Timo, D. H.: A Survey of Application Distribution in Wireless Sensor Networks. Journal on Wireless Communications and Networking. 5, 774--788 (2005)

6. Li Renfa, Wei Yehua, Fu Bin, Chen Hong long: A Review of Middleware for Wireless Sensor Networks. Journal of Computer Research and Development. 45(3),83--391 (2008).(in Chinese)

7. Philip, L., David C.: Maté: A Tiny Virtual Machine for Sensor Networks. In Proceedings of the 10th International Conference on Architectural Support for Programming Languages and Operating Systems, ACM New York, NY, USA. 85--95 (2002)

8. Ting Liu, Margaret, M.: Impala: A Middleware System for Managing Autonomic, Parallel Sensor Systems. In Proceedings of the 9th ACM SIGPLAN Symposium on Principles and Practice of Parallel Programming, New York, NY, USA. 38, 107--118 (2003)
9. Chen-Liang FOK, Gruia-Catalin ROMAN, Chen-Yang LU: Mobile Agent Middleware for Sensor Networks: An Application Case Study. In Proceedings of the 4th International Symposium on Information Processing in Sensor Networks (IPSN'05), Los Angeles, CA, USA. 382--387 (2005)

10. Yong, Y., Johannes, G.: The Cougar Approach to In-Network Query Processing in Sensor Networks. ACM SIGMOD Record. 31, 9--18 (2002)

11. Chavalit, S., Chaiporn, J., Chien-Chung Shen: Sensor Information Networking Architecture and Applications. Personal Communication, IEEE. 8, 52--59 (2001)

12. Heinzelman, W.B., Murphy, A. L., Carvalho, H. S., Perillo, M. A.: Middleware to Support Sensor Network Applications. Network, IEEE. 18, 6--14 (2004)

13. Samuel, R. M., Michael, J. F., Joseph, M. H., Wei Hong: TinyDB: An Acquisitional Query Processing System for Sensor Networks. ACM Transaction on Database Systems. 30, 122--173 (2005)

14. Marie, K., Jun, W. L., Yong, J. L., Jae-Cheol R.: COSMOS: A Middleware for Integrated Data Processing over Heterogeneous Sensor Networks. ETRI Journal. 30, 696--706 (2008)

15. Shuoqi, Li, Ying Lin, Sang, H. Son, John, A. S., Yuan Wei: Event Detection Services Using Data Service Middleware in Distributed Sensor Networks. Telecommunication Systems. 26,351--368(2004)

16. Nader, M., Jameela, A.: A Survey on Service-oriented Middleware for Wireless Sensor Networks. Service Oriented Computing and Applications. 5, 71--85 (2011)

17. Kavi, K. K., R.K. Subramanian: A Service-Oriented Component-Based Middleware Architecture for Wireless Sensor Networks. International Journal of Computer Science and Network Security. 9,174--182(2009)

18. Qingfeng Li, Chen Li, Jifang Shi: Research and Application on Application-oriented Event-Based Middleware of WSNs. 2010 Second International Conference on Networks Security Wireless Communications and Trusted Computing. 498--501(2010)

19. Emanuel, P., Miguel, A. F., Raul, M., Carlos, R. C., Juan, A. L., Samuel R. M., P.J.S.G. Ferreira, M.J.C.S.Reis: An Autonomous Intelligent Gateway Infrastructure for in-field Processing in Precision Viticulture. Computers and Electronics in Agriculture. 78, 176--187(2011)