The Design and Completion of Remote Data Monitoring Based on ZigBee Wireless Sensor Network

According to the current technology of wireless sensor networks and the development situation and the research topic of ZigBee that is currently gaining much attention, this paper further studies the working principle of ZigBee technology and completes the establishment and test of a wireless sensor network using this technology. Finally, it integrates the design of remote data monitoring and analyzes the application of a wireless sensor network based on ZigBee technology.


INTRODUCTION
As a burgeoning wireless communication technology, ZigBee technology is generated on the basis of the protocol standard IEEE802.15.4.Compared with other wireless communication technology at present, it is remarkable for its short distance and low complexity, low power consumption, low data flow and as well as the low cost.Due to its features, ZigBee technology is suitable for conduct business with small data flow.These characteristics meet the needs of the wireless communication network.ZigBee can coordinate mutual communication among thousands of micro sensor nodes, which consumes little power and effectively transmits data from one to the other through radio waves.Therefore, ZigBee technology is the best option for completing the wireless sensor network and also offers an opportunity for its development.Wireless sensor network structure is shown as figure 1.With the advantages of self-organizing, small volume, low cost and high flexibility, the wireless sensor network has been widely applied to military, environmental science, medical and commercial fields.ZigBee is a newly-developed technology with unique advantages.Using ZigBee as the transmission carrier of the wireless sensor network can make full use of its advantages [1].In order to integrate with the practical application, this paper has realized the remote data monitoring system on the basis of the ZigBee wireless sensor network.It makes use of the sensor node to collect the data and the ZigBee network to transmit data in order to complete the remote monitoring of data.Hence, this paper studies the following three technologies: ZigBee, wireless sensor network and remote data monitoring [2][3].It blends the three together and completes the research and design of remote data monitoring based on the ZigBee wireless sensor network.With the starting point of practical application, this paper presents the advantages of the ZigBee wireless sensor network as well as its wide prospect.

A. Figures and Tables
The nodes in the ZigBee network can be divided into two types according to their communication capability: full function device and reduced function device.
(l) The full function device (FFD) has all functions and feature regulated in the ZigBee protocol.With sufficient calculation capability and storage capacity, it can serve as the coordinator and router in the network, and of course, can work as the terminal node [4][5][6].
(2) The reduced function device (RFD) has limited functions, and can only work as the terminal node, which lowers the complexity and cost of the nodes.FFD devices can communicate with each other, while the RFD devices cannot communicate with each other.They can only communicate with the FFD devices or transmit data to the outside through an FFD device [7].The division of the above FFD and RFD devices depends on the communication capability of the nodes [8].In fact, from the point of the function of the nodes, the ZigBee standard stipulates three types of network nodes: coordinator, router and terminal node, which can be defined as follows [9].
(l) Coordinator This is an FFD.Whatever the topology that the ZigBee network adopts, it will need only one coordinator node.As the core of the network, its tasks at the network layer include selecting the frequency channel that the network uses, building the network and allowing others to enter it, providing information routing, security management and other services [10].After the establishment of the network PAPER THE DESIGN AND COMPLETION OF REMOTE DATA MONITORING BASED ON ZIGBEE WIRELESS SENSOR NETWORK and the completion of the initialization of the entire network, it can still work normally even when the coordinator nodes are closed [11].
(2) Router This is also an FFD.If the ZigBee network adopts the tree or star topology, it will use the node as a router, which will be in charge of the routing and transmission of the data.One ZigBee network can have several routers which act as the key components of far-extension of the ZigBee network.The functions of the router node are sending and receiving information about the node, transmitting data among nodes, and permitting slave nodes to enter the network through it [12].
(3) Terminal Device The terminal device can be an RFD and its main task is sending and receiving messages.Normally, a terminal device node is supplied by the battery and it will remain in a dormant state to save power when it does not receive data.The terminal node can neither transmit a message nor let other nodes join the network [13].
The ZigBee standard rules that one single network can at most hold 4,165,535 nodes which all belong to one of the above-mentioned three types [14].All the three node types are the concepts of the network layer which determines the topological structure.The concept of the network topological structure will be introduced in detail in the next section.TEEN protocol generates clusters is shown as figure 2.

General node General node
The secondary ry r cluster heads The secondary cluster heads

