+33 970 820 250 Mon–Sat, 9 am – 5 pm (CET) [email protected]
Development

Contiki OS: Powering IoT Development

Explore Contiki OS — the open-source RTOS designed for IoT. Learn about its architecture, protothreads, networking stack, and how it powers WiSMote sensor modules.

MSP430 experimenter boards used for embedded development
Photo: DSP-user, CC BY-SA 3.0, via Wikimedia Commons · Credits

Building software for IoT devices is fundamentally different from traditional application development. Sensor nodes have kilobytes — not gigabytes — of memory, run on batteries that must last years, and need to communicate reliably over lossy wireless links. These constraints demand a purpose-built operating system, and Contiki is one of the most widely used and well-regarded choices in the field.

What Is Contiki?

Contiki is an open-source, highly portable, multitasking operating system designed for networked embedded systems and the Internet of Things. Originally developed by Adam Dunkels at the Swedish Institute of Computer Science (SICS, now RISE), Contiki has been adopted by research institutions, companies, and open-source communities worldwide.

WiSMote modules run Contiki natively, and WiSMote is a platform referenced by the Contiki community, with its own target in the Contiki source tree.

Key Features

Small Footprint

A typical Contiki system image requires about 30 KB of ROM and 10 KB of RAM — well within the capabilities of micro-controllers like the MSP430 used in WiSMote. This efficiency is achieved through careful code design, compile-time configuration, and a modular architecture that includes only the components your application needs.

Protothreads

Contiki introduces protothreads — a programming abstraction that provides a sequential, thread-like coding style on top of an event-driven kernel, without the memory overhead of traditional threads. Each protothread requires only two bytes of state, making it practical to run many concurrent activities on a device with just 16 KB of SRAM.

Full IPv6 / 6LoWPAN / RPL Stack

Contiki includes a complete, standards-compliant networking stack: uIP for IPv6, the IPHC header compression specified in RFC 6282, the RPL routing protocol (RFC 6550), and the Erbium CoAP implementation. This stack enables WiSMote nodes to participate as first-class citizens on the IPv6 Internet.

ContikiMAC

ContikiMAC is a radio duty-cycling protocol that keeps the transceiver in sleep mode for most of the time, waking briefly at regular intervals to check for incoming transmissions. This achieves sub-1 % duty cycles while maintaining reliable communication — the key to multi-year battery life.

Cooja Simulator

The Cooja network simulator allows developers to test and debug Contiki firmware on a virtual network before deploying to real hardware. Nodes in Cooja run the same compiled firmware that will execute on the physical device, providing high-fidelity simulation with accurate timing, power modeling, and network behavior.

Contiki Architecture

Contiki follows a modular, event-driven architecture:

  • Kernel: A lightweight event scheduler that dispatches events to processes. No preemption — processes run to completion or yield explicitly.
  • Processes: Implemented as protothreads, each process registers to receive events and can post events to other processes or to itself (for delayed execution).
  • Timers: Contiki provides several timer types — etimer (event timer), ctimer (callback timer), rtimer (real-time timer for time-critical operations), and stimer (second-resolution timer).
  • Networking: The uIP stack handles IPv6, while RIME provides a layered set of communication primitives for simpler, non-IP-based networking.
  • Storage: The Coffee file system provides lightweight flash storage for data logging.
  • Shell: An optional interactive shell for debugging and configuration.

Development Workflow

Developing with Contiki on WiSMote typically follows this workflow:

  1. Write your application in C using Contiki’s process and protothread macros.
  2. Compile using the MSP430 GCC toolchain, specifying the WiSMote target platform.
  3. Simulate in Cooja to verify logic, network behavior, and power consumption estimates.
  4. Flash the compiled firmware to the WiSMote hardware via JTAG or USB bootloader.
  5. Debug using GDB over JTAG, serial console output, or Wireshark for over-the-air packet capture.

The WiSMote development environment includes the Eclipse IDE, architecture toolchains, debugging/programming/networking tools, drivers, software examples, schematics and application notes to accelerate this process; the Contiki source tree also contains generic examples such as a border router and a CoAP server.

Power Optimization in Contiki

Contiki provides several mechanisms for minimizing power consumption: ContikiMAC for radio duty cycling; the low-power module (LPM) that puts the MSP430 into deep-sleep modes when no processing is needed; software-configurable sensor sampling intervals; and compile-time options to exclude unused protocol layers and drivers. Combined with WiSMote’s low-power hardware, these features allow long battery-powered deployments; the actual lifetime depends on how often the node samples and transmits.

Community and Ecosystem

Contiki has a vibrant global community of developers, researchers, and companies. The source code is available on GitHub under a permissive BSD license. Extensive documentation, mailing lists, and academic publications provide resources for developers at all levels. Because the WiSMote platform lives in the Contiki source tree, its drivers and build files are available alongside the core OS.

Contiki-NG

Contiki-NG (Next Generation) is a community-driven fork that modernizes the codebase while maintaining backward compatibility with Contiki applications. It features improved IPv6 support, enhanced security (DTLS, link-layer encryption), better documentation, and a streamlined build system. WiSMote is a platform of the original Contiki tree; check the Contiki-NG platform list before planning a migration, as not every Contiki platform was carried over.

Getting Started

To start developing with Contiki on WiSMote, you need a WiSMote module (or the Network Starter Pack), a programmer/debugger, and a Linux or macOS workstation. Install the MSP430 GCC toolchain, clone the Contiki repository, and compile your first “Hello World” application. The WiSMote documentation at the WiSMote platform in the Contiki source tree provides detailed setup instructions.

Get WiSMote modules and start building your IoT application today.

WiSMote Engineering Team

Engineers at ARAGO SYSTEMS working on WiSMote, Contiki and wireless sensor networks.

Keep reading