Final Year Report Template

2 downloads 0 Views 2MB Size Report
Aug 2, 2017 - localisation algorithms, is by measuring the received signal strength (RSS) value of a ..... o Irrigation management ... o Automated meter reading ... position fix of an object is by using a global positioning system (GPS) receiver, .... perform the data logging of RSSI values, two Arduino Uno platforms combined ...
Localization of a Mobile Node in a Wireless

Sensor

Network:

an

Evaluation of RSSI as a Distance Metric Chris Gkiokas Student ID: 10059631

A thesis submitted in part fulfilment of the degree of BSc. (Hons.) in Computer Science with the supervision of Prof. Apostolos Lazaris.

BCA Computer Science Department – LMU Faculty of Computing Business College of Athens – London Metropolitan University

26 April 2015 Athens, Greece

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Abstract Wireless sensor networks are becoming more and more omnipresent and are applied to new found areas with great rate. For many of those application it is critical that the location of sensor node is known and reported back as information, so localisation algorithms are of great significance in improving the data that such applications will deliver. One of the most wide-spread methods of range-finding technique, for use in localisation algorithms, is by measuring the received signal strength (RSS) value of a node and translating it into a distance. In most of the research work done using this metric RSS is considered de facto a correct metric to use as a parameter in localisation algorithms. The purpose of this research is to investigate whether the RSS can indeed be used as a key parameter in a localisation algorithm without assuming that it is by definition. In the experiments made throughout the project the measurements it was clear that RSS values are not as well suited to act as sole or basic parameter in a localisation algorithm mainly due to the reason that RSS can be very easily affected by the external environment due to effects like multipath and electronics interference.

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Acknowledgment

The completion of this thesis was made possible with the help of some people that I would like to offer my deepest thanks. First of all I would like to thank my supervising professor and head of computer science department Prof. Apostolos Lazaris for his guidance, aid and inspiration not only in this project but throughout these four years of my studies. I would also like to thank my family for supporting me emotionally and financially through this time enabling me to fulfil my dreams and life aspirations, boosting me to achieve my greatest goals. Chris Gkiokas April 2015

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Table of Contents Introduction ........................................................................................................... 7

2

1.1

Problem Statement ...................................................................................................... 8

1.2

Objectives .................................................................................................................... 9

Background and Literature Review .............................................................. 10 2.1

Wireless Sensor Networks ......................................................................................... 10 2.1.1

2.2

Localization in WSN ................................................................................................... 12 2.2.1

3

4

Uses of Sensor Networks .............................................................................. 10

Range-finding techniques .............................................................................. 13

Investigating methods, tools and techniques ................................................ 17 3.1

Wireless Sensor Network ........................................................................................... 18

3.2

XBee networking ........................................................................................................ 18

3.3

Arduino ....................................................................................................................... 19

3.4

MATLAB ..................................................................................................................... 21

Development & Findings .............................................................................. 22 4.1

Experiment Setup....................................................................................................... 22 4.1.1

Electronics Setup ........................................................................................... 23

4.1.2

Network Setup ............................................................................................... 25

4.1.3

Arduino Setup ................................................................................................ 31

4.1.4

Data Gathering .............................................................................................. 35

4.2

Measurements ........................................................................................................... 36

4.3

Evaluation .................................................................................................................. 47

4.4

Further Development ................................................................................................. 48

5

Conclusion ................................................................................................... 49

6

Personal Reflection ...................................................................................... 50

Bibliography ........................................................................................................ 52 5

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

7

Chris Gkiokas

Appendix ...................................................................................................... 55 7.1

Table of Figures ......................................................................................................... 55

7.2

Table of Tables .......................................................................................................... 56

7.3

Code Listings ............................................................................................................. 57 7.3.1

RouterNodeScript sketch ............................................................................... 57

7.3.2

ReadRssi sketch ............................................................................................ 59

7.3.3

arduinoread MATLAB script........................................................................... 62

