ZigBee-Based Wireless Sensor Network for Temperature Monitoring

The proposed system in this paper describes the design and implementation of a Wireless Sensor Network (WSN) based on ZigBee technology to monitor the history and current temperature information of remote locations. The system is an electronic embedded system that contains: Base Station with coordinator ZigBee, End nodes with router ZigBee, and host computer as a data base (DB) server. The base station is responsible for data collecting, a display for end node sensor readings, and TCP/IP communication with the host computer. End nodes are directly connected with sensors and transmitting the readings of these sensors to the base station. The host computer is responsible for building a data base from end nodes sensor readings. The Microcontroller Units (MCUs) from Peripheral Interface Controller (PIC) family have been used and the firmware has been developed using C language with MikroC Pro which is a full-featured ANSI C Compiler for Microchip PIC MCU as a development environment.


INTRODUCTION
Nowadays, there are many challenges in remote locations environment monitoring. In the same time there are many technologies that can be used to resolve these challenges. Wireless Sensor Networks (WSN) is the technology that could provide ubiquitous computing [1]. Rapid advances in the areas of sensor design, information technologies, and wireless networks have paved the way for the proliferation of wireless sensor networks [2]. A sensor network is an infrastructure comprised of sensing (measuring), computing, and communication elements that gives an administrator the ability to instrument, observe, and react to events and phenomena in a specified environment [3].
ZigBee specification defines ZigBee's smart, cost-effective and energy-efficient mesh network. ZigBee technology is a low data rate, low power consumption, low cost; wireless networking protocol targeted towards automation and remote control applications. Table 1 shows WIFI, Bluetooth, and ZigBee main features comparison.  [3]. ZigBee devices are the combination of application (such as light sensor, lighting control etc), ZigBee logical (coordinator, router, end device), and ZigBee physical device types (Full Function Device and Reduced Function Device) [4] (see figure 1-a). There are three network topologies considered in IEEE 802.15.4: star, tree network, and mesh, (see figure 1-b Security CCMP/TKIP 128bit/64bit 64bit, 128bit 128 bit AES S e p t 2 5 , 2 0 1 3 exist on the same channel. The PAN ID is sent together with all packets. This means that devices can discard packets which are meant for another network [5]. Figure 2 shows IEEE 802.15.4 protocol architecture which focuses on the specification of the lower two layers of the protocol (physical and data link layer). On the other hand, ZigBee Alliance aims to provide the upper layers of the protocol stack (from network to the application layer) for interoperable data networking, security services and a range of wireless home and building control solutions, provide interoperability compliance testing, marketing of the standard, advanced engineering for the evolution of the standard. 802.15.4 itself defines the physical and MAC layers, whereas ZigBee defines the network and application layers [6].

SYSTEM HARDWARE PLATFORM
A block diagram for the proposed system is shown in figure 3. Each of End Nodes communicates with the Base Station which will display the sensor information received from end nodes on LCD and send this information to the server to be saved into an SQL database as history information. An evaluating hardware has been developed with the intention to build our proposed system which included two main devices: Base Station and End node.

Base Station Hardware Platform Microcontroller
A high performance microcontroller PIC18F45K22 as shown in figure (4-a) has been chosen to be the core and main processor for our proposed base station. PIC18F45K22 microcontroller from Microchip has many device specifications that served our proposed system [6]. The main features that concern the system are the Flash Memory size, RAM size, CPU speed, and Digital communication peripherals as the system has used UART interface with ZigBee module and SPI interface with Ethernet controller module plus Ethernet protocol stack has been loaded on the MCU.

ZigBee Chip
The ZigBee Chip CC2530 from Texas Instrument [7] and integrated into DRF1605 board as shown in figure (4-b) [8] has been chosen to provide the ZigBee protocol communication between the Base Station and End Nodes. DRF1605 ZigBee module provide serial UART interface for direct send/receive data communication with microcontrollers. This module to be used in the Base Station, it has been configured as a Coordinator with a specific PAN ID using the software application provided with the module.

LCD Module
A 2x16 LCD (1602A) shown in figure (4-c) with 4-bit interface mode [9] has been chosen to display the sensor readings received from end nodes.

Ethernet Controller
The Ethernet connection with the data base server has been done using an ETH Click module from MikroElekronik. This module features ENC28J60, a 28-pin 10Base-T standalone Ethernet controller, 8 Kbytes of Buffer RAM and SPI serial interface [10]. See Figure (4-d).

Sensors
Each end node has been connected with environmental sensors that are needed to be used. In our proposed system, LM35 analog temperature sensors, as shown in figure (5-b), have been used as an example and connected to one ADC channel of ADC seven channels of PIC16F88.

Fig 5: End Node Hardware Devices
The ZigBee module has also been used in the end nodes to provide the ZigBee communication with Base Station. It has been configured as a router with the same PAN ID and same RF channel of Base Station.

