TinyOS For Your Low-Power IoT Needs


The Internet of Things (IoT) phenomenon has truly caught the imagination of techies and developers worldwide. Companies, both non-profit and for-profit, are developing operating systems (OSes) for the same, promoting these as the best alternative to products already in the market.

In this article, we look at Tiny OS, which just happens to be one of the most popular and oldest OSes specifically for low-power applications. Tiny OS finds use in a multitude of applications, not restricted to wireless sensor networks, smart dust, personal area networks, automation in buildings, smart meters and smart – what ever’ s connected to a local area network.


What began as a collaboration between U C Berkeley, Intel and Crossbow technology, has now become one of the most trusted and used OSes in this field and has even spawned an international consortium, the Tiny OS Alliance. ESTCube-1, the world’s first satellite with an electric solar wind sail, has its communication module powered by Tiny OS. A humble beginning with a trip to space, what a story indeed!
In this month’s DVD, you will find a copy of this software so you too can let your low-powered applications roar with life, may be even outside this planet.

What more is Tiny OS

You may know that Tiny OS is an open source, BSD-licensed OS designed for low-power wireless devices, but what you may not know is that it provides software abstractions for underlying hardware. For example, when we might see a flash drive as a storage device, with certain read/write/erase properties, Tiny OS looks at it as just another example of a circular log.

This allows it to simplify the job of application and system developers as they can now use this sort of abstraction to reduce the time spent on one multi-step process by bringing it down to multiple single-step processes. We will discuss why this is critical in a bit.


Fig. 1: Structure of Tiny OS


Tiny OS flourishes on micro controllers (MCUs) with underlying sensors and/or network capabilities. It has been designed keeping in mind that most of the boards it will be loaded on will have resource constraints in the form of a few kB of RAM and/or memory, or the need to run on low power.

The Tiny OS- Arduino comparison

People sometimes wonder whether Tiny OS and Arduino address the same need and, if so, if Arduino can replace Tiny OS. The simple answer is ‘No,’ but let us not stop at giving simple responses.box-1
What Arduino does is provide C support for MCUs and sensors, whereas Tiny OS is more of a full-fledged OS with a host of developers constantly providing support and documentation. Ask any developer and they would swear that it is easier to get started from scratch in Arduino, and maybe build a simple application that runs on a sensor. But where Arduino scores on ease and simplicity, in the long run, and when dealing with applications that require more processing power, Tiny OS and its facilities in the area of networking, like multi-hop routing, reliable dissemination and time – synchronisation, do pay off huge.

There are also certain other factors to keep in mind, like the fact that while Tiny OS is optimised for low-power applications, Arduino is not. While Arduino focuses on sensing, digital I/O and computation, Tiny OS supports these while adding functionalities for wireless as well. Since all IoT applications need some sort of wireless function, Tiny OS fits in like a glove.

One crucial difference though is that, while Arduino is coded in C, Tiny OS is written in nesC, a dialect of C developed specifically for Tiny OS.All it does is add a few extra functionalities to aid programming.

Profile for Tiny OS: the good and the not-so-good

If you are a newbie in the field of developing for the IoT, then you can rest easy knowing that the Tiny OS environment not only supports multiple MCUs and radio chips, it is also extensively documented and checked. This has led to a robust and efficient code with very few bugs.box-2
Tiny OS’s speciality lies in its strong support for low-power operation, especially wireless networking. These are extremely important when the OS uses single-hop and multi-hop communication. There is also extensive documentation and support for CC2420, the leading 802.15.4/Zig Bee radio chip in use. Many of today’s IoT standards are based on Tiny OS designs and the countless hours put in by users worldwide.
Being low-power and low-resource-friendly does bring its share of issues too, though. Tiny OS has, for a long time, suffered from a steep learning curve for its programming model, along with having issues in implementing processes that are computationally intensive. The thing is though that these two are highly correlated.

box-3As Tiny OS is intended for devices with very little RAM, its APIs are all non-blocking or split-phase. To understand non-blocking, let us take the example of a sensor sending a message. Because of limited RAM space, when Tiny OS SEND()s a message, the send function is instructed to return immediately, even before the message is sent.

This might seem confusing but it is done to minimise the time taken by a single process. At a later stage, Tiny OS calls a callback, send Done(), to tell it that SEND() has been completed. The reason you cannot allow a process to run uninterruptedly is because then the OS cannot run other system processes and, in turn, might have to drop packets, timeouts and such.

A simple way around this is to break your multiple-step process into multiple single-step processes that run one after the other without interrupting each other. Granted, this may take some time to get used to, but the uptake is that there is enough and more documentation that will help you with the same.

Interestingly enough, the current version of Tiny OS includes a thread library to help with cases
of CPU-intensive applications by letting you add a threaded application on top of Tiny OS. This application allows you to do two things: add a blocking API to include long loops and write applications in C rather than nesC.

What are you waiting for

Fig. 2: IoT node types and data paths

With the IoT fever already at a high, this is the best time to equip yourself with knowledge of an OS that is a crowd favourite in this regard. Tiny OS can be installed on Linux, Mac OS X and Windows machines. Get started with our DVD today, and maybe the first inter-stellar, cross-planet, hunger games could be powered by something you build. Or, maybe, something a little more useful!
The author is a student at Great Lakes Institute of Management (GLIM), Chennai







Please enter your comment!
Please enter your name here