There are two ways to install TinyOS in Ubuntu 12.10 LTS
1. Manually download tinyos-2.1.2.tar.gz from below link
http://tinyos.stanford.edu/tinyos/dists/source/
OR
2. Add TinyOS repository address in the repository source file. (Which is shown detail below)
Note:- Before start installation move from user mode to root mode using below command then and then you can modify the system file
$ sudo su
Following steps are the installation of tinyOS Repository.
Step:-1
First of all, run following commands to open sources.list file
$ sudo gedit /etc/apt/sources.list
Add following lines at the end of sources.list
deb-src http://archive.ubuntu.com/ubuntu quantal universe
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu lucid main
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu maverick main
deb http://tinyos.stanford.edu/tinyos/dists/ubuntu natty main
You will get this dialog box
save it and Close.
Note:- Perform gedit command in root mode otherwise it will not modify.
Step:-2
Execute the following commands.
$ sudo apt-get update
To get the list of versions of tiny os type following command
$ sudo apt-get install tinyos
You will get available versions of TinyOS & you have to select which version you want to install
Here we are going to install TinyOS-2.1.2
$ sudo apt-get install tinyos-2.1.2
Step:-3
Run this command if you have not installed subversion of tinyos or jump to step-4
Note:- If you get package error then run following command
$ sudo rm -rf /var/lib/apt/lists/*
Again you have to execute step-2 command for update
Step:-4
After installation of TinyOS, go into the tinyos-2.1.2 directory
$ cd opt
$ cd tinyos-2.1.2
Step-5
Now you have to check tinyos.sh file exist or not. If not then using gedit command create tinyos.sh file and add below lines of code and save it.
#! /usr/bin/env bash
# Here we setup the environment
# variables needed by the tinyos
# make system
echo “Setting up for TinyOS 2.1.2 Repository Version”
export TOSROOT=
export TOSDIR=
export MAKERULES=
TOSROOT=”/opt/tinyos-2.1.2″
TOSDIR=”$TOSROOT/tos”
CLASSPATH=$CLASSPATH:$TOSROOT/support/sdk/java:.:$TOSROOT/support/sdk/java/tinyos.jar
MAKERULES=”$TOSROOT/support/make/Makerules”
export TOSROOT
export TOSDIR
export CLASSPATH
export MAKERULES
If tinyos.sh file exist then match this lines of code
Type following command to give permission to tinyos.sh file
$ sudo chmod 777 tinyos.sh
Step-6
To make that folder as your TOSROOT path, run below command to open /.bashrc file
$ sudo gedit ~/.bashrc
In /.bashrc file you have to add below one line of code at the end of the script
#Sourcing the tinyos environment variable setup script
source /opt/tinyos-2.1.2/tinyos.sh
Now save it and Close.
Note:- make sure you have to modify the bash file in root mode
Step-7
Close the terminal and restart PC.
Now you can check whether tinyos successfully installed or not. For that, after the reboot PC open console again and you will see the message on the console.
OR
To go in /opt/tinyos-2.1.2 /apps/ Execute following commands,
$cd opt
$cd tinyos-2.1.2
$cd apps
$cd Blink
Now you have to execute which kind of Mote you use whether it is IRIS or MICA2:-
If IRIS then execute
$make iris
You will get this dialog box
If MICA2 then execute this command
$make mica2
You will get this dialog box
If still, error occur then we have to change permission and for that, we have to go back in /opt/ directory and run this command
$ sudo chmod -R 777 tinyos-2.1.2
-: EXAMPLE:-
LED blinking Tutorial with IRIS Mote
After successfully installed tinyos, how we can use it for various application. Let’s see.
Here we are going to use two wireless hardware to demonstrate LED blinking on the predefined time interval.
1. IRIS Mote (51 Pin)
- 2.4 GHz IEEE802.15.4protocol
- More suitable for wireless sensor network with Embedded application
- Compatible with various IoT sensor
- Speed 250kbps data rate
2. Mote Interface Board
MIB520 interface board |
This interface board is use for to upload code in various mote or sensors.
Note:-Now we have to connect both device in such a way that antenna of IRIS mote and USB of interface board must be in same side.
Commands
$ cd opt
$ cd tinyos-2.1.2
$ cd apps
In this directory, you will see various projects file like
Now we have to go in Blink directory /opt/tinyos2.1.2/apss/Blink
$ cd Blink
In this directory, you will see various blink related file
If you want to modify the code of this project then you can open BlinkC.nc. Even if you can modify any project code with “.nc “extension file.BlinkAppC.nc file is for configuration and BlinkC.nc Module file.
Now upload the code in IRIS Mote then we have to execute below command in /opt/tinyos2.1.2/apps/Blink/ directory only (same for other projects)
$ make iris install.1 mib520,/dev/ttyUSB0
Note:-
1. In the above command “install.1″ So here “.1” is node id if you use another mote then we have to use the different number because when we receive the signal from specific mote to base station then the signal will only identify by their node number.
2. mib520 is programming board name
3. dev/tty is location of board
If you will get an error like permission denied then assign permission and again execute the above command to upload code.
$ sudo chmod 666 /dev/ttyUSB0
After successfully run above command you will get this kind of dialog box
Now you can see three LED which is located on the Mote board start blinking according to predefined time interval in BlinkC.nc file.
Once you upload the code on Mote detach it form Programming Interface Board and fit two battery cell on Mote now it start working.
Applications
Using the same process you can upload various code for different sensor and application like,
- Automation (office, home )
- Security system (Bank, ATM, Restricted areas)
- Weather forecasting system
- Disaster management system