TinysOsAccelerometer

This application is the result of a didactic project for the Pervasive Systems course of the Master of Science of Engineering in Computer Science at Sapienza University of Rome

Overview

The goal of the project is to create a wireless sensors network (WSN) for collecting data from an accelerometer and storing them to a server

The network is made of a number of motes, small electronic devices capable of doing some processing and communicating one another by mean of a radio transceiver. The solution adopted to reach the goal comprises two main parts:

  1. a TinyOS-based application, running on every single node of the network
  2. a Java GUI application in charge of uploading data to a server

Architecture

The network is based on the Collection Tree Protocol (CTP):nodes organize themselves to form a tree-shaped network, where packets are transmitted from the leaf node to the root node. In particular, every node maintains its own routing table with an estimation of the quality of the link to all its neighbors, so it's always capable of determining the path which involves less hops before a packet is delivered to the root; periodically every node sends broadcast packets (beacons), waiting for the other nodes to acknowledge them in order to discover the quality of the links. For this project the architecture of the network is as follows:

  • 1 leaf node: interacts with the accelerometer in order to sample data from it and then sends them towards the root of the network. Its mote-id has to be set to "1" in order to correctly update data on Parse(see later)
  • 1 root node : the recipient of the data sent by the leaf; it's connected to the serial port of a pc
  • n intermediate nodes: they are in charge of forwarding data received from one neighbor node to another neighbor node on the path to the root
The root node interacts with a pc which is connected to the Internet: the Java application running on it uploads data to a server as it receives them from the serial port.

Hardware implementation

The accelerometer used in this project is the ADXL-345 by AnalogDevices, a 3-axis accelerometer with 13-bit resolution, up to +/-16g peaks of acceleration. The leaf node to which it's connected is a MagoNode Platform, while the root node and the various messengers are represented by Crossbow TelosB

Software implementation

TinyOS-based application

Since the hardware platform of the leaf node is different from the one of the messenger nodes and of the root node, the TinyOs-based application comes in two distinct flavours:

  1. Accelerometer: it's the application installed on the Magonode platform (leaf node); it includes the driver to configure the accelerometer, with which it interacts
  2. Node: this is installed both in all the intermediate nodes and in the root node, meaning that they execute the same code, but actually their behaviour is not the same. In fact the root node is assigned a reserved mote id (50,arbitrarly chosen),so that it's possible to make it perform specific tasks by mean of the variable "TOS_NODE_ID"
Anyway, since they have to communicate one another, all the nodes in the network make use of the same implementation of the CTP provided with the distro of TinyOS.

Java GUI application

TinyOS comes with a Java application named "mviz" which provides a graphical tool to show the links in a network made of nodes running the Collection Tree Protocol: the application communicates with the root node through a serial port,so when messages are received the representation of the topology of the network gets updated. graph
Thus the Java application included in this project represents an extension of "mviz" which provides it with two additional features:

  1. Data upload on a database created at Parse.com Only data extracted from packets whose origin is set to "1" are uploaded (data from the accelerometer)


  2. parse upload

  3. Data download of the last three uploaded value, from the database


  4. parse download

Both these features are implemented using the REST API available at Parse.com. Since the request and the response of this API contain a JSONObject, in order to run the "extended Mviz" it's necessary to import either this JSON library and this HTTP Client.

Files Description

The most important files available from this project are:

  1. TinyOs applications for the motes, i.e. for the Magonode (Accelerometer) and for the TelosB (Node)
  2. Header file (Acceleration.h) including the fields of the packets to be visualized by the Java GUI application
  3. Extended version of Mviz
  4. Make files to compile to magonode (avr folder and magonode.target); to be put in the make directory of the TinyOS installation