Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Master of Engineering
September 2013
Candidate
Wenbo CHEN
Supervisor
Shu Liu
Associate Supervisor:
Industrial Supervisor:
Gil De Sousa
Master of Engineering
Speciality
Software Engineering
Affiliation
School of Software
Date of Defence
September, 2013
Degree-Conferring-Institution
Harbin Institute of Technology
Abstract
In recent years, with the rise of wireless sensors, wireless sensor networks
(WSN) are used in many applications in day-to-day life. In smart agriculture, WSN
has been applied to monitor the development of crops from remote places. The
monitored data includes temperature, humidity and soil moisture.
This thesis focuses on the wireless sensor device Libelium Waspmote and
corresponding modules including the XBee ZigBee Pro module and the real time
clock module, agricultural sensor board, Waspmote Gateway, Meshlium,
MCP9700A sensor and 808H5V5 sensor. The aim was to realize a wireless sensor
network to monitor crops development. The network is a star topology structure.
The Meshlium works as the center point while Waspmotes are around working as
nodes. Different sensors are plugged into an agricultural sensor board which is, in
its turn, plugged on a Waspmote. The final WSN can be divided into three parts:
collecting data, storing data and sending data. In collecting data, corresponding
sensors collect the environmental data at a fixed frequency. In storing data,
Waspmotes store the data in flash memory or SD cards. In sending data, Waspmotes
send the data by the XBee ZigBee Pro module to a Meshlium based on ZigBee
protocol. Meshlium stores the data in local files or, local or external database. To
design the WSN, this project requires the programming and the testing of all the
modules of the Waspmote. The programmed modules are used in the final design of
the network. Communication among Waspmotes, communication between
Waspmotes and Waspmote Gateway are tested to design communication between
Waspmotes and Meshlium. In the project, Waspmote has changed from version v1.1
to version v1.2 on hardware.
The final wireless sensor network is based on Waspmote v1.2 and a Meshlium
stores temperature, humidity and other environmental parameters sent by multiple
Waspmote wireless sensor nodes.
Keywords: wireless sensor network; wireless sensor; ZigBee Pro protocol
II
Rsum
Au cours des dernires annes, avec lvolution technologique des capteurs
sans fil, les rseaux de capteurs sans fil (RCSF) sont utiliss dans de nombreuses
applications dans la vie de tous les jours. Dans l'agriculture intelligente, un RCSF
est utilis pour surveiller distance le dveloppement des cultures agricoles. Les
donnes surveilles comprennent la temprature, l'humidit et l'humidit du sol.
Ce rapport porte sur le capteur sans fil Libelium Waspmote et ses modules
associs, y compris le module XBee ZigBee Pro et le module d'horloge temps rel,
la carte dextension agricole, la passerelle Waspmote Gateway, le routeur Meshlium,
les capteurs MCP9700A et 808H5V5. L'objectif est de raliser un RCSF pour
surveiller le dveloppement des cultures. Le rseau a une topologie en toile. Le
Meshlium fonctionne comme un point central autour duquel sont prsents les
Waspmotes en tant que nuds. Diffrents capteurs sont branchs sur une carte
dextension agricole qui est, son tour, branche sur un Waspmote. Le
fonctionnement du RCSF final peut tre divis en trois parties : la collecte, le
stockage et l'envoi de donnes. Lors de la collecte, les capteurs correspondants
recueillent des donnes de l'environnement une frquence fixe. Pour le stockage,
les Waspmotes utilisent de la mmoire flash ou des cartes SD. Pour lenvoi, les
Waspmotes les transmettent par leur module ZigBee XBee Pro un Meshlium. Le
Meshlium stocke ensuite les donnes dans des fichiers locaux ou une base de
donnes locale ou externe. Pour concevoir le RCSF, ce projet exige la
programmation et l'essai de tous les modules du Waspmote. Les modules
programms sont ainsi utiliss dans la version finale du rseau. La communication
entre Waspmotes, la communication entre Waspmotes et une passerelle Waspmote
Gateway ont t testes pour concevoir la communication entre Waspmotes et un
Meshlium. Durant ce projet, la version matrielle du Waspmote a chang, passant
de la version v1.1 la version v1.2.
Le RCSF final est bas sur la version v1.2 des Waspmotes. Au final, le
Meshlium recueille diffrentes donnes environnementales sur la temprature et
lhumidit envoyes par plusieurs nuds de capteurs sans fil Waspmotes.
Mots Clefs: Rseau de capteurs dans fil ; Capteur sans fil ; ZigBee
III
Table of contents
ABSTRACT .......................................................................................................... II
CONCLUSION .................................................................................................... 84
REFERENCES .................................................................................................... 85
ACKNOWLEDGEMENTS ................................................................................. 88
Chapter 1 Introduction
1.1 Background
Today, with the development of wireless sensor, wireless network
communication, digital electronics and micro electro mechanical systems, wireless
sensors have become smaller in size and lower in cost and more powerful. Besides,
wireless sensors have become more multifunctional and can communicate with each
other in short and medium distances. Based on these new wireless sensors that can
be used for environment sensing, data processing, data storing and short distance
communicating, Wireless Sensor Network (WSN) has been developed and applied
to many fields.
A sensor is a device which can measure one or more physical quantities and
convert the measured physical quantities into a signal that could be recognized and
read by observers or electronic instruments. Based on sensor, wireless sensors are
standard measurement devices that measure one or more physical quantities
[1]
and
use the equipped transmitters to convert the measured physical quantities into radio
signal and send the radio signal out through communication model and antenna. The
radio signal is interpreted by the receiver or electronic instruments which then
convert the wireless radio signal into a specific, desired output.
Compared to common sensors, the primary benefits of using wireless sensors
are safety, convenience and reducing costs. Wireless sensors can be used in
locations that are difficult to access due to extreme conditions such as high
temperature, humidity and pressure. Besides, wireless sensors can also be used to
form a wireless sensor network which would allow technicians to monitor a large
number of different locations far from the monitoring place. In addition, through
using wireless sensors in manufacture filed, it is able to decrease the cost of
monitoring and running factories by reducing the cost of costly accessories
including extension cables, conduit and etc.
A sensor network is a group of specialized sensors that equipped with
communication infrastructures for the purpose of monitoring and recording
environmental parameters of a specific location and send the result to receivers
antenna, a micro
controller that embedded in the sensor board, a sensor board with pins provided as
interfaces for others specific sensors and energy sources.
Because of the characteristics including low cost, rapid deployment, flexibility,
high fault tolerance, high sensitivity and etc., WSN has a wilder use in many new
and exciting applications and fields for remote sensing.
In agriculture and environment areas, smart wireless sensor network has been
applied in several applications as follows [2]:
1) Increase wine quality. Monitoring environmental parameters of vineyards
including soil moisture, temperature, diameter of trunk and etc. to control the health
of the grape trees and enhance wine quality.
2) Irrigation in golf green. Through monitoring the soil moisture of the golf
green and irrigating the dry zones, the cost of irrigation and water resources in golf
green can be reduced.
3) Weather forecast. By deploying the wireless sensor network in fields,
technicians can forecast the weather condition including rain, snow, drought, wind
and etc.
4) Control compost. Monitoring the humidity and temperature of compost to
prevent it from bacterial pollution such as fungus and etc.
Wireless sensor network can be used to monitor different environmental
parameters related to agriculture such as air temperature and humidity, soil
temperature and humidity, weather condition, leaf wetness and many other
parameters. The monitoring of these environmental parameters allows the user to
minimize the cost of time and money as well as maximize the agricultural results.
2
application,
home
application,
health
application,
military
In the environmental area, a wireless sensor network can be used for detection
of floods and forest fires, bio-complexity mapping of the environment, precision
agriculture and tracking the movements of animals. Forest fire detection needs
wireless sensor nodes that are able to be left in forest for months and even years, so
sensors are equipped with effective power modules
[5]
wireless sensor nodes should ignore the obstacles which block the wireless sensors
line of sight like rocks and trees and communicate with each other nodes in short
distance. An example of wireless sensor network used in the detection of the flood
[6]
is the ALERT system deployed in US. The rainfall, water level and weather
[7]
are equipped with wireless sensor nodes that are able to communicate
with each other nodes and users. Theses self-organizing wireless sensor nodes
should be integrated with existing embedded devices, provide communication
among room users to share information and services they offered such as printing
and faxing
[8]
appliances and devices like refrigerators and micro-wave ovens. Residents are able
to control the home devices outside of home.
Wireless sensor network applications related to health include tracking and
monitoring doctors and patients inside a hospital, drug administration and control in
hospitals, telemonitoring of human physical data and etc. The installed wireless
sensor network can be used to monitor and detect the behavior of elderly people and
the disability like a fall and store the collected physical and biological data for a
long period of time
[9]
[10]
. An example of applying
wireless sensor network in health field is the Health Smart Home deployed in the
Faculty of Medicine in Grenoble in France to validate such system [11].
Because of the specific characteristics of wireless sensor network including
rapid deployment, self-organization of network, high fault tolerance, high
sensitivity and etc., wireless sensor networks have a wide range of applications in
military field. Wireless sensor networks have been applied in fields such as
4
[12]
museums that are able to respond to peoples action to learn more about the
exhibition. The real time cause-and-effect environment is already provided and
deployed for people to take part in
[13]
The sink nodes and other sensors use the same protocol stack. The protocol
statck includes five layers: application layer, transport layer, network layer, data
link layer and physical layer. The protocol stack also includes three planes: task
management plane, mobility management plane and power management plane
[4]
The five layers are used for communication while the three planes are used for
management. The five layers and the three planes are shown in Figure 1-2.
5
Figure 1-2 The protocol stack of the sink node and other sensors [4]
[14]
sensor nodes such as power consumption, production costs, scalability and hardware
constraints. The second part is factors related to network such as fault tolerance,
sensor network topology and transmission media. And the last part is factors related
to environment such as operating environment [15].
6
[17]
[16]
and RFID
Figure 1-3 a) Waspmote agriculture sensor board b) Waspmote proto sensor board c) Waspmote
RFID module
The deployment process was divided into the following different tasks:
1) Module development: development of measuring module, communication
module and statistical prediction model.
2) Interface development: development of irrigation system interface, user
interface such as a PC or smart phone and air conditioning system interface.
3) Communication development: development of traceability of the grape
based on a RFID system.
The global architecture diagram of the Siega System is shown in Figure 1-4.
The deployed wireless sensors collect data at a fixed frequency and send them to a
Meshlium which stores them in a database or sends them to web application models.
Figure 1-5 Siega System sensor nodes used to collect data from environment
10
Meshlium was installed in the center of the vineyard to gather all the data
coming from the sensor nodes and storing this data in a database or sending this
data to a web application, PC or mobiles. The Meshlium used in Siega System is
shown in Figure 1-6.
Once the base system was deployed, both PC and smartphone applications
were developed to help the user to manage irrigation system, air conditioning
machines and to prevent possible plagues. The Siega Systems PC application is
shown in Figure 1-7.
Sensor nodes are located using Google Maps and the user can access to
real-time data from each sensor node, and even obtain a visual representation of the
different parameters measured by that node. A smartphone application is able to
11
control the system from anywhere when connected to the Internet. The graphical
user interface of Siega smartphone application is shown in Figure 1-8.
between
Waspmotes
and
Waspmote
Gateway
or
the
The third part is the project design. It focuses on the design and development
of the different Waspmote modules. All modules used in the communication
between Waspmote and Meshlium have to be programmed and tested in this part.
As the core of this thesis, this chapter focuses on the collecting of data from sensors,
storing data in the memory, and transmitting the data to the Meshlium. Then as a
router, the Meshlium transmits the data to the Internet or other terminal end users.
The last part is the conclusion. This chapter makes a conclusion of each
chapter and makes a summary of the project and thesis.
13
[18]
that works
as a wireless sensor device equipped with different specific modules. For this
project, I firstly need to become familiar with different modules of Waspmote first.
Each module has to be programmed and tested before being used in the project. The
modules of Waspmote that will be used in this project include USB modules, utility
modules, power modules, XBee ZigBee Pro modules, XBee868 modules, real time
clock (RTC) modules, accelerator modules, SD card modules and WIFI modules.
After programming and testing all the related Waspmote modules, we have to
focus on the XBee ZigBee Pro module and the XBee 868 module will be focused on
because they are in charge of transmitting data and thus the communications
between different devices. In this project, there are three types of wireless
communications. They are communication between Waspmotes, communication
between Waspmotes and a Waspmote Gateway, communication between
Waspmotes and a Meshlium. The final wireless sensor network is based on the
communication
between
Waspmotes
and
Meshlium.
However,
this
14
data of Meshlium in real-time and modify some parameters that cannot be modified
using the Manager System of the Meshlium.
In the wireless communication based on XBee ZigBee Pro module and XBee
868 module, apart from the USB module, power module, real time clock module
and SD card module, other needed hardware are agricultural sensor board,
temperature sensor MCP9700A, humidity sensor 808H5V5, soil moisture sensor
and etc. As a result, environmental data, including air temperature, air humidity,
soil moisture and battery level, has to be collected by Waspmote equipped with
corresponding sensors. Waspmote stores the data in flash memory or SD card, and
uses the wireless communication module to transmit the collected data from
Waspmote to Meshlium. The Meshlium stores the collected data in local files or in
local database or even stores them on external database through the Internet.
[14]
. An example of the
Erasable Programmable Read-Only Memory), 8KB SRAM (Static RAM) and 128
KB flash memory that are not enough for saving the whole environmental
parameters collected by the temperature sensor MCP9700A, the humidity sensor
808H5V5 and the soil moisture sensor. So the external SD card with a maximum
size of 2GB is necessary.
The Accelerator module is used for get accelerator and checking the status of
the Waspmote. In deployment, the Waspmote could be placed on high places like
poles or trees, since the accelerator has a function to check the free fall status by
getting the accelerator in X axis, Y axis and Z axis, it can be used to check whether
the Waspmote has fallen or not to avoid the missing of data.
The GSM/GPRS module is used for using GSM network. With this module, the
Waspmote is able to make calls, send and receive messages, upload and download
files from FTP web servers. In deployment, when the server is an FTP server, the
collected data from the specific sensors may be uploaded to the FTP server to
update the data in real time.
The XBee ZigBee Pro module is one of the most important wireless
communication modules used on the Waspmote. Based on the ZigBee protocol, this
module is used for sending data from Waspmote to Waspmote, from Waspmotes to
a Waspmote Gateway and from Waspmotes to a Meshlium. The XBee ZigBee
module has a radio range of 500m while the XBee ZigBee Pro module has a range
of 7000m that is enough for field deployment to monitor the crops development [20].
The XBee 868 module is another wireless communication module used on the
Waspmote. With a higher transmission power and sensitivity, the radio range of the
XBee 868 module is 12km. The radio frequency of XBee 868 is 868MHz.
Compared to the XBee ZigBee Pro module, the XBee 868 module is more powerful
and has a wilder use in monitoring crops development.
2.2.1.1 The functional requirements of the utility module
As the one of the basic modules, the utility module needs to be tested first. The
utility module takes control of several useful parts: USB port, LEDs, flash memory
EEPROM, basic sensors including temperature sensor MCP9700A and humidity
sensor 808H5V5 and basic libraries including type converting functions [21].
The USB function is used to transmit data from the Waspmote to the IDEs
serial monitor on a PC through an USB cable. Through the IDE provided by
Libelium, the Waspmote can print out some important parameters for users to know
17
the status of the running programs better. Besides printing on serial monitor, in this
function the serial monitor can also send data to the Waspmote node when the USB
port is available [22]. The USB function is important in all other modules for printing
out the results of the executed commands to help developers to know the status of
the Waspmote.
The LED function is used to control the two LEDs embedded on the Waspmote
board and to check the different status of the running programs. Both LEDs can be
controlled by the uploaded program, including turning on, turning off and blinking
for a certain time. When testing the communication module, the LEDs can be used
to check whether the network is joined successfully or the data packets are sending
correctly.
With a size of 4 KB, the EEPROM can be used to save temporal data. Except
for the first 1 KB that is occupied by the operating system, the other 3 KB can be
used. In this project the flash memory of Waspmote is not enough for saving the
environmental parameters collected by the temperature sensor MCP9700A, the
humidity sensor 808H5V5 and the soil moisture sensor, so the SD card module that
can be extended to 2 GB will be introduced later.
The basic sensor function is a new function. In Waspmote v1.1, there are not
any specific pins on boards for the temperature sensor MCP9700A or the humidity
sensor 808H5V5. So an agricultural sensor board is necessary for these
corresponding sensors to collect data. The agricultural sensor board is plugged into
the Waspmote board and all the needed sensors are plugged into the agricultural
sensor board. However, in Waspmote v1.2, the hardware has been changed as well
as the API (Application Programming Interface). The basic sensors including the
temperature sensor MCP9700A and the humidity sensor 808H5V5, they can be
plugged directly on the Waspmote board. Besides, the corresponding specific
functions have been developed to collect basic environmental data including air
temperature and humidity.
In the utility program, all the functions needed to be tested. The test program
had to be compiled and uploaded on the Waspmote v1.2.
2.2.1.2 The functional requirements of the real time clock module
Considering that saving energy is one of the most important factors in design
of wireless sensor network, the Waspmote should have an effective function to
change the status between sleep mode and active (ON) mode. The real time clock
18
(RTC) module is used for setting time and alarm clock. As the core part of
deceasing energy consumption and saving energy, this part has wild use in the
communication between Meshlium and Meshlium.
Real time clock module has an embedded thermometer to get temperature. The
getting temperature function will be used later in communications based on XBee
ZigBee Pro module and XBee 868 module as a node to collect the temperature [23].
Alarm clock part contains setting alarm clock and getting interruption to wake
up. Real time clock module has two alarm clocks. One is based on
day/hour/minute/second format. The other is based on hour/minute/second format.
So the first alarm clock is used more widely. After setting the alarm clock that
defines a corresponding sleep time in program, the Waspmote will change into sleep
mode where all modules except the real time clock one are powered off. When the
sleep time is over, the real time clock module will send the RTC_INT
[24]
interruption, when the Waspmote get the RTC_INT interruption, it wakes up from
sleep mode to active mode. When Waspmote wakes up, all modules need to be
initialized and turned on again.
In the program of real time clock module, it should be focused on the alarm
clock part where absolute time and offset time need to be tested as well as the alarm
clock 1 and the alarm clock 2 with all corresponding alarm clock modes. These
programs should have two versions according to the hardware. One should be
uploaded and tested based on the Waspmote v1.1. The other should be uploaded and
tested based on the Waspmote v1.2.
2.2.1.3 The functional requirements of the SD card module
The SD card module is used for saving the environmental data including air
temperature, air humidity and soil moisture data from corresponding sensors.
Considering that the Waspmote only has 4 KB EEPROM and 128 KB flash
memory, when in the deployment, the environmental data needs a large memory to
save, so the 2GB extended SD card is necessary.
The SD card module provides basic files operations including reading files,
writing files, deleting files, searching content in file, basic folder operations
including creating folder, deleting folder, basic SD card operation including
calculating the number of files in card and getting the disk size and etc. The
checking SD card function is used to check whether the Waspmote has a SD card
19
before storing data in it. It is important to check every time to detect broken SD
card event in order to reduce the possibility of losing collected data [25].
The creating and deleting folders functions make the SD card clear in
architecture. Because SD card module uses tree architecture, so there could be
different layers. Each layer could have different folders and files. The name format
of SD card module is 8.3. The name of the created file contains at most 8 letters
while the suffix contains at most 3 letters. The change directory function and show
files function are also provided for users to check the whole file architecture as well
as the content of the SD card.
Because the SD cards are only provided in the Waspmote v1.2 tool kit, the SD
card module only needs to be tested on Waspmote v1.2, all functions including
operation related to files and operations related to folder are needed to be tested. In
our program, the different processes includes checking SD card status, getting basic
parameter of SD card including number of files and disk size, creating files, writing
files, appending sentences in files, reading files and showing content, deleting files,
creating folders, deleting folders and etc. The test program needs to be compiled
and uploaded on Waspmote v1.2.
2.2.1.4 The functional requirements of the GSM/GPRS module
The Waspmote v1.2 tool kit has a Waspmote v1.2 board equipped with a
SIM900 module designed for using the GSM network service. When a SIM card is
plugged, this module can be used to make and receive calls, send and receive
messages, download files from a FTP server as well as upload files to a FTP server.
In the project, if the collected environmental data needs to be stored on a FTP
server, other Waspmote devices in the same network can send data to the
GSM/GPRS module through communication modules like the XBee ZigBee Pro
module or the XBee 868 module. And with its GSM/GPRS module, this Waspmote
node can resend the data to a FTP server. Besides, when the monitored
environmental parameters such as temperature and humidity are outside of the
normal level including too high or too low, the GSM/GPRS module could send
messages or make calls to the settled phone number.
The GSM/GPRS module provides setting PIN and checking GSM network
status functions that need to be used during each initialization to ensure the
connection to the GSM network with the used SIM card. In the program, the
marking calls and sending messages function are tested on Waspmote v1.2. The
20
functions of uploading files to a FTP server and downloading files from a FTP
server are reserved until they are needed on the communications based on the XBee
ZigBee Pro module and the XBee 868 module [26].
2.2.1.5 The functional requirements of accelerometer module
An accelerometer is embedded on the Waspmote board. It provides several
functions such as getting acceleration on X axis, Y axis and Z axis, checking free
fall status and etc.
In deployment, Waspmote equipped with corresponding sensor could be placed
on trees or wire poles for better collecting specific environmental data. In case of
falling from high places and losing data without any alarms, technicians can use the
accelerometer module to check whether the Waspmote is in free fall status. When
the accelerometer checks the free fall status, it can send an interruption named
ACC_INT which could wake the Waspmote up from sleep or deep sleep mode, then
use the GSM/GPRS module to send messages to technicians as an alarm [27].
The program that includes the functions of getting acceleration on X axis, Y
axis and Z axis and check free fall status has been compiled uploaded and tested on
both Waspmote v1.1 and Waspmote v1.2. The free fall status is simulated by using
hands to protect the Waspmote devices.
2.2.1.6 The functional requirements of the XBee ZigBee Pro module
As the core part of the project, the XBee ZigBee Pro module is used for
sending the collected environmental data from Waspmote to other Waspmotes, from
Waspmote to Waspmote Gateway or from Waspmote to Meshlium based on ZigBee
protocol. As a communication module that costs lots of energy, most of the time the
XBee ZigBee Pro module is in sleep mode until it is the right time to send the
packet to destination. When the collected data is enough to fulfill the packet, the
XBee ZigBee Pro module is turned on and tries to join the network and send
packets.
In the program to make sure that the data is received correctly, the joining
network function has been settled to a maximum trying time value called
MAX_JOIN_NET_TIME while the sending data function has also been settled to a
maximum sending time called MAX_SEND_TIME. For example, in this project the
joining network and sending packets will try at most 10 times to reach a node of the
network. On one hand, this method tries to make a stable connection and tries to
send the packets to the receiver. On the other hand, this method tries to save battery
21
in avoid of wasting too much energy on trying to join network when the network
falls off. The settled maximum time has to be considered both on making stable
connection and saving energy [28].
The first time of turning on XBee ZigBee Pro module, it needs to be initialized
including setting PANID, channel, channel verification, encryption mode and
encryption link key. Then each time when the Waspmote wakes up from sleep
mode, Waspmote just needs to turn on this module with the stored hardware and
network parameters without initialization. The first time of initialization also needs
to print out the network parameters including operating 16-b PAN ID, operating
64-b PAN ID, channel, MAC address and etc.
The sending packet includes three parts; the first part is the header containing
some necessary information. The second part is the data part with the collected
environmental data. The last part is the CRC (Cyclic Redundancy Check) part in
order to check data integrity. The data structure of a sending packet is shown in
Figure 2-2.
Because the collecting data and the sending data frequencies are not the same,
a sending packet may consist of collected data. The aggregated data number of the
sending packet has relationship with the sending data frequency and the collecting
data frequency. The formula to calculate the aggregated data number is shown in
Figure 2-3.
22
After collecting enough data to fulfill a sending packet, the XBee ZigBee Pro
module needs to use the join net function to connect to the network. This module
finds the coordinator in the network with the same PANID, tries at most
MAX_JOIN_NET_TIME times. If it succeeds in joining a coordinator, the return
value is true so the program will go on to send packet. Otherwise, the program
changes into sleep mode and waits until the next loop. If the joining network is
successful, in the sending data part, the data packet is fulfilled with the collected
data stored in the SD card. And the module will try at most MAX_SEND_TIME
times, whether sending data successful or not. Afterwards, whether sending of data
is successful or not, this module will change into sleep mode to save energy.
In sleep mode, all modules except real time clock module are powered off to
reduce energy consumption. After the sleep time that settled in program is over, the
real time clock module and USB module are turned on and Waspmote goes into the
next loop.
This module has to be tested on both Waspmote v1.1 and Waspmote v1.2. The
program includes two parts. The first part is the set up part including the
initialization of real time clock module for setting the time and alarm clock, USB
module for monitoring the running parameters on IDEs serial monitor, XBee
ZigBee Pro module for communication between Waspmote and Gateway or
Meshlium. The second part is the loop part that contains collecting data, joining
network, sending data and sleeping and waking up.
2.2.1.7 The functional requirements of the XBee 868 module
As another important communication module, the XBee 868 module has a
wilder radio range up to 12000m while the radio range of XBee ZigBee Pro module
is just 7000m.The functional requirements of XBee 868 module is similar to XBee
ZigBee Pro module as well as the test programs.
The test of the XBee 868 module includes initialization, collecting data,
storing data in SD card, joining network, sending packets and sleeping and waking
up. Similar to the XBee ZigBee Pro module, energy saving should also be
considered. So in joining network step, the XBee 868 module will try at most
MAX_JOIN_NET_TIME times. And in sending packet step, the XBee 868 module
will try at most MAX_SEND_TIME times. Both values are settled as 10 by default
23
in this project. On one hand, this will do the best to join network and send packets.
On the other hand, this will avoid waste energy when the network falls down [29].
As a communication module, the XBee 868 module should be tested in three
ways: communication between Waspmotes, communication between Waspmotes
and Waspmote Gateway, communication between Waspmotes and Meshlium. In
communication between Waspmotes, this communication is used to test the
self-organized network of Waspmote. Each Waspmote node works as a sender as
well as a receiver. After sending a packet, the sender node will wait a specific time
to receive back messages. After receiving packet, the receiver node will send the
assurance packet to the sender node. The communication between Waspmote and
Waspmote Gateway works as a simple simulation of communication between
Waspmote and Meshlium. Besides, this could also be used for checking multiple
Waspmotes connecting to one coordinator. The most important part is the
communication between Waspmote and Meshlium because this will be used in
agriculture for monitoring crops development.
Considering of saving energy, most of time the XBee 868 module is in sleep
mode. When enough data have been collected, this module wakes up. Similar to the
XBee ZigBee Pro module, it only needs one initialization on the first time, in other
cases it just needs to be turned on. After checking the network with the same
PANID and channel to find the coordinator, the XBee 868 module will send a
packet and goes back into sleep mode again.
The XBee 868 module is a new hardware in Waspmote v1.2 tool kit. So it has
only been tested on this version of Waspmote. The program has two parts. The first
part is the set up part for initialization of the related modules including USB
modules, real time clock modules and the XBee 868 modules. The second part is the
loop part for collecting specific environmental data including temperature data from
the MCP9700A sensor, humidity data from the 808H5V5 sensor, soil moisture from
the soil moisture sensor, battery level data from the power module.
on the specific needs of the application. The Waspmote Gateway equipped with the
XBee ZigBee Pro module is shown in Figure 2-4.
Figure 2-4 A Waspmote Gateway with the XBee ZigBee Pro module
powered by solar panel, battery or both and can be integrated with a GPS module
for monitoring of vehicle applications and mobile applications. Because of the
wrapped aluminum IP-65 enclosure, the Meshlium is able to be placed outside.
Libelium provides a Manager System that works as a web application for
developers to control Meshlium quickly and easily. The Manager System provides
graphical configurations of WIFI, ZigBee, Bluetooth and 3G/GPRS module and
storage options of sensor and received data
[30]
Figure 2-5 A Meshlium with two WFIF antennas and two ZigBee antennas
such as temperature, humidity, soil moisture, light condition, air pressure and etc.
At most 14 different sensors can be plugged on the agricultural sensor board at most
at the same time. The specifications and electrical characteristics of an agricultural
sensor board are shown in Table 2-1. The top side of the agricultural sensor board
[32]
collecting temperature data from the MCP9700A sensor, humidity data from the
808H5V5 sensor
[33]
, soil moisture from the soil moisture sensor and battery level
data from the power module of the Waspmote. The agricultural sensor board is
plugged on the Waspmote v1.1 while the corresponding sensors are plugged in the
pins of the agricultural sensor board.
The agricultural sensor board can be programmed through the Waspmote
program, in the collecting data part of communication based on the XBee ZigBee
Pro module, the agricultural sensor board needs to be turned on each time before
getting the data of corresponding sensors. After getting data, the agricultural sensor
board has to be turned off for saving energy [34].
Table 2-1 Specifications and electrical characteristics of the agricultural sensor board [32]
Hardware Parameter
Value
Weight
20 g
Dimensions
3.3V & 5V
200mA
400mA
28
In the new Waspmote development tool kit associated to the Waspmote v1.2,
three XBee 868 modules, one GSM/GPRS module with a specific antenna and two
expansion boards have been added.
GSM/GPRS module and etc. The XBee ZigBee Pro module and XBee 868 module
are the most important parts for the communication between Waspmote and
Waspmote, communication between Waspmote and Gateway, communication
between Waspmote and Meshlium. Other parts are basic parts that could be used in
the three kinds of communications. The requirement analysis makes a brief
introduction of each module, focuses on the needed functions of each module and
talks about how to test and program these modules, including testing process and
important parts.
The un-functional requirement analysis focuses on the compatibility of the
system between Waspmote v1.1 and the Waspmote v1.2. Considering the changes
in the hardware and in the API, the system will be tested on both hardware versions.
30
31
In the test of the real time clock module, functions including setting and
reading time, setting and reading alarm clocks, using embeded thermometer to get
32
In the set up part, the USB module is turned on for monitoring the running
parameters of the program on IDEs serial monitor, the real time clock module is
turned on for setting time. After setting time, the getting time function is used to
show local time. After the initializaiton part, program goest into loop part.
In the loop part, the thermometer and the two alarm clocks have been tested.
Firstly, using the embeded thermometer to get temperature in celsius degrees, then
set the two alarm clocks in different modes to test the wake up interruption as well
as the sleep mode. The alarm clock can be settled in two ways: the absolute way and
the offset way. In absolute mode the Waspmote receive interruption according to
the right time of day or date. In offset mode the Waspmote receive interruption
every specific interval. After setting and getting alarm clock, the Waspmote changes
33
into sleep mode in which all modules except the rea time clock module have been
turned off. When the real time clock interruption RTC_INT is received by the
Waspmote, Waspmote wakes up and turns on the USB module and real time clock
module as well as showing the wake up time. The program will go to the next loop.
The six alarm clock modes of alarm clock 1 is shown in Table 3-1.
Table 3-1 The six alarm clock modes of the alarm clock 1
Mode of alarm clock 1
Functions
RTC_ALM1_MODE1
RTC_ALM1_MODE2
RTC_ALM1_MODE3
RTC_ALM1_MODE4
RTC_ALM1_MODE5
Match seconds
RTC_ALM1_MODE6
34
creating this constructor. The class diagram of class WaspSD is shown in Figure
3-3.
Waspmote has 8 KB SRAM, 4 KB EEPROM and 128 KB flash memory. These
memories are not enough for storing the environmental data collected by
corresponding sensors. So the 2GB extended SD card is necessary in this project.
Apart from checking whether there are blocks, the program also needs to test the
file editing functions (reading, writing, appending and deleting) and folder editing
functions (creating and deleting).
The test program includes two parts, the set up part and the loop part. In the set
up part, the USB module is turned on for showing the running parameters on the PC
screen. The SD card module is also turned on. The output basic parameter of SD
card includes the check whether the SD card is inserted or not, the disk size of SD
card, the total number of files in the card. Then, the program makes and removes
directories, shows the content of SD card module in tree architecture, creates file
35
with the name format that there are at most 8 characters in the name and at most 3
characters in the file suffix and appends sentences into the created file.
In the loop part, the program just appends sentences into the created file in
each loop and used two sub functions to show the content of the file. One sub
function is reading file by lines. The other function is reading file by buffer. Due to
buffer size, there is a limitation in size. If the read data is bigger than the size of the
buffer, the function will activate the TRUNCATED_DATA value in the flag. This
value is checked to ensure the data integrity. The activity diagram of the SD card
module is shown in Figure 3-4.
libraries
are
WaspGPRS_Pro.h,
WaspGPRS_Pro.cpp
and
WaspGPRS_Proconstans.h.
An object called GPRS_Pro from class WaspGRPS_Pro is created inside the
Waspmote GPRS_Pro library and is public to all libraries. In creating the object
GPRS_Pro, some variable have already been initialized with a default value. For
example, the baudrate defines baud rate used to transmit data, the socket
defines the socket used to communicate with the Waspmote, and the pwrMode
defines the power mode. The class diagram of the class WaspGPRS_Pro is shown in
Figure 3-5.
The testing program has two parts: the set up part and the loop part. In the set
up part, the USB module is turned on for showing the running parameters on the PC
screen and the GPRS_PRO module is turned on for checking the GSM network
service. In the initialization of the GPRS_PRO module, the PIN code is checked
firstly, followed by a wait for the connection to the network. After connected to
GSM network successfully, the program goes into loop part.
The loop part has several sub functions such as making and receiving calls,
sending and receiving messages, download files from FTP server, uploading files to
FTP server, getting IMSI (International Mobile Subscriber Identification Number)
37
and IMEI (International Mobile Equipment Identity), etc. The activity diagram of
the GSM/GPRS module is shown in Figure 3-6.
Power down
--
Normal mode
1000
Lower-mode 1
0.5
Lower-mode 2
Lower-mode 3
Lower-mode 4
Lower-mode 5
10
38
The acceleration sensor has 3 scales including 2G, 4G, and 8G and can
measure accelerations with output radio rates from 0.5 Hz to 1 KHz. The
accelerometer has 7 power modes. The relationship between output data rates and
the power modes is shown in Table 3-2.
The micro controller has communication with the accelerometer sensor by the
2
I C interface, in which INT pin is used to generate the interruptions while SCL pin
and SDA pin are used for task. The four types of events mentioned before (free fall,
inertial wake up, 6D movement and 6D positions) are able to generate interrupts.
Related API libraries are WaspACC.cpp and WaspACC.h. Besides, the times and
thresholds of those four events are also set in WaspACC.h file by default.
An object called ACC from class WaspACC is created inside the Waspmote
ACC library and is public to all libraries. No variables are initialized by default
when creating the constructor. The class diagram of the class WaspACC is shown in
Figure 3-7.
The accelerator module testing program incudes two parts: the set up part and
the loop part. In the set up part, USB module is turned on for monitoring accelerator
parameters on serial monitors. Accelerator module is also initialized and turned on.
In loop part, there are two sub functions. One is for getting accelerations on the
X, Y and Z axsis, this sub function needs the Waspmote be placed in different
directions, the other sub function is for testing free fall interruption. In testing free
fall interruption, the accelerometer is initialized with a ful-scale value choosen from
39
2G, 4G and 6G. After the free fall interrup is setted, Waspmote changes intor sleep
mode that the main program is paused and the micro controller passes to a latent
state, from which it can be woken by accelerator interruption. After checking the
free fall status, the Waspmote wakes up and clear the interruption flags, turn on the
USB module because it is turned off in sleep mode. The activity diagram of the
accelerator module is shown in Figure 3-8.
In real testing, the Waspmote equipped with accelerator module should be
tested by hand for simulating the free fall situation. The free fall function checks the
accelerometer on the X, Y and Z axes. If the accelerometer on one axis is lower than
a specific level, the free fall interruption will get by Waspmote interruptions module.
This level of checking free fall interruption can be set in program as well as the
accelerometers full-scale value. Each time before the accelerometer is used, the
check register should be checked for proper functionality of the accelerometer.
40
Protocol
Frequency
Power
Range
Number of channel
XBee-ZB-Pro
ZigBee-Pro
50mW
7km
13
XBee-ZB
ZigBee-Pro
2mW
500m
16
As ZigBee is supported in the IEEE 802.15.4 link layer, the frequency used in
XBee ZigBee is the free band of 2.4 GHz, using 16 channels with a bandwidth of 5
MHz per channel while the number of channels of XBee ZigBee PRO is limited to
13. The channels and frequencies of XBee ZigBee Pro module and XBee ZigBee
module are shown in Table 3-4.
Table 3-4 Channels and frequencies of XBee ZigBee module
Channel Number
Frequency
Supported by
0x0B Channel 11
XBee-ZigBee-PRO/XBee-ZigBee
0x0C Channel 12
XBee-ZigBee-PRO/XBee-ZigBee
0x0D Channel 13
XBee-ZigBee-PRO/XBee-ZigBee
0x0E Channel 14
XBee-ZigBee-PRO/XBee-ZigBee
0x0F Channel 15
XBee-ZigBee-PRO/XBee-ZigBee
0x10 Channel 16
XBee-ZigBee-PRO/XBee-ZigBee
0x11 Channel 17
XBee-ZigBee-PRO/XBee-ZigBee
0x12 Channel 18
XBee-ZigBee-PRO/XBee-ZigBee
0x13 Channel 19
XBee-ZigBee-PRO/XBee-ZigBee
0x14 Channel 20
XBee-ZigBee-PRO/XBee-ZigBee
0x15 Channel 21
XBee-ZigBee-PRO/XBee-ZigBee
41
Frequency
Supported by
0x16 Channel 22
XBee-ZigBee-PRO/XBee-ZigBee
0x17 Channel 23
XBee-ZigBee-PRO/XBee-ZigBee
0x19 Channel 25
XBee-ZigBee
0x1a Channel 26
XBee-ZigBee
Figure 3-9 Network architecture of Waspmote XBee ZigBee Pro module - Star topology
42
Related
API
libraries
are
WaspXBeeCore.h,
WaspXBeeCore.cpp,
In Waspmote XBee ZigBee Pro module, the WaspXBeeZB class inherits from
the class WaspXBeeCore. Class WaspXbeeCore is one of the most important
classes in XBee communication modules, it extends various classes like class
WaspXBee802, class WaspXBee868, class WaspXBee900, class WaspXBeeDM
and class WaspXBeeZB. Most basic functions of class WaspXBeeZB are inherited
from the class WaspXBeeCore, including functions related to setting network
parameters
like
setPAN
and
getPAN,
setChannel
and
getChannel,
functions
related
getOperating16PAN,
to
setting
its
getOperating64PAN
43
unique
and
etc.
network
The
parameters
class
diagram
like
of
communication
between
Waspmote
and
Waspmote,
Meshlium. The Meshlium will receive these packets, extract and store their data in
local files, local database or external database on Internet.
In communication between Waspmote and Waspmote, Waspmote node A and
Waspmote node B both have to realize sending packets function and receiving
packets function. The progarm of node A has two parts: the set up part and the loop
part. In set up part, the USB module is initialized for transmitting running
parameters on IDEs serial monitor. The real time clock module is turned on for
counting waiting time in receiving packets function, the XBee ZigBee Pro module
is initialized including setting PANID that identifies the network, setting channel
for communication, setting node verification for finding the coordinator in network,
setting encryption mode and link key for security [38] and etc. At last, the parameters
of the network including 16-b PANID, 64-b PANID and channel are printed out in
serial monitor. Then node A tries to join the network and find the cordinator.
Considering
saving
energy,
the
joining
network
has
time
limit
45
In loop part, the program gets right now time in format hour/minute/second
with the help of real time clock module, fulfills the header of the sending packet
with the right now time as well as other necessary information like MAC address of
destination and sends the packet. Considering saving energy aspect, the sending
time has a limit MAX_SEND_TIME. If in MAX_SEND_TIME times, the packet is
not sent successfully, this packet will be discarded. On one hand, this action does
the best to send packets to destination. On the other hand, this action avoids
waisting energy when the network falls down. After sending a packet, the LEDs
blink as a signal for the technicians, the memory of the packet is freed for saving
memory, otherwise the memory will still be occupied. If the packet is sent
successfully, the program goes into receiving packets function. In receiving
function, the program waits a specific programmed time to receive the
acknowledgment packets sent by node B. In the waiting loop, this receiving packets
function stays in a loop to check the XBee ZigBee Pro module and receive packets.
When packet is received, the parameters of the received packet including source
MAC address, packet data, RSSI signal and etc. will be printed out on the serial
monitor. At last, this received packet will be freed for saving memory. The
Waspmote XBee ZigBee Pro module provides a queue for the receiving packets and
according to the first-come-first-serve rule, the packets are dealed with in order.
Besides, the length of this queue can be fixed in the program.
The program of node B is similar to the program of node A, including two
parts, the set up part and the loop part, the only difference is on the order of sending
and receiving functions in the loop part. In set up part, the USB module is turned on
for checking the running status of Waspmote and real time clock module is turned
on for setting time and alarm clock. The initialization of XBee ZigBee Pro module
includes setting PANID for recongnizing network, encryption mode and link key for
security, channel for wireless communication and etc. The initialization parameters
need to be saved in Waspmote so that XBee ZigBee Pro module will use the saved
parameters to join network and find the coordinator in next time without another
initializaiton. The check of coordinator and network is also necessary. If it joins a
network successfully, it will go to the loop part. In this communication, node A
works as end deivice whitle node B works as a coordinator. The activity diagram of
receiver node is shown in Figure 3-13.
46
In loop part, node B waits a specific programmed time to wait for the packets
sent by node A in the same network. When received packets, the source MAC
address, packet data, RSSI signal and etc. will be shown on the serial monitor and
the memory of the packet will be freed for next coming packets. If node B receives
packet successfully, node B will send back an assurance packet that only includes a
sentence as a ACK message back to node A. The packet is also needed to be
fulfilled with other necessary information like destination parameters including
MAC address of node A. Similar to node A, the trying times of sending function
also has a limit called MAX_SEND_TIME. If in MAX_SEND_TIME times, the
packet is not sent successfully, this packet will be abandoned for saving energy. On
one hand, this action does the best to send packets to node A, on the other hand, this
action avoids waisting energy when the network falls down. After sending packet,
the LEDs blinks as a signal for the techinicians, the memory of the packet will be
freed for saving memory, otherwise the memory will all be occupied.
47
Figure 3-14 Activity diagram of the Waspmote XBee ZigBee Pro module
48
In set up part, the USB module is turned on for monitoring the content of the
sending packets. The real time clock module is turned on for setting time and alarm
clock, the XBee ZigBee Pro module is turned on for wireless communication. The
initialization of XBee ZigBee Pro moudle includs setting PANID that identifies the
network, setting encryption mode and link key for secruity, setting channel for
communication. The link key has 16 bytes. The encryption mode is AES encryption.
After saving the hardware and network parameters of XBee ZigBee Pro module for
the use in the loop part, the parameters of the network including operating 16-b
PANID, operating 64-b PANID, channel and etc. are printed to the serial monitor on
the IDEs serial monitor. Then the data that will be used in the packet is initialized
with the specific format. The activity diagram of Waspmote node is shown in Figure
3-14.
In loop part, the use of Waspmote agricultural sensor board depends on the
Waspmote board version. Because the Waspmote v1.2 intergrates some sensor pins
on its board, so the agricultural sensor board is only used on Waspmote v1.1.
Considering Waspmote v1.2, node A is equipped with MCP9700A sensor for
collecting temperature data and 808H5V5 sensor for collecting humidity data while
node B has no sensors. After collecting data, there is a sub function to check
whether the collected quantity is enough for fulfilling a packet. If enough data is
collected, the XBee ZigBee Pro module is turned on and saved parameters are
restored. Then the node tries to join the network. This joining network step will be
executed at most MAX_JOIN_NET_TIME times and the sending packets step will
be tried at most MAX_SEND_TIME times. In this project, these two values are
settled as 10 by default. On one hand, this action does the best to send packets to the
Waspmote Gateway. On the other hand, the times limit avoids of waisting energy
when then network falls down. In sending packet function, the destination MAC
address parameter is set as the Waspmote Gateways MAC one. After sending a
packets successfully, the Waspmote changes into sleep mode for saving energy. All
modules except the real time clock module are powered off. A real time clock
interruption RTC_INT will be caught when the specific programmed sleep time is
over. When Waspmote wakes up, the USB module and real time clock module are
turned on because these modules are turned off under sleep mode. This is one loop,
the loop part will repeat these tasks again and again.
49
50
Function
Content
Node A
Waspmote.
Node B
Node C
moisture sensor.
Frequency
Transmission
Range
Power
XBee 868
869.4869.65
Number
of
channel
315 mW
12 km
MHz
The topology used in the communication based on XBee 868 module is a star
topology. The network architecture of XBee 868 module is shown in Figure 3-15,
nodes in this type of network are able to establish point to point connections with
other
brother
nodes
through
MAC
address.
Related
API
libraries
are
51
Figure 3-15 Network architecture of Waspmote XBee 868 module - Star topology
In Waspmote XBee 868 module, the WaspXBee868 class also inherits from
the class WaspXBeeCore as the WaspXBeeZB class. Most basic functions are
inherited from the class WaspXBeeCore, including functions related to setting
network parameters like setPAN and getPAN, setChannel and getChannel,
setEncryptionMode, setLinkKey and etc., functions related to sending and
receiving packets like setDestinationParams, sendXBee, treatData and etc. Class
WaspXBee868 also has its unique functions including initialization function like
WaspXBee868, functions related to setting its unique network like getDeviceType,
setMultipleBroadcast and etc. The class diagram of the class WaspXBee868 is
shown in Figure 3-16.
Compared to the XBee ZigBee Pro module, as a new hardware provided in
Waspmote v1.2 development tool kit that has higher sensitivity and more powerful
transmission radio power, the XBee 868 module has a longer radio range as far as
12000m while the range of XBee ZigBee Pro is 7000m. The test program of XBee
868 also includes two parts: the set up part and the loop part.
In the set up part, the USB module is turned on for checking the sending and
receiving status of the packets and real time clock module is also turned on for
setting time and alarm clock. The initialization of XBee 868 moudle includs setting
PANID that identifies the network, setting channel for wireelss communication,
setting encryption mode and link key for security. The link key has 16 bytes using
AES encryption. After saving the parameters of the XBee 868 module for the use in
the loop part, the parameters of the network including node identifier and etc. are
52
printed out on the IDEs serial monitor. Then the data that will be used in the packet
is initialized with the specific format. Afterwards, the program goes into loop part.
The set up part of the XBee 868 module is simpler than the set up part of the XBee
ZigBee Pro module.
XBee 868 module is lower than the XBee ZigBee Pro module. When the sending
packets step succeeds, the Waspmote changes into sleep mode and waits for the
alarm clcok interruption RTC_INT. When the sleep time is over and RTC_INT
interruption is detected, Waspmote wakes up part. The it turns on USB module and
real time clock module and goes into next loop. The loop part keeps on collecting
data, storing data, check number of data, sending packet, sleeping and waking up.
Since XBee 868 module is more powerful, the joining network time and sending
packets are significantly less than the joining network time of the XBee Zig Bee Pro
module. The activity diagram of the Waspmote XBee 868 module is shown in
Figure 3-17.
54
Table 3-7 Firmware parameters of XBee 868 and XBee ZigBee Pro module
Module
Modem
Function Set
Version
XBee 868
XBP8-DP
1061
XBP24-ZB
21A0
In X-CTU
[39]
Figure 3-18 Parameters of the Waspmote Gateway equipped with XBee 868 module
56
In X-CTU, the parameters of XBee ZigBee Pro module have been divided into
8 parts, including networking, addressing, RF interfacing, security, serial
interfacing, sleep modes, I/O settings and diagnostic commands. In this project,
only the networking, security and serial interfacing are used. In networking part, the
modem VID is settled to identify module itself. In addressing part, the PANID is
settled to an identification of the network. The Waspmote will join the Gateway that
has the same PANID. In security part, the encryption enable is settled to enable
ZigBee encryption with a 16 characters key. In serial interfacing part, the baud rate
is settled to 115200 for the transmission rate of a Waspmote. The API enable is
settled to 2 for API with escapes. The parameter details of the Waspmote Gateway
equipped with the XBee ZigBee Pro module is shown in Figure 3-19.
Figure 3-19 Parameters of Waspmote Gateway equipped with XBee ZigBee Pro module
57
Internet. In order to give Internet access, the Meshlium uses the Ethernet connection
and gets an IP from a network using DHCP protocol. The model of Meshlium AP is
shown in Figure 3-20.
Meshlium can take the sensor data which comes from a ZigBee Wireless
Sensor Network (WSN) made with Waspmote sensor devices and send it to the
Internet using the Ethernet interface. Users can also connect directly to the
Meshlium using the WIFI interface to control it and access to the sensor data. The
model of the Meshlium ZigBee AP is shown in Figure 3-21.
59
joining network part, sending packets part and etc. The time of XBee 868 module
for finding coordinator and joining network is shorter than the time of XBee ZigBee
Pro module because of the transmission power.
61
Content
Operating system
Windows 7 Professional
System memory
4 GB
Other hardware
Software
1)Waspmote Pro IDE version 03 with Waspmote Pro API version 003
X-CTU provided by Digi
2)Firefox web browser
3)Putty
62
No
YES
Create a packet and fill the packet with the
collected data such as temperature,
humidity, soil moisture, battery level. Use
the XBee module to send the packet
XBee ZigBee Pro module is the core part of the project. The process diagram
of XBee ZigBee Pro module is shown in Figure 4-1. As shown in this figure, the
first step is the set up part. The rest is the loop part. In the set up part, the USB
module is turned on for monitoring the running parameters on IDESs serial
monitor, the real time clock module is turned on for setting time and alarm clock,
63
the XBee ZigBee Pro module is turned on and initialized for wireless
communication. The initialized parameter of XBee ZigBee Pro module includes
setting PANID, channel, encryption mode, link key and etc. After initialization of
all modules, the program goes into loop part.
In the loop part, environmental data including temperature and humidity and
soil moisture are collected by corresponding sensors like temperature sensor
MCP9700A and humidity sensor 808H5V5 and soil moisture sensors, battery level
data is collected by power module. Then the collected data are store in SD memory
card. After checking whether the stored data is enough to fulfill a packet with a
level of MAX_NUM_IN_PACK, the process goes into two different ways. If the
data is not enough, all the modules are powered off and the Waspmote changes into
sleep mode to save energy waiting for the next loop. If the data is enough, a new
packet is created. The Waspmote uses the stored data to fulfill the created packet
and adds other necessary information including MAC address of the Meshlium and
etc. Afterwards, the initialized XBee ZigBee Pro module is turned on and the
Waspmote tries to join a network and find a coordinator. The joining network step
will be executed at most MAX_JOIN_NET_TIME times and the sending packets
step will be executed at most MAX_SEND_TIME times. On one hand, this action
does the best to send packets to Waspmote Gateway or Meshlium. On the other
hand, the time limit avoids the waste of energy when the network falls down. After
sending the fulfilled packet to the Meshlium, the program goes into sleep mode and
all the modules are powered off. When the settled sleep time is over, the real time
clock interruption RTC_INT is caught and the Waspmote wakes up from sleep
mode, goes back to work mode and turns on all the modules including the USB
module and the real time clock module and goes into next round.
[40]
. The
Waspmote IDE is based on Arduino IDE which is an open project. Besides the
compiling and uploading functions, the serial monitor is an important part of the
Waspmote IDE. The serial monitor is used for monitoring the running parameters of
the Waspmote. Through the USB module, the Waspmote can show the running data
64
on serial monitor for developers to check the status of the program. In addition, the
Waspmote IDE also provides some examples for each different modules. The
Waspmote IDE is shown in Figure 4-2.
65
Beyond the Meshlium Manager System, Meshlium can also be managed using
SSH (Secure Shell) protocol/software. In this project, Putty software is used to
access to the Meshlium configuration. After setting some network parameters
including IP address and port of the Meshlium, login user and password, the file
system of Meshlium can be shown in Putty. The file architecture of Meshlium is
similar to a Linux operating system. Through command /etc/init.d/ZigbeeScanD.sh
stop, we can get the data sent by the Waspmote wireless sensor network. Through
the command capturer S0 38400, the Meshlium will capture the data on its S0
port with a data rate of 38400 bits/second. The data sent by Waspmote nodes and
received by the Meshlium can be shown and updated in Putty in real time. The SSH
software Putty used for showing the data of the Meshlium is shown in Figure 4-4.
Figure 4-4 SSH software Putty used for showing the data of the Meshlium
66
In the loop part, firstly, it gets the temperature using the embedded
thermometer, then, it shows the current time and sets alarm clock with offset time
mode, in this test, the settled sleep time of Waspmote is 20 seconds. When the
programmed sleep time is over, Waspmote detects the RTC_INT interruption,
wakes up and shows the wake up time. Then the program goes into the next loop.
The serial monitor of the real time clock module is shown in Figure 4-5.
MCP9700A, get humidity from humidity sensor 808H5V5. These data will be used
in XBee ZigBee Pro module. In a Waspmote v1.1, these sensors need the Waspmote
Agricultural Sensor Board to be used on the Waspmote while in a Waspmote v1.2,
these sensors can be plugged directly on Waspmote board because of the hardware
changes. The serial monitor result of the utility module is shown in Figure 4-6 and
Figure 4-7.
69
free fall is detected, the free fall interruption ACC_INT will be created by the
accelerator module. After detecting the interruption, Waspmote wakes up, turns on
USB modules and accelerator module and goes into another loop. The serial
monitor of the accelerator module is shown in Figure 4-10.
72
the time gotten from the real time clock module and the data sent by the receiver is
a sentence for assurance of the right receiving packets sent by sender.
In the set up part, the real time clock module is turned on for setting time and
alarm clock. USB module is turned on for showing parameters of the program on
the IDEs serial monitor. Besides, hardware and network parameters of the XBee
ZigBee Pro module are also initialized including setting PANID for identifying the
network, setting encryption mode and link key for security, setting channel
verification for finding a coordinator and etc. The basic parameters of the network
are also shown such as operating 16-b PAN ID, operating 64-b PAN ID, channel,
MAC address and etc. Afterwards, the sender tries to join a network and find the
coordinator. The joining network action will try at most MAX_JOIN_NET_TIME.
This value is defined by users according to different network environments. In this
project, it is settled to 10 by default. Besides, the sent data is also initialized. After
that these previous tasks are finished, the program goes into loop part. The initial
part of the sender is shown in Figure 4-11.
Figure 4-11 The initial part of the sender in communication among Waspmotes
The loop part includes three sub functions: the collecting data function,
sending packet function and the receiving packet function. The first step is the
73
collecting data part. In the sub function collecting data, the first parameter is the
sensor type. According to the sensor type, different values including time, battery
level, temperature data gotten by the embeded thermometer , temperature gotten by
the temperature sensor MCP9700A, humidity gotten by the humidity sensor
808H5V5 can be collected and stored as string data. After the coordinator has been
already found and the network been already joined in, in the sending part, the
packet is directly sent to the receiver. After sending a packet the sender will wait for
the acknowledgment message sent from the receiver to make sure that the packet is
well received. When the time is off or the ACK message is gotten, the test program
goest into the next loop. The sending data part of the sender is shown in Figure
4-12.
Figure 4-12 The sending part of the sender in communication among Waspmotes
Considering the receiver, the set up part of the receiver is as same as the sender
one. The set up part includes turning on USB module and real time clock module as
well as initializaton of XBee ZigBee Pro module. The difference is on the firmware
of the XBee module. The firmware of the receiver is the coordinator API while the
firmware of the sender is the router API. The firmware of receiver is settled by
X-CTU. Besides, the receiver will also join a network and find a coordinator in the
set up part. Because the receiver works as a coordinator in the network, the join
74
network step will try 0 times After sending packets, sender will show the
parameters of the packet including frame length, frame type, hex frame, string
frame and etc.
In the loop part, the receiver waits for a packet sent by the sender. After
receiving a packet, the receiver shows the parameters of this one including source
MAC address, packet data, node identifier, RSSI (Received Signal Strength
Indication) and etc. Then, the receiver will send a packet fulfilled with a
acknowledgment message to the source address and goes into another loop. The
loop part of the receiver that includes receiving data packets and sending
acknowledgment packets is shown in Figure 4-13.
Figure 4-13 The receiving part of the receiver in the communication among Waspmotes
will collect soil moisture data from a soil moisture sensor. In test program, both
sensors are connected to PC B through USB cable for monitoring the parameters of
running programs. After collecting enough data, both Waspmote nodes send packets
to Waspmote Gateway based on ZigBee protocol, Waspmote Gateway is also
connected on PC A for monitoring the received packets. The architecture of the
communication between Waspmote and Waspmote Gateway is shown in Figure
4-14.
Figure 4-14 Architecture of the communication between Waspmote and Waspmote Gateway
In this communication, the set up part of Waspmote node A is similar to the set
up part of the communication among Waspmotes. The firmware of the Waspmote
node A is router API as well as the Waspmote node B one. The firmware of the
Waspmote Gateway is the coordinator API. In set up part, the RTC module and
USB module are turned on. The XBee ZigBee module is initialized including setting
PANID, encryption mode, link key, channel verification and etc. The basic
parameters of the network are also shown such as operating 16-b PAN ID, operating
64-b PAN ID, channel, MAC address and etc. In this communication, the sleep and
wake up functions are needed. So the joining network will be done in each loop.
When a Waspmote wakes up from the sleep mode, all modules are turned on,
Waspmote nodes need to rejoin the network and refined the coordinator, otherwise
the packets will not be sent correctly.
76
The loop part includes again three sub functions, the collecting data function,
the sending packets function and the sleeping and waking up function. The first step
is the collecting data. In this sub function, the input parameter is the sensor type.
According to the sensor type value, different values including time, battery level,
temperature gotten by the embedded thermometer, temperature gotten by the sensor
MCP9700A, humidity gotten by the sensor 808H5V5 can be collected and stored as
string data. Because the frequency of collecting data is different from the frequency
of sending data, several data will be integrated in a packet. So the program will test
whether collected data is enough to fulfill a packet. In this project, the variable
MAX_NUM_IN_PACK indicates the number of data in a packet. This variable is
settled to 3 by default. If the collected data is enough, program goes into send
packets function and after goes into sleep and wake up function. Otherwise,
program goes into sleep and wake up function directly. In the sending packets
function, a Waspmote needs to join a network and find a coordinator. This function
is used only when the data is enough to send a packet in the purpose of reducing
power consumption. In joining network sub function, a Waspmote will try at most
MAX_JOIN_NET_TIME times. Otherwise, this action will be abandoned for saving
energy. After finding a coordinator successfully, a Waspmote fulfills the packet
with the collected data as well as other necessary information. For example, Node A
inserts A into the header of the packet as identification of the packet while node B
inserts B into the header. Besides, the fulfilled data of node A is temperature data
and humidity data while the fulfilled data of node B is soil moisture data. The
sending packet function will try at most MAX_SEND_TIME times. If this action
does not succeed, the packet will be discarded for saving energy. After sending a
packet, the data string is cleared and program goes into sleep and wake up
function. In the sleep and wake up step, a Waspmote will change into sleep mode
and wait for a wake up interruption. The sleep time is settled by users for reducing
power consumption. When a Waspmote wakes up, the RTC module and USB
module are turned on. Then the program goes into next loop. The serial monitor of
the Waspmote node A is shown in Figure 4-15 while the serial monitor of the
Waspmote node B is shown in Figure 4-16.
77
78
79
Figure 4-19 Collecting data part in the communication beween Waspmote and Meshlium
80
When the collected data is enough, program goes into the sending packet
function. In this part, firstly, the Waspmote tries to join a network and find a
coordinator. Since the XBee ZigBee Pro module has already been initialized, this
module just needs to be turned on and can find coordinator automatically. In the
program, the number of joining network attempts is counted and shown in the
serial monitor. After sending a packet, the program goes into sleep and wake up
function. In this function, the Waspmote will change into sleep mode, and wait for a
wake up interruption. The sleep time is settled by users for reducing power
consumption. When the Waspmote wakes up, the RTC module and the USB module
are turned on. Then program goes into next loop. The sleep time, alarm clock time
and wake up time are all shown in the IDEs serial monitor for checking the status
of the running program. The sending packet part of the Waspmote node A is shown
in Figure 4-20. The sending packet part of the Waspmote node B is shown in Figure
4-21.
81
82
83
Conclusion
With the development of wireless sensors, wireless sensor network has been
applied in many aspects of day-to-day life. This document focuses on the
application of wireless sensor network in agriculture especially for plants
development. With the help of the wireless sensor network, people could monitor
the environmental parameters of crops in real-time from remote places. This project
is based on an emerged wireless sensor device called Waspmote developed by
Libelium Company. Other needed accessories are agriculture sensor board,
Waspmote Gateway and Meshlium. In the final system, multiple Waspmotes use
corresponding sensors to collect environmental data and use their wireless
communication modules to send the collected data to a Meshlium. Then, the
Meshlium stores the data in a local database or local files. Meshlium can also
update the received data to a specific server in real-time. To realize the final
wireless sensor network, the different modules of a Waspmote were analyzed and
tested in this project, including USB modules, utility modules, real time clock
modules, accelerometer modules, XBee ZigBee Pro modules and etc. These
modules are integrated in the wireless network communication as sub functions.
This document includes four parts. Firstly, a brief introduction of the
background and the related research are made. Secondly, the project from the
perspective of system requirements is analyzed. Thirdly, the design and
development of the project are shown in details according to the different modules.
Finally, the process diagram and tests of all the modules as well as the different
types of wireless communications are shown. As the project needs to upload code
on hardware, the system test includes both hardware and software. In the fourth
chapter, the result of the tests is shown in many figures clearly.
This project can be further extended. The next goal of this project is to focus
on the Meshlium and other Waspmote modules. In Meshlium, the files that control
the receiving data format can be modified for recognizing different data formats.
Besides, the local database of Meshlium can be optimized. Also, other Waspmote
modules can be added like video camera module for the visual monitoring of the
crops development.
84
References
[1] Definition of wireless sensor, available from
http://www.omega.com/prodinfo/wirelesssensors.html
[2] Libelium Comunicaciones Distribuidas S.L. 50 Sensor Applications for a
Smarter World. 14~15
[3] D. Estrin, R. Govindan, J. Heidemann, S. Kumar, Next century challenges:
scalable coordination in sensor networks, ACM MobiCom99, Washingtion,
USA, 1999, pp. 263270.
[4] I. F. Akyildiz, W. Su, Y. Sankarasubramaniam, E. Cayirci. Broadband and
Wireless Networking Laboratory, School of Electrical and Computer
Engineering, Georgia Institute of Technology, Atlanta, GA 30332, USA.
Wireless sensor networks: a survey. Computer Networks 38 (2002) 393422.
[5] A. Chandrakasan, R. Amirtharajah, S. Cho, J. Goodman, G. Konduri, J. Kulik,
W. Rabiner, A. Wang, Design considerations for distributed micro-sensor
systems, Proceedings of the IEEE 1999 Custom Integrated Circuits Conference,
San Diego, CA, May 1999, pp. 279286.
[6] P. Bonnet, J. Gehrke, P. Seshadri, Querying the physical world, IEEE Personal
Communications (October 2000) 1015.
[7] C. Herring, S. Kaplan, Component-based software systems for smart
environments, IEEE Personal Communications, October 2000, pp. 6061.
[8] I. A. Essa, Ubiquitous sensing for smart and aware environments, IEEE
Personal Communications (October2000) 4749.
[9] P. Johnson et al., Remote continuous physiological monitoring in the home,
Journal of Telemed Telecare 2 (2) (1996) 107113.
[10] M. Ogawa et al., Fully automated biosignal acquisition in daily routine
through 1 month, International Conference on IEEE-EMBS, Hong Kong, 1998,
pp. 19471950.
[11] N. Noury, T. Herve, V. Rialle, G. Virone, E. Mercier, G. Morey, A. Moro, T.
Porcheron, Monitoring behavior in home using a smart fall sensor, IEEE-EMBS
Special Topic Conference on Microtechnologies in Medicine and Biology,
October 2000, pp. 607610.
85
[12] G.
J.
Pottie,
W.
J.
Kaiser,
Wireless
integrated
network
sensors,
P.
Seshadri,
Querying
the
physical
world,
IEEE
Personal
comunicacions
distribuidas
S.L.
Waspmote
interruptions
[26] Libelium
comunicacions
distribuidas
S.L.
Waspmote
GSM/GPRS
comunicacions
distribuidas
S.L.
Waspmote
accelerometer
87
Acknowledgements
First of all, I would like to express my thankfulness to my four tutors, they are
Mrs. Shu Liu from HIT, Mr. Gil De Sousa from Irstea, Madam Susan from ISIMA,
UBP and Prof. Kun-Mean Hou from ISIMA, UBP. They helped me a lot in my
project and in this paper. They gave me a lot of advices in my report, requirement
analysis, system design and development. Thanks to their patience and enthusiasm,
I can finish this project and the paper in time.
Also I want to thank my colleges in Irstea, they are helpful and hospitable.
Since I worked at Irstea, they helped me a lot in my daily life, gave me suggestions
on my paper and talked with me about the new technology. Besides, I want to offer
my regards to my classmates, they supported me in all aspects of the project.
88