You are here

Getting Started


This guide provides instructions and resources to help developers set up the development environment, build the IoTivity stack and build sample applications on Ubuntu for an Arduino target.


Needed for Arduino only:

Tools and libraries

The following tools and libraries are necessary to build IoTivity code for Arduino. The commands and instructions provided in this section are specifically for Ubuntu LTS 12.04.

Open the terminal window and use the following instructions to install all the necessary tools and libraries to build an IoTivity project.

Ubuntu LTS 12.04

Ubuntu LTS version 12.04 is the supported OS for building the IoTivity stack. Instructions may be different for other versions of Ubuntu and Linux.


Git is a source code management software, and is necessary to gain access to the IoTivity source code.

Use the following command to download and install git:

$ sudo apt-get install git-core 


Secure Shell is required to connect to the git repository to check out the IoTivity source code. Secure Shell is typically part of the base operating system and should be included. If for any reason it is not available, it can be installed by running the following command in your terminal window:

$ sudo apt-get install ssh 


Doxygen is a documentation generation tool used to generate API documentation for the IoTivity project. Download and install Doxygen by running the following command in your terminal window:

$ sudo apt-get install doxygen 

Arduino Framework and AVR-GCC compiler

For Arduino ATMega 2560, Arduino version 1.0.5 and AVR-GCC version 4.5.3 is needed.

For Arduino Due: Arduino Version 1.5.7 and AVR-GCC version 4.8.3 is needed

Note: Arduino framework obtained using $ apt-get will come with different AVR-GCC compiler version. Please use the link provided above

The installation directory for the Arduino framework is referred to as <ARDUINO_DIR> in this document. This is typically located in /usr/share/arduino/. Arduino tools directory is referred to as <ARDUINO_TOOLS_DIR> in this document. This is typically located in <ARDUINO_DIR>/hardware/tools/avr/bin


Arduino Time Library

Download the Arduino Time Library and unzip it in the Arduino directory at <ARDUINO_DIR>/libraries/TIME. 

For Arduino ATMega 2560, download the Time library from here.

For Arduino Due, download the Time library from here.


Cutecom is a graphical serial terminal used in this project for debugging purpose. Cutecom is only used for viewing logs from the Arduino platform. Use the following command in the terminal window to download and install cutecom:

$ sudo apt-get install cutecom 

Source code

There are 2 methods to get the source code.

  1. Downloading most stable source from here.
  2. Getting source directly from gerrit.

Gerrit is a web-based code review tool built on top of the git version control system. Gerrit's main features are side-by-side difference viewing and inline commenting, which streamline code review. Gerrit allows authorized contributors to submit changes to the git repository after reviews are done. Contributors can have code reviewed with little effort, and get their changes quickly through the system.

The following five steps describe how to check out the source code on the development machine.

Note: skip Step 1 to use existing ssh keys.

Step 1:

Create ssh keys.

  1. On the terminal, type the following (replace "your name <your_email_address>" with your name and email address):
    $ ssh-keygen -t rsa -C "your name" 
    For example John Doe with an email address would type:
    $ ssh-keygen -t rsa -C "John Doe" 
  2. After pressing the Enter key at several [LS6] prompts, an ssh key-pair will be created at ~/.ssh/

Step 2:

Upload and register an ssh public key.

  1. Log in to IoTivity Gerrit.
  2. Click on Settings on the top right side as shown here:
    IoTivity Gerrit Settings
  3. Click on SSH Public Keys and add key.
  4. Open ~/.ssh/, copy the content, and paste the content in the "Add SSH Public Key" window.
  5. Click Add.

Step 3:

Setting up ssh.

  1. Open ~/.ssh/config in a text editor.
  2. Add the following line:
    Host iotivity
      IdentityFile ~/.ssh/id_rsa 
      User [username] 
      Port 29418 
  3. To connect behind the proxy, add the following line after IdentityFile ~/.ssh/id_rsa with the appropriate proxy address and port:
    ProxyCommand nc -X5 -x <proxy-address>:<port> %h %p 

Step 4:

Verify your ssh connection.

  1. Execute the following command in the terminal window:
    $ ssh 
  2. Upon successful connection, the following message should appear indicating proper ssh and configuration connection.
     **** Welcome to Gerrit Code Review **** 
  3. If the connection is not established, check for the proxy and use the proxy settings described in Step 3.

Step 5:

Cloning the project source.

To build the IoTivity resource stack:

  1. Using your terminal window, browse to the directory where code will be checked out.
  2. Execute the following command in the terminal window to clone the iotivity repository:
    $ git clone iotivity:iotivity 
    git clone ssh://

This command clones the repository in your current working directory.

Build the IoTivity project for Arduino

Step 1: Apply arduino patch

Using the terminal window, navigate to <ARDUINO_DIR>, and run the following command.

For Arduino ATMega 2560:

$ patch -p5 < <iotivity>/tools/arduino/patches/arduino-1.0.5_linux.patch

For Arduino Due:

$ patch -p5 < <iotivity>/tools/arduino/patches/arduino-1.5.7_linux.patch

Step 2: Setup

Create a file named "" under <iotivity>/resource/csdk/ and paste the following in the file.

ifeq ($(PLATFORM), arduinomega)
    #Location of arduino sdk for Arduino Mega
    ARDUINO_DIR := <arduino-1.0.5>
    ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/avr/bin
    #Location of arduino sdk for Arduino Due
    ARDUINO_DIR := <arduino-1.5.7>
    ARDUINO_TOOLS_DIR := $(ARDUINO_DIR)/hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/bin

Note: make sure to update <arduino-1.0.5> and <arduino-1.5.7> with appropriate arduino installation directory location.

Step 3: Build

Using the terminal window, navigate to <iotivity> directory and execute following command

For Arduino ATMega 2560:

$ make arduinomega 

For Arduino Due:

$ make arduinodue 

This command builds the core and the C SDK for the IoTivity project with Arduino target along with the sample apps. 

Build the Arduino Sample

The output of the compiled samples will be located at <iotivity>/resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/

When an Arduino SimpleClientServer application is running, it outputs logs to serial port. This requires the current user to be a part of the "dialout" user group permissions on Ubuntu. If your Arduino device is NOT installed at location "/dev/ttyACM0", you must define ARDUINO_PORT to the location it is installed at. This location will be referred to as <DEV_PORT>.

navigate to <iotivity>/resource/csdk/stack/samples/arduino/SimpleClientServer/ocserver/ and run the following command, where <DEV_APP> is "occlient" or "ocserver"


Use cutecom to connect to the dev_port for the Arduino with following settings:

Baud Rate : 115200 Data bigs: 8 Stop bits: 1 Open for: Reading 

Apply settings and select open device.