A. Operational Process of the Coordinator Node
Every ZigBee network can only have one coordinator node which is the key to the entire network.It builds and maintains the operation of the two networks with the discovering and self-organizing functions which can find requests from other network nodes asking to join the network and can permit their entrance [15][16].When the power is on, the coordinator firstly begins the initialization and then searches the channels and selects the suitable one to build the network as well as set the PANID of the network to wait for the joining of routers or terminal nodes [17].After the routers or the terminal nodes join the network, the coordinator node can receive the data from the router or terminal node [18].The operational process of the application program of the coordinator is shown in Figure 3.

B. Functions Used by the Application Program of the
Coordinator (l) APPcoldstart This is the start of the entire program.This function configures the channel number and PANID and then invokes the vlnit function to complete the initialization of the network [19].
(2) AppWarmstart This is the start of the warm start of the program.It will be called automatically when the system restarts after sleeping.In this application, we simply invoke the Appcoldstart [20][21][22].
(3) JZA--boAPPStart This function will be utilized after initializing the ZigBee stack to register the Endpoint of the application program and distribute the descriptive symbol for the EndPoint.Usually, it will call the JAZ Startstack in this function and start the ZigBee protocol stack.
(4) JZA--vAPPEventHandler This function will be used for dealing with external events and is called by BOS in a fixed amount of time [23].
(5) JZA--vPeripheralevent This function will be called when hardware is interrupted in the peripheral system.The processor will enter the interrupt mode while in call.The interrupt information will be put in a simple FIFO sequence, then read by the JZA_vAppEventHandier function.There is no specific application in this program, but it must define the function to be empty [24].
(6) JZA_vAppDefineTasks This function is used to register its users task to the BOS which belongs to the kind that is rarely used.There is no specific application in this program, but it must define the function to be empty.
(7) JZA_eAfkvpObject This is used for receiving and processing the KVP data sent from other nodes.The form of the data being sent in the program is MSG [25].So it has not been used and the function body is empty. (

8) JZA_u8AfMsgobjeet
This function is applied to receiving and processing the MSG data sent by other nodes.This function is used for receiving the sensor data sent from the receiving terminal node.
The above-mentioned functions constitute the framework of the entire application program which work as the interactive interface between the application program and the ZigBee protocol stack.Then we add our own application program to these interface functions and write our own functions as well as make calls in them.Many interface functions have not been used in this program but still have to be defined [26][27][28].Additionally, we need to keep the function prototype and set its body to be empty.

C. Program Design of the ZigBee Router Node
Just like the coordinator node, the router node firstly needs to finish the relative initialization, including both the ZigBee protocol stack and the peripheral.What is different is that the router does not need to build the network, but search the information channel and select the proper network and wait to join [29][30][31].As long as it is searching the network, it should send the joining request to the coordinator node of the network and finally join the network after receiving the confirmation of joining permission sent from the coordinator node [32].After successfully joining the network, the router node can read the data of the sensor and send them to the coordinator node.The operational process of the router node is shown in Figure 4.

D. The Completion of Key Function
What differs the router node from the coordinator node is that the former has to complete the functions of collecting and sending data.The following will discuss the implementation of these functions.
(l) Collecting Data of Temperature and Humidity The router will collect the data through the onboard integrated temperature-humidity sensor which is on the sensor board made by the JENNIC Company.The JENNIC Company also offers a relative developing function which is convenient for to use to complete the function of collecting data.It is necessary to simply introduce the structure of the onboard sensor [33].working process of temperature and humidity is shown as figure 5.The other four can sample the input voltage of the external pin.In order to collect voltage data, we need to make AD shift to the input voltage of the pin.Then we use the vAHI-AdcStartSamPle function to start the AD shift and wait for its completion.Here, we adopt the bAHI-AdcPoll function to search the ADC state and judge whether it isfinished as well as use the ul6AHI-AdeRead function to read the digital quantity of the AD shift.
We can determine the pin voltage which is currently measured according to the relative data transforming and processing of the values obtained.The voltage measured here is that of the internal power.If we add the output of the externally-connected sensor to the ADC pin, then we can easily measure the data of corresponding sensors.The program flow chart of the ADC module is illustrated in Figure 6.
The data transmission is implemented by the VsendData function which constructs the corresponding data package that seals the temperature, humidity and the voltage inside and calls the afdeDataRequest function to send the relative transmission request to the ZigBee protocol stack so as to transmit the sensor data to the coordinator node.

A. Overall Design of the System
The automatic meteorological observing station has to collect the data of all meteorological elements, including the temperature, humidity, wind speed, rainfall and the air pressure, and its selection of sensors will be different according to requirements.The communication between the sensor node and the gateway node (network coordinator) is done by the ZigBee protocol.The next one collects the data from all sensor nodes and connects to the Pc serial port through RS-232 or transmits the data to the Internet through GSM/GPRS.The hardware structure of the data monitoring system concerned in this paper is shown in Figure 7, which consists of the following key parts: (1) Data Collection In the data monitoring system, the sensor is usually used to collect data.What data must be collected depends on the specific applications.Different types of data requires different sensors.For example, the data collected by an automatic meteorological observing station is some environmental data related to meteorology, such as the temperature, humidity, wind speed and rainfall.The data collection is fulfilled by using corresponding sensors that act as a kind of tentacle of the monitoring system.We can finally realize the monitoring of the environment by using various sensors to collect corresponding data.(2) Data Transmission In the system, the data transmission consists of two parts: one is where the data is transmitted from the node to the main node, the other is from the main node to the data center.In the process of the data collection of the main node, the technology that the system adopts is the ZigBee wireless sensor network.So the integration of ZigBee technology, GPRS network technology and sensor technology forms the new wireless sensor network.The entire data transmission process is shown in Figure 8.
(3) Data Analysis and Storage The data analysis and storage is completed by the software in the data center.The upper computer software of the data center needs to store the data after receiving the detecting data sent from the sensor network and carries out analysis and processing by using related technologies, and finally gets the conclusion so as to fulfill the real-time monitoring of the monitored area.

B. Processing of Data Received
The serial port will receive whatever data is sent from the ZigBee network.But in practical application, it usually conducts relative analysis and processing on the data received and obtains the data required.At the sending terminal, we need to self-define the data form in order to conveniently handle the data at the receiving terminal.The program in this paper uses the ZigBee network to transmit four pieces of data: the address of the ZigBee network node, temperature, humidity and voltage.The form of self-defined sending data is as follows: "@ID*****@T*****@H*****@V***&$" Here, the "*****" between @ID and @T is the data with varying length which is the first parameter transmitted, namely, the node address ID; the "*****" between @T and @H is the data with varying length which is the second parameter transmitted, namely, the temperature data; the "*****" between @H and @v is the data with varying length which is the third parameter transmitted, namely, the humidity data; the "*****" between @v and &$ is the data with varying length which is the fourth parameter transmitted, namely, the measuring value of the voltage.Each piece of data will end with the two special characters "&$".

C. Storage of Data Received
As for referring to the historical data, the serial port must store the data after receiving them from the sensor node.Due to the simple data table, this paper uses the Microsoft Access database and the ODBC database visiting technology to access the database.The storage of the data is also completed with the onTimer() function.
The resolution of each frame of data will lead to the four pieces of data; the node ID, temperature, humidity and voltage.The program has created a sensor data table in the Acess database and uses the Open() function of the type of Cdatabase to open the database.Additionally, we use the ExecuteSQL() function to insert the data and finally use the Close() function to close the connection with the database.

V. CONCLUSION
With the advantages of self-organizing, small volume, low cost and high flexibility, the wireless sensor network has been widely applied to military, environmental science, medical and commercial fields.ZigBee is a newly-developed technology with unique advantages.Using ZigBee as the transmission carrier of the wireless sensor network can make full use of its advantages.In order to integrate with the practical application, this paper has realized the remote data monitoring system on the basis of the ZigBee wireless sensor network.It makes use of the sensor node to collect data and the ZigBee network to transmit the data in order to complete the remote monitoring of data.Hence, this paper studies the following three technologies: ZigBee, wireless sensor network and remote data monitoring.It blends the three together and completes the research and design of remote data monitoring based on the ZigBee wireless sensor network.With the starting point of practical application, this paper presents the advantages of the ZigBee wireless sensor network as well as its wide prospect.
With the ZigBee technology as the carrier, this paper designs a small wireless sensor network and offers its design method as well as analyzes its application prospect by using practical instances.Lastly, it introduces the wireless sensor network technology and relevant theories of ZigBee technology.Then it constructs the developing platform of software and hardware applied in this paper.On this basis, it gives the building theory and method of the ZigBee network in which the most critical part is the software design of two sensor network nodes, the coordinator node and the router node.The paper offers the overall block diagram of the program and analyzes the specific program implementation of some of the functions.After successfully building the wireless sensor network, it studies the detailed design process of the remote data monitoring system based on the wireless sensor network.In the overall implementation of the thesis, many experiments were conducted, and the prospective effect was basically realized.

Figure 1 .
Figure 1.Wireless sensor network structure

Figure 3 .
Figure 3. ZigBee network coordinator operation process