SYSTEM IMPLEMENTATION
The implementation of the proposed ZigBee wireless sensor network includes: End Node and Base Station hardware and software implementation, and Host Computer Software implementation. Figure (6-a) shows the block diagram of Base Station. The base station has been implemented to collect end nodes sensor information and display this information on LCD and also send this information to the host computer to be saved as history information. The MCU PIC18F45K22 has been the main controller of base station operation. The MCU receives end nodes sensors information from the Coordinator ZigBee module. The ZigBee module has been connected to MCU through UART1 interface. The received information has been displayed on 2x16 LCD and also sent Ethernet controller which is connected to MCU through SPI interface.  Figure (6-b) shows the structure of proposed ZigBee end node. End node has the sensors that collect the environmental information and send this information to the microcontroller which processes the information. Analog temperature sensor has been used in the proposed system as an example. This sensor has been connected to ADC channel (1) of PIC16F88 MCU. Then the processed information has been sent to the ZigBee module. The ZigBee module sends the information to the coordinator. The ZigBee has been connected to PIC16F88 through UART interface. As a power source, each end node has been provided by DC power using 9V battery and because that MCU works on DC 5V and ZigBee module works on DC 3.3V, voltage regulators has been used.

SYSTEM OPERATION
The proposed ZigBee Wireless Sensor Network has been composed of multiple ZigBee wireless sensor nodes, Base Station, and host computer. The flowchart for Base Station and End Nodes operation is shown in figure 7. Initialization n=0 S e p t 2 5 , 2 0 1 3

Fig 7: Base Station and End Node System Operation
The system operation initializes from base station. The base station sends a request to each end node and waits a specific time delay. If a node is online and receives the request, this node will get the information from temperature sensor through ADC channel and upload it to the ZigBee module. The ZigBee module sends this information to the base station coordinator. In case, the timer is finished and no information has been received from end node the base station will indicate that the end node is offline and display offline state on the LCD. Once the microcontroller of base station gets the end nodes information from the ZigBee module through UART interface, The MCU processes the information received from end nodes and sends that information to the LCD module. The LCD will display the received sensor readings. The MCU also uploads the processed sensor information of each end node to the Ethernet controller which sends this data to the host computer as a UDP packet.
The system has been deployed with a closed indoor field and nodes have been distributed on the rooms of this building. The distance between base station and single node was 10-20m with successful data delivery. 20-30m distance, we have got about 50% of missing readings. Exceeding 30m, end node lost connection with Base Station and no readings have been received. The connection has been resumed when another end node or a ZigBee router has been putted on the path between Base station and the disconnected end node as shown in figure 8. By this way, the mesh networking between ZigBee nodes has been achieved.

Fig 8: ZigBee Mesh Networking Test
The host computer has been used to make a data base (DB) of end nodes sensor information and this DB has been considered as a history log for sensor readings. In the host computer, a PHP code has been used to open a UDP server socket and an SQL programming code has been used to insert the received information from base station into the data base. XAMPP software application for Windows has been installed on the host computer. XAMPP has been used to install the Apache HTTP server, MySQL, PHP, and PHPMyAdmin on the host computer. Using PHPMyAdmin web-based interface tool a MySQL ZigBee DB has been built as shown in figure (8-a). The data base structure for end nodes has contained: id (record id), sensor id (Node id), value (temperature reading), and timestamp (reading received time) fields, see figure (8-b). The end nodes sensor information has been sent as UDP packets to the host computer through an Ethernet connection. This information has been inserted into the ZigBee DB using the PHP and MySQL code already running in the host computer.

SYSTEM TESTING AND RESULTS
The finsal hardware design for the proposed ZigBee system is shown in figure 9.

Fig 9: The Final ZigBee Base Station and End Node System Hardware Design
This system has been implemented and tested with Base Station and three end nodes. The temperature sensor has been used to send the environment temperature information to the Base Station. When the system has been run in a stable fashion and end nodes located within the base station coverage, the temperature information has been received normally from the 3 end nodes and temperature information displayed on the LCD of base station as shown in figure (10-a). Whenever one of the nodes has been powered off, the offline state has been displayed on the LCD of Base Station as shown in figure (10-b).

Fig 10: Display End Nodes information and sensor readings on Base Station LCD
Also the same information for each node has been sent to the host computer. Using XAMPP web-based server interface, the temperature readings for the 3 end nodes at different timestamps has been queried and browsed as shown in figure  11.

CONCLUSION
In this paper, a prototype of an embedded wireless sensor network has been built based on PIC microcontrollers and DRF1605 ZigBee module. The environmental temperature monitoring has been considered in this work to demonstrate the capability of applying the system. The system has the character of wireless on wiring to remove the limitation of traditional wired network system for any kind of remote conditions monitoring.