6

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Introduction While Wireless sensor networks (WSN) have been developed from the late 1970’s when Defence Advanced Research Projects Agency’s (DARPA) organized the Distributed Sensor Nets Workshop (DAR 1978) [6], it is during the last twenty years where consumer electronics and Very-large-scale integration (VLSI) took off and became more powerful and more available than ever before, that WSN’s are coming closer and closer to be reliably applied to commercial real world applications. In addition given the recent rise and expected industry high of the internet of things (IoT), WSN’s are in the spotlight of the engineering community. 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.[17] They possess restricted sensing, computing, communication and storage capabilities and while connected in a network they are acting to provide data about the physical world to a data processing service and provide information, event monitoring and forecasting [Anchor Node Localization for Wireless Sensor Networks Using Video and Compass Information Fusion]. Thus they are essentially connecting the physical world with the digital world in a unique unprecedented way that will enable us to gather data preventing catastrophic infrastructure failures, conserving natural resources, increasing productivity, enhancing security and enable many new and novel applications [6].

7

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

1.1 Problem Statement These sensor network can find use in a multitude of applications that require data monitoring and gathering ranging from scientific, social care and agriculture to military and security. In many cases the location of a sensor device is fixed, for example a weather station or a forest fire detection system, therefore the topology is known and linked to each node. However in situations where the location of a node is not known and/or moving, typically in personnel tracking systems, like security forces deployment, workspace monitoring and healthcare monitoring, the method most commonly used is by equipping the sensor nodes with their own Global Positioning System (GPS) receiver unit, in order to track their location. The issues with this technique are that the GPS receivers are inherently more costly to obtain, they can be problematic when the connection to the satellite is obscured by natural obstacles and is practically useless in indoor environments. The alternative localization methods are based on four range finding techniques using the signal that the sensor node communicate, one of these four techniques is using the Received Signal Strength (RSSI) indication, this study will focus on this technique evaluating its range finding performance. The concept of the RSSI method is that a signal decays with the distance travelled, in distance the RSSI degrades with the square of the distance from the sender and is measured in dBm. [6] Therefore RSSI can be potentially utilized as a range finding indicator. However in the relevant literature review it is evident that the RSSI is prone to error due to interference from the environment [15] and that it cannot be used to produce reliable distance measurement metrics. This project will aim to examine the matter of whether the RSSI can or cannot be used as a range finding metric in a realistic indoor WSN localization scenario.

8

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

1.2 Objectives The main objective of this study is to take measurements and evaluate the Received Signal Strength Indicator as a range finding method using an experimental prototype, low cost and open source WSN setup: 1. A prototype wireless sensor network using low cost open source equipment consisting of the minimum two nodes 2. A prototype control program that will send testing packets 3. A prototype control program that will receive the test packets, finds the RSSI and convert it to distance then feed it to the data gathering program 4. A prototype data gathering program that will get the data from the WSN and produce graphs. 5. Evaluation of the produced data as to whether RSSI can be a reliable range finding method.

9

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

2 Background and Literature Review 2.1 Wireless Sensor Networks A wireless sensor network (WSN) is a collection of spread out distributed autonomous sensors (often referred as “nodes” or “motes”) that monitor bodily or environmental conditions like temperature, pressure, sound, movement and many more. Working in unison, they transfer data to a centralised location where the data are collected and processed by a central system (usually a computer system or a microcontroller). Most modern sensor networks are bidirectional, allowing remote control of the nodes by a central system. A sensor network can contain from only a few nodes to hundreds or thousands of nodes, each controlling one or more sensors, every node has some typical parts, a wireless transceiver with internal or external antenna, a microcontroller, an electrical circuit that acts as an interface between sensors and microcontroller and a power source, typically a battery or a solar panel. The topology of a WSN network varies from a simple peer-to-peer, to a star topology or more advanced mesh network topologies. The data distributing method can vary between static or dynamic routing and flooding. [6, 17] 2.1.1Uses of Sensor Networks WSNs because of their modular architecture and the ability to include a large number of sensors that can connect to them, are easily expandable and adaptable in various scenarios and can record a wide range of measurements. Wireless sensor network can find application in multiple scenarios, some of them but not all are listed below: [17] 

Area supervision



Environmental observations / earth observation o Air pollution monitoring o Forest fire detection o Landslide detection 10

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

