Tag Archives: WSN

Setting up Cooja: A simulator for TinyOS

It might not be possible to test out all the work you do in TinyOS on a physical test bench at all times. Or maybe sometimes you want to save yourself the trouble of flashing a large number of motes only to realize that you’d made trivial errors in your code. Enter: Cooja.

Contiki is another widely used platform in the field of Wireless Sensor Networks. We’ll now be describing how to setup Cooja: the simulator tool offered by Contiki.

The normal installation is by following the instructions on this site:
http://www.contiki-os.org/start.html

However, for somebody who just wants to use Cooja as a simulation platform in conjunction with TinyOS, the normal setup is bulky at a little over 2 GB to download and the instructions are something that even we struggled with.

In order to save you the trouble of this procedure, we’ve uploaded the relevant part of Contiki to make Cooja.

Steps:

1. Download the .zip file from https://docs.google.com/file/d/0Byj9l1T-DECtRGd2a1Vka1RUakk/edit
2. Extract the files to any convenient location.
3. Make sure you have java development kit (7 or greater) and ant installed on your system. If not, then :

                    sudo apt-get install ant (on Linux)  or https://ant.apache.org/manual/install.html (for Windows)

http://www.oracle.com/technetwork/java/javase/downloads/index.html (for Windows)
or sudo apt-get install openjdk-7-jdk (for Linux)

4.Set the path variables for java and ant (only required if not automatically set or in windows)
5.Go to the location where you’ve extracted the folder.
6.Navigate to contiki/tools/cooja
7.Write ant run (in terminal or cmd)

This should launch the simulator and you can now explore Cooja.

The example we’re going to show here is simple radio communication between two motes and from our basic Send Receive code hosted at:

https://github.com/shady33/tinyos-bits/tree/master/basic_send_receive

General Steps for simulating code based on TelosB motes:
1. File->New Simulation. Create.

2.Motes->Add Motes->Create a new mote type->Sky Mote

3.In the Contiki Process/Firmware field browse to the location on disk where you’ve compiled your code using make telosb

4.Go to build/telosb/ and choose main.exe

5.Add motes

6.Press Start in the simulation control panel

That’s about it. Some of the other common features we use are:

1. The on board LEDs which you can add from View->LEDs in the Network Window.
2. Radio Messages from Tools->Radio Messages
3.Speed Limit control in the Simulation Control window
4.The output of Printf statements that show up in the Mote Output Window
(Something to watch out for while using Printf statements, its better to use the SerialPrintfC component in the configuration file XYZAppC.nc file while simulating in Cooja. On the other hand, PrintfC works better in real-world simulations using the java.net.tinyos.tools.listen tool for tinyos or something else like Cutecom.)

Cheers,
Mayank Joneja, Laksh Bhatia, Sachin