Keywords

1 Introduction

In recent years, greenhouse agriculture has increasingly become an important direction of modern agriculture development [1]. And the design of an effective and accurate greenhouse monitoring system is prerequisite for improving the monitoring function service of greenhouse. wireless sensor network (WSN) has these advantages of low cost, low power consumption, flexible network organization [2, 3]. At present, the WSN has been applied in cabbage farm [4] and feed storage [5] successfully in foreign countries. Different applications of zigbee based on wireless sensor network in agriculture are developing rapidly [6]. Rajesh Singh has developed a pressure monitoring system using a RF module coupled to AVR MCU. Steven Silva has developed a website for monitoring water pollution based on Zigbee and WiMax technologies and realized the remote monitoring via browser. Liu Hui has used WSN to detect the environment parameters such as temperature, humidity, illumination, and harmful gas. These parameters can be summarized and managed at the server [7, 8]. These systems use some wireless communication technologies such as GPRS, WCDMA. And WSN has been applied in aquaculture, information collection of tea plantation and the cold chain environment of fruit respectively by Shi [9], Wang [10] and Guo [11, 12]. These developers have made great achievements in the zigbee protocol stack, packet loss rate and system stability. Zhang has designed a two-way communication, which can enable users to control these parameters in real-time way [13, 14]. But in the above applications, detecting data mainly depends on only one sensor. And the remote system is not mature enough to expand easily.

In this paper, a new communication protocol for greenhouse monitoring system with multifunctional nodes is designed based on zigbee WSN to overcome the poor expansibility of existing monitoring system. The protocol establishes and maintains the routing table dynamically. And the bit mask method is used to mark devices and sensors which can access multiple devices in one packet. Through the elaborately designed protocol, a distributed monitoring system is designed to realize scanning the data, capturing images and controlling the devices through browser on the Internet. And this greenhouse monitoring system designed in the paper has perfect transportability and expansibility.

2 General Architecture of Monitoring System

As Fig. 18.1 shows that the monitoring system includes three layers, which are relatively perception layer, network layer and application layer. The perception layer is made up of the greenhouse equipment. The network layer consists of zigbee nodes and embedded gateway. And the application layer program is located at the center server.

Fig. 18.1
figure 1

Structure of the system

The gateway takes the S3C6410 provided by Samsung as the core processor (533 MHZ main frequency). It has a peripherals interface and built-in hardware image encoder. Gateway has IP network interface, DM9000 network adapter, WM-GMR-09 wifi module, WSN interface, and zigbee coordinator. At the same time the gateway is connected with some equipments, such as camera, wind speed sensor, wind direction sensor, and so on.

The MCU CC2530 with low power consumption and cost provided by TI is used to build zigbee wireless network. The MCU K60 using ARM Cortex-M4 for the kernel and produced by Freescale is the core control unit of the node. There are many actuators in the node including humidifier, heater, incandescent, and devices which are charge of communication with automatic equipment, such as pick-up robot, patrol robot, irrigation equipment, and so on.

The server is responsible for summarizing and storing the data of all sensors. The web server program provides service for clients to browse the data and operate the local equipment in the greenhouse through the Internet.

In Fig. 18.2, the single-arrows represent the calls and returns, and the double-arrows represent data communication.W2S represents web server and communication data packages for daemon, which are realized by the structure WEB2SERVER below, similar to S2G, G2N, and so on.

Fig. 18.2
figure 2

Data flow of the system

Different nodes are just different in device driver and user interface, but the communication, acknowledge and data management of system follow the same method. Like this, compatibility of different nodes is realized, thus it is only necessary to add related user interface and device driver when new types of node are added which can make system suitable in different situations.

3 Design of Communication Protocol and Data Structure

From the Fig. 18.2, there are six data structures of the packet used in each layer. And the meaning of each segment is shown in Table 18.1. The six data structures are designed as follows:

Table 18.1 Each segment of packet
  • WEB2SERVER: GWID, NODEID, DEVID, LoD, DATA, PACKETID, CMD

  • SERVER2GW: NODEID, DEVID, CMD, LoD, DATA, PACKETID, CRC

  • GW2NODE: NODEID, DEVID, CMD, LoD, DATA, PACKETID

  • NODE2GW: NODEID, DEVID, CMD, LoD, DATA, PACKETID

  • GW2SERVER: GWID, NODEID, DEVID, CMD, LoD, DATA, PACKETID, CRC

  • SERVER2WEB: GWID, NODEID, DEVID, CMD, LoD, DATA, PACKETID

CMD, DEVID and DATA fields are responsible for semantic representations. The values of CMD and DEVID fields are shown in the Tables 18.2 and 18.3, and DEVID represents the devices which are available in the way of bit mask. Each bit represents one device. The command has an operation to the devices whose corresponsive bits are set, or has an operation of uploading frequency to node when all the bits of DEVID are 0.

Table 18.2 Downlink command
Table 18.3 Uplink command

For example, if there is a packet whose GWID = 4, NODEID = 7, DEVID = 0 × 00001800 (bit11 and bit12, that are humidifier and temperature controller), CMD = 0 × 0002, DATA = 0 × 0046001c(70,28), it will present a request to adjust the humidity and temperature to 70 % and 28 °C around node No.7 in greenhouse No.4, using humidifier and temperature controller.

If the users need to obtain the current temperature and humidity of Node 7 in Gateway 3 by client browser, these steps of responding to the above request are shown as follow:

  1. Step 1.

    The client web program generates the original WEB2SERVER data package as follow: GWID = 3, NODEID = 7, DEVID = 0 × 0003, CMD = 0 × 0003, LoD = 0, DATA is empty; PACKETID consists of timestamp and random number.

  2. Step 2.

    The client web program transmits this package to a daemon designed to communicate with gateway. The daemon adds CRC field to start transmission using TCP protocol and waits for ack (acknowledgment character) signal from gateway. It will transmit again if time is out.

  3. Step 3.

    Gateway will transmit an ack signal of GW2SERVER with CMD = 0 × 0006.

If the check is successful, find the short address of node No.7, delete NODEID to form GW2NODE and send it to the node.

  1. Step 4.

    The node checks the DEVID bit by bit. When it comes to the bit of temperature (bit 0), node will sample the data of temperature once, and add 4 to LoD to fill this 4 bytes. When it comes to humidity bit, it will do the similar thing. After all bits are finished, the data NODE2GW is formed. Then the node will send it to the gateway.

  2. Step 5.

    The gateway will send data in packet GW2SERVER to the daemon in server and then wait for ack signal. And the daemon will return the data to the client web program if check is successful. And these data are added to the database after it finishes analyzing these data.

As for the operations whose actuators are directly connected to the gateway, such as image capturing, the process of request is similar but simpler. Their NODEID is 0, which is the ID of gateway in zigbee network. Then these requests and devices will be analyzed on gateway like nodes. After image is acquired, the gateway will compress it to format jpeg and send it to the server. The client web browser shows the image as shown in Figs. 18.3, 18.4. In addition, the users can adjust the angle of cameras by up, down, right, and left buttons.

Fig. 18.3
figure 3

The upload and display of sensor data

Fig. 18.4
figure 4

The capture and display of image

The users can configure the nodes and gateways by their GUI supplied by LCD or touch screen. And the device list will be established once the node is powered up. The routing table is established when the gateways and nodes join the system by transmitting the corresponding commands.

4 Experiment Results

The WSN based on the above new communication protocol is established in laboratory. And the numbers of nodes are eight. In order to verify the transportability and expansibility of the monitoring system, there are three types of nodes in laboratory. The first type is only connected to temperature and humidity sensors. The second type is connected to one sensor and four devices including fan, irrigation valve, light, and stepper motor. And the third type is connected to automatic picking machine. Experiment results show that all the nodes can work well, upload data correctly, and control remotely. That’s to say the stability and suitability of system are good.

5 Summary

In summary, the communication protocol designed in this paper improves the expansibility of monitoring system in three aspects. First, the design of dynamic routing can meet the variable number of nodes. Second, the design of software layer in the node improves the portability and the communication protocols need not be changed when the system is updated. Finally, the gateway and node are both configurable, which make the device in a certain node changeable and expansible.

When the short delay and real-time characters of the system are achieved, different types of nodes have good compatibility and flexible configuration. And the sensor nodes can be adjusted to avoid chaos automatically according to the configuration when the system is expanded. The new communication protocol makes up the deficiencies of existing greenhouse monitoring system. In the future, the system can be promoted. These applications of data and image processing will have more enhanced functionality.