o Water quality monitoring o Flood detection 

Commercial applications o Data logging o Production line monitoring o Workspace supervision o Inventory control o Vehicle tracking o Structural integrity monitoring o Traffic monitoring & management



Agriculture applications o Precision agriculture o Irrigation management o Greenhouse management



Home applications o Home automation o Instrumented environment o Automated meter reading



Health applications o Remote monitoring of physiological data o Tracking and monitoring doctors and patients in a hospital o Drug administration o Elderly or handicapped assistance



Military & security applications o Monitoring inimical forces o Monitor friendly forces or equipment o Military-theatre or battlefield surveillance o Targeting o Battle damage assessment o Nuclear, biological and chemical attack detection

11

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

2.2 Localization in WSN Sensor nodes in a WSN are distributed in a delocalised and spread out manner in order to collect data and perform their function so their physical position in space is often not known or easily tracked. Especially in applications where position tracking is a requirement for the WSN. Some of the advantages of knowing the locations of a node other than position tracking as a primary or secondary function are: [17] 

Location-based routing, may be used to conserve energy



Enhances security



Aid in sensor management and monitoring



Providing support for mobile nodes that are self-guiding through knowledge of their location

Even nowadays the most accurate and reliable means of obtaining a position fix of an object is by using a global positioning system (GPS) receiver, which can provide precise and consistent location information for a node. However it is prohibitively expensive and impractical for most of WSN applications to employ a GPS receiver for every node in the network and in addition GPS receivers fail to operate reliably in indoor environments or areas with obscured line of sight to the satellites. [17] As an alternative the research has focused in relative localisation techniques that are based on range measurements, estimating the distance between sensor nodes. These range based localisation techniques, are depending on the sensor nodes to provide measurable metrics such as received signal strength (RSSI), time difference of signal arrival and more novel methods like computer vision and Doppler shifts in the signal.[6,10].

12

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

2.2.1Range-finding techniques

2.2.1.1 Time of Arrival The main idea supporting time of arrival (ToA) method is that the distance between the sender and the receiver of a signal can be obtained by measuring the signal propagation time and the signal’s known velocity. Considering that a radio signal wave travel through the air with the speed of light (~300km/s), we can deduce that the signal will require about 30ns to travel 10m and in that manner have a distance estimation. The downside of this method is that the nodes require very sensitive high resolution precision clocks adding to the cost and complexity of a WSN. [6] There are two ways for the calculation of ToA: one-way and two-way propagation time. In one-way, the difference between the send and arrival of the signal is calculated using high precision synchronization of the clocks of the sender and receiver. For one-way (Figure 1(a)) measurements, the distance between two nodes i, j can be calculated as: (

)

(eq. 2.1)[6]

Where t1 and t2 are the send and receive time of arrival of the signal measured at the sender and receiver respectively. In two-way (Figure 1(b)) method the roundtrip of the signal is measured at the sender node and is calculates similarly as: (

)

(

)

(eq. 2.2)[6]

Where t3 and t4 are the send and receive times of the response signal. We can observe that with the one-way approach the receiver node calculates its position while in two-way method the sender calculates the distance to the receiver and must then report the location using an extra message.

13

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Figure 1 - (a) one-way ToA (b) two-way ToA (c) TDoA [6]

2.2.1.2 Time Difference of Arrival Time difference of arrival (TDoA)(Figure 1(c)) method uses two signals that travel two the receiver with different velocities, thus the receiver is able to obtain its location similar to ToA approach. This can be calculated as: [6] ( Where

)

(

) (eq. 2.3)[6]

= t3 – t1 which is a fixed time interval.

14

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

2.2.1.3 Angle of Arrival One more method of acquiring localization bearings is to pinpoint the direction of signal propagation, by using an array of antennas or microphones as shown by Peng and Sichitiu [22]. The angle of arrival (AoA) is defined as the angle between the propagation direction and some reference direction known as orientation

. Figure 2 - Triangulation in AoA localisation: (a) Localisation with orientation (b) Localisation without orientation [22]

2.2.1.4 Received Signal Strength The theory supporting the received signal strength (RSS) method is that the signal decays with the distance travelled. In many wireless devices it is common to find a received signal strength indicator (RSSI) feature, which can be incorporated to measure the amplitude of an incoming RF signal. Typically RSSI values are measured in –dBm and range from 0 to a max_RSSI value which differs from vendor to vendor. In free space, RSS decays with the square of the distance from the sender as it is expressed with the Friis transmission equation for received power

to the transmission power

(

Where

: [6] (eq. 2.4)[6]

)

is the antenna gain of the transmitting antenna,

antenna, λ is the wavelength of the signal, (

)

of the receiving

the separation distance where

15

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

n is the attenuation constant. Further on using the path-loss exponent equation we can relate RSSI value with a distance between two nodes as: ( )

(eq. 2.5)

Where n is the path loss exponent which is usually obtained from empirical measurements of propagation cases, d is the distance between the receiver and the sender in meters and C is a constant which calibrates for systems losses, typically the value in dBm of the RSSI at one meter distance between the nodes is used. Then we can transpose the above equation (eq. 2.5) to conclude that the distance d as a relation to RSSI can be calculated as: ( (

) )

(eq. 2.6)

16

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

3 Investigating methods, tools and techniques In order to examine the performance of RSSI a simple sensor network must be implemented, it will be comprised of the minimum of two nodes: one that will send a generic packet and one that will receive the said packet and report the RSSI of the transmission. The two nodes will require a means of RF communication and an embedded controller to execute the function that the experiment requires and communicate the measurements back to the data logging machine, which will be a Personal Computer in this case. The typical node configuration is either comprised of a microcontroller with sensors and a communication module attached, which is either engineered on a printed circuit board from individual components or sold as a complete product (microcontroller – communication module) that one can attached the desired sensors. For prototyping and experimentation as is the case in this study however proto-boards using embedded development platforms is acceptable. In this study in order to implement the minimal prototype sensor network and perform the data logging of RSSI values, two Arduino Uno platforms combined with two XBee series 2 Zigbee RF modules will be used. In addition to perform the evaluation of the range finding RSSI results, the well-known numerical computing software MATLAB will be used. All of the above choices are analysed in the following subchapters. The experiment will take place in a simulated controlled indoor office space, it will always have the two nodes in the same level plane to rule out the height difference from the measurements. It will provide measurements in different distances with the nodes in a static position, moving towards or away one another to a fixed distance on a natural walking pace rate. Additionally it will provide measurements from static distances with physical barriers static or moving between the nodes, to examine how much does physical objects would affect the RSSI distance values in a real-world scenario. The above measurements will be plotted and presented here in order to discuss the performance of the RSSI as a range finding metrics

17

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

3.1 Wireless Sensor Network The wireless sensor network in this project will be a bare minimum two node topology comprised by a coordinator node and a regular XBee router node. The router node will begin communication by sending a testing packet to the coordinator in constant time frames and will validate that the packet has been acknowledged by the coordinator node. The coordinator node will be constantly listening for the packets of the router node and when received it will query the RSSI value from the XBee, calculate the distance and feed it to the serial connection with the personal computer.

3.2 XBee networking As a communication module for this project the XBee radio modules are used for their ability to easily create networks and provide a framework for message passing and packet managment. The XBee modules implement the Zigbee specification which is a protocol used to create personal area networks (PAN’s) built on the IEEE 802.15.4 standard. XBee modules operates in 2.4 GHz with a fixed data rate of 250 Kbit/s, which is more than enough for the purpose of this experiment. It provides advanced networking functions like retries and acknowledgments, supports point-to-point, point-to-multipoint, and peer-to-peer topologies and has self-routing, self-healing and fraud tolerant mesh networking. In addition it provides an extensive command set, an out-of the box RF communication ability and a free configuration software called X-CTU. Moreover XBee modules give the ability to create instantly a mesh topology network and provide all the necessary infrastructure that support RF communications, in addition of some useful functions such as varying power level, sleep mode and an option for a 128 bit encryption, making extremely prevalent in the WSN community. Finally XBee provides an in built function that returns the RSSI value in dB for the last message received programmatically which significantly aids the aim of this project. In contrast using an out of the shelf RF antenna module would be lower the cost significantly compared to the XBee pricing, however it would require that the microcontroller should implement a basic message passing protocol as well as managing

18

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

the transmit/receive functions of the RF module, thus increasing the complexity and add to the overall program code overhead as the Arduino’s memory resources are limited. XBee-PRO Series 2 modules that were selected for this project specification: 

Transmission peak current: 205mA



Receive current: 47mA (@3.3V)



Power-down current: 3.5μA @ 25 degrees C



Indoor range: up to 90m



Outdoor line-of-sight: up to 3200m



Transmit power: 63mW (18dBm)



Receiver Sensitivity: -102dBm

In addition the version using an RP-SMA antenna was

Figure 3 - XBee-PRO Series 2 module with RP-SMA antenna

chosen because of the omnidirectional transmission capability of the RP-SMA antennas.

3.3 Arduino For the microcontroller it is obvious that the most suitable choice would be to use an Arduino platform as it covers all the requirements of the project and will enable the opportunity for rapid development and experimentation. In detail it will provide a complete microcontroller prototyping platform that cover covers with ease the problem of communicate via serial with the PC, input/output handling for the microcontroller – RF module communication and a power source as the platform does have on-board voltage regulators. In addition the Arduino project is completely open source, as the objectives require, providing a multitude of low-cost options as again the objectives require. Finally and most importantly the core concept behind Arduino is to provide a C language boot loader inside the microcontroller, thus eliminating the need for assembler programming, enabling truly ease of use and rapid development and experimentation. All those factors made the use of Arduino the only choice, as in contrast a standalone microcontroller would require a severe amount of programming in assembly 19

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

language for interfacing with I/O and serial communication alone. On the other hand commercial standalone motes while they are easier to use and have built-in basic functionality, they are severely more expensive that Arduino platforms and are proprietary devices that contradict one of the core objectives of this study.

Arduino is comprised of an Atmel 8-bit AVR microcontroller with all the complimentary parts required

to

enable

its

programming

and

its

Figure 4 - Sparkfun's Arduino Uno implementation

interconnectivity with external parts. An important attribute of Arduino is the ability to connect with a multitude of other platforms that provide specialised functions, known as: “shields”. Nowadays there are many versions of Arduino using a variety of microcontrollers, however most of them use a linear 5 Volt voltage regulator and a 16 MHz crystal oscillator. Its microcontroller is pre-programmed with a boot-loader that is simplifying the process of loading programs in flash memory in contrast with other devices that require an external programmer module. Arduino has most of the I/O pins of the microcontroller available for connection. In detail most Arduino versions have 14 digital I/O pins, 6 of which are capable of producing pulse width modulation and 6 can be used as analog inputs. Arduino Uno was chosen for this project: 

Microcontroller: ATmega328 @16MHz



Power supply: 5 Volt



Flash memory: 32KB



EEPROM memory: 1KB



SRAM memory: 2KB



Digital I/O: 14(PWM 6 and 6 analog)

Figure 5 - Original Arduino Uno board

20

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

The Arduino Integrated Development Environment (IDE) that is used in this project is an application written in Java programming language that is compatible with all Arduino platforms and is derived from Processing programing language and Wiring IDE. It is designed to be easy to use for beginners and has the capability of compiling and uploading a program to Arduino with one “click”. The programs are written in C or C++ although the IDE contains a lot of libraries that aid common I/O operations. A program or a code part written for Arduino is called a “sketch” and the user need to include only to functions on which the execution of an Arduino program is based on: 

setup (): a function that runs once at the beginning of a program and is used to initialise variables and configurations.



Figure 6 - Arduino IDE

loop (): a function that is called constantly until the deactivation of the Arduino device.

3.4 MATLAB For data logging and plotting this project uses Math Works MATLAB as it is a very widespread and respected tool for academic research and provides easy access to data manipulation tools such as plotting and filtering. Although open source or custom software could be used, MATLAB was chosen for this project mainly because of its universal acceptance and prestige in the scientific community as well as its ease of use in comparison from its competitors allowing rapid prototyping. MATLAB covers the serial communication with the Arduino the data logging in matrix form and the plots that are created for evaluating the performance of RSSI range finding in this study.

21

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

4 Development & Findings 4.1 Experiment Setup The experiment will be conducted in a controlled office space simulated environment with distances up to 4 meters and several measurements will be logged using MATLAB to compare and contrast. In detail the output data consist of a three digit floating point number that represents the distance in meters, this value is sent from the Arduino to MATLAB through serial connection where it is received and plotted. The distance value will be calculated in Arduino code by using the equation (eq. 2.6) and after passed through a size three median filter in order to eliminate extremely sudden spikes. The equation (eq. 2.6) requires two constant values, an attenuation constant value and the calibration RSSI at one meter value. The first one was obtained through a table with fixed coefficients linked to certain environments, while the second through sampling the RSSI at

fixed 1 meter and averaging the obtained values.

22

Figure 7- Path loss exponent values for common environments [8]

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

All in all the setup is a simplistic range finding WSN where it will enable to draw conclusion on whether the RSSI can be used for localisation purposes or not.

4.1.1Electronics Setup The electrical setup of the nodes is straightforward and requires minimal wiring, as both the Arduino and the XBee are prototyping platforms and have onboard the required components for interconnection and power. The Arduino operates on 5V charge that can be delivered via the usb connection with a personal computer, via battery or with the use of a consumer transformer through the mains. In contrast the XBee operates on 3.3V charge and normally requires a voltage regulator to convert input charges to 3.3V, however the Arduino Uno has already a 3.3V voltage regulator on-board and can be used to power up the XBee without issues. For the connection of the two modules only two wires are required that connect the transmit and receive pins of the XBee to select pins on the Arduino that are going to be programmed to handle the digital input as serial I/O. Finally the Arduino connects to the PC using the on-board FTDI FT232RL chip that converts TTL serial from the Atmel processor.

23

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Figure 8 - Wiring Diagram

Table 1 - Bill of Materials

Bill of Materials Arduino Uno

x2

XBee-PRO Series 2

x2

RP-SMA Duck Antenna

x2

Breadboard

x2

Connecting Wires

x8

24

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

Figure 9 - An assembled node

4.1.2Network Setup The XBee network is practically plug and play as it only requires that one node in the network is setup with a coordinator firmware, a common PAN ID across the nodes and pointing the nodes to the coordinator 64 bit hex address that every XBee module has assigned by the manufacturer. This is called the transparent mode (AT) and sets up a mesh network on the fly that listens to the serial of a node and simply passes it through the network to the targeted node exactly as it receives it. However this is not suitable for the purpose of this project as it is required to communicate with the XBee node itself rather than simply transmit through it, in order to query it for the RSSI reading. To achieve this

25

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

XBee provides a different firmware, the API (application programming interface) set of firmware that enables the programmer to directly talk to an XBee through a serial connection to a microcontroller, in this case the Arduino. To setup the network for this mode the coordinator and router API firmware must be installed to the corresponding nodes and the PAN IDs must be again configured to be the same across the network. After this setup everything can be programmatically be configured and operate as the communication now is conducted through protocol packets (or frames) of information that can be created by code and target the desired node directly. Example Zigbee Transmit and Received Packets: Table 2 - Zigbee Transmit Request

Frame fields

Offset

Values

Start

0

0x7E

MSB1

0x00

LSB2

0x16

3

0x10

4

0x01

Description

delimiter Length

Number of bytes between the length

Frame

Frame

specific data

type Frame ID

and the checksum Identifies the UART data frame for the host to correlate with a subsequent ACK (acknowledgement). If set to 0, no response is sent.

26

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

64-bit

MSB5

0x00

Destination

6

0x13

address

7

0xA2

8

0x00

9

0x40

10

0x0A

11

0x01

LSB12

0x27

MSB13

0xFF

LSB14

0xFE

Set to the 64-bit address of the

16-bit

destination device if known.

address Broadcast

Set to the 16-bit address of the

destination network

destination device.

15

0x00

Sets maximum number of hops a

radius

broadcast transmission can take. Options

16

0x00

Bit field of supported transmission options.

RF data

17

0x54

Data that is sent to the destination 27

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Checksum

Chris Gkiokas

18

0x78

19

0x44

20

0x61

21

0x74

22

0x61

23

0x30

24

0x41

25

0x13

device.

0xFF – the 8-bit sum of bytes from offset 3 to this byte.

Table 3 - Zigbee Receive Packet

Frame fields

Offset

Values

Start

0

0x7E

MSB1

0x00

LSB2

0x11

3

0x90

Description

delimiter Length

Number of bytes between the length

Frame

Frame

specific data

type

and the checksum 64

28

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

MSB4

0x00

5

0x13

6

0xA2

7

0x00

8

0x40

9

0x52

10

0x2B

LSB11

0xAA

MSB12

0x7D

LSB13

0x84

14

0x1

64-bit address of sender.

64-bit source address

16-bit source address

Receive options

16-bit address of sender.

0x01 – Packet acknowledged 0x02 – Packet was a broadcast packet 0x20 – Packet encrypted with APS encryption 0x40 – Packet was sent from an end device

29

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Received

Chris Gkiokas

15

0x00

16

0x00

17

0x54

18

0x78

19

0x44

20

0x61

21

0x13

data

Received RF data

Checksum

0xFF – the 8-bit sum of bytes from offset 3 to this byte.

The initial firmware install and network configuration of the nodes was made using Digi’s excellent X-CTU tool that can be downloaded for free and accompanies XBee products, that provides a very user friendly graphical user interface for setting up the nodes, giving a much easier alternative to the traditional serial terminal command configuration. The final topology of the network is depicted below:

Figure 10 - WSN topology graph

30

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

4.1.3Arduino Setup The Arduino microcontrollers are programed using standard C programming language and in this project the standalone Arduino IDE that comes with the platform was used. To aid the development four libraries were used including C’s stdlib and math. In addition two free and open source libraries were used: SoftwareSerial, a project that enables the implementation of a software serial interface that was used to make the connection between the Arduino and the XBee module and XBee which is a library that provides methods and data types that implement the Zigbee protocol packet functions significantly aiding in the implementation of the experiment’s software. For the experiment two C sketches were created one that controlled the coordinator node and one that was responsible for directing the router node. The first sketch named ReadRssi is uploaded into the Arduino that controls the coordinator XBee. It has five methods including the two default Arduino void setup and void loop methods: 

void setup is executed once from the Arduino boot loader and is used to setup the I/O pins and to initialize the serial communication instances. : pinMode(rxPin, INPUT); pinMode(txPin, OUTPUT); Serial.begin(9600); xbeeSerial.begin(9600); xbee.begin(xbeeSerial); Serial.println("Starting up!");



void loop is the main loop of the program and is constantly executed from the Arduino each processor clock tick, in this block the code calls getPacketData() each cycle to get the incoming packet from the router node, it fills a size 3 sample array that feeds the median filter in smooth() method, it calculates the distance

31

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

using the equation(), sends it over serial and delays for 1 second (1000milis) to synchronize with the router node: rssiReport = getPacketData(8); for (int i=0; i 0) { for (int i = 0; i < atResponse.getValueLength(); i++) { str += atResponse.getValue()[i]; } } } else { // Serial.print("Command return error code: "); //Serial.println(atResponse.getStatus(), HEX); } } else { //Serial.print("Expected AT response but got "); //Serial.print(xbee.getResponse().getApiId(), HEX); } } else { // at command failed if (xbee.getResponse().isError()) { //Serial.print("Error reading packet. Error code: "); //Serial.println(xbee.getResponse().getErrorCode() ); } else { //Serial.print("No response from radio"); } } return str;



unsigned long smooth is an implementation of a simple size three median filter and is used to refine the output RSSI values smoothing out any unexpectedly large spikes in the data: unsigned long middle;

33

Localization of a Mobile Node in a Wireless Sensor Network: an Evaluation of RSSI as a Distance Metric

Chris Gkiokas

if((valA