Ever thought of controlling more than a single things together or ever tried to build something which can automate 2 or more sensors or any sort of devices simultaneously.

Now it’s possible with ARDUINO.

A free RTOS is  Real Time Operating System which enables us  creating more than one task and run the created tasks simultaneously without interfering with the interrupts. It matches the time and delay rate of both the devices which executes on different  frequencies.

Most operating systems appear to allow multiple programs or threads to execute at the same time. This is called multi-tasking. In reality, each processor core can only be running a single program at any given point in time. A part of the operating system called the scheduler is responsible for deciding which program to run when, and provides the illusion of simultaneous execution by rapidly switching between each program.

The scheduler in a Real Time Operating System (RTOS) is designed to provide a predictable (normally described as deterministic) execution pattern. This is particularly interesting for embedded systems, like the Arduino devices, as embedded systems often have real time requirements.

Traditional real time schedulers, such as the scheduler used in FreeRTOS, achieve determinism by allowing the user to assign a priority to each thread of execution. The scheduler then uses the priority to know which thread of execution to run next. In FreeRTOS, a thread of execution is called a Task.

So let’s start exploring more about RTOS.



  1. Arduino UNO
  2. Jumper wires
  3. LED’s
  4. Sensors(Any)


  1. Arduino IDE


The Arduino IDE and environment has many drivers and libraries available within an arms reach, but the Arduino environment is limited to just setup() and loop() and doesn’t support multi-tasking effectively.

This is a simple, easy to use and robust FreeRTOS implementation that can just shim into the Arduino IDE as a Library and allow the use of the best parts of both environments, seamlessly.

Let’s Start Building

Firstly in the Arduino IDE Library manager, from Version 1.6.8, look for theFreeRTOS Library under the Type: “Contributed” and the Topic: “Timing”.

Ensure that the most recent FreeRTOS Library Release is installed. As of writing that is v8.2.3-14.

Then under the Sketch->Include Library menu, ensure that the FreeRTOS library is included in your sketch. A new empty sketch will look like this.


Compile and upload this empty sketch to your Arduino Uno/Yun/Leonardo/Mega or Goldilocks 1284p device. This will show you how much of your flash is consumed by the FreeRTOS scheduler. As a guide the following information was compiled using Arduino v1.6.7+ on Windows 10.

// Device:   loop() -> FreeRTOS | Additional Program Storage

// Uno:         450 ->   7328   |     21%

// Goldilocks:  504 ->   7386   |      6%

// Leonardo:   4002 ->  10766   |     24%

// Yun:        3910 ->  10760   |     24%

// Mega:        642 ->   9466   |      3%

At this stage FreeRTOS is already running on your device.

Next steps

Now upload and test the Blink sketch, with an underlying Real-Time Operating System simply by inserting #include <Arduino_FreeRTOS.h> at the start of the sketch. That’s all there is to having FreeRTOS running in your sketches.

The next step is to explore the features provided by a full RTOS within the Arduino IDE.

Blink_AnalogRead.ino is a good way to start off as it combines two basic Arduino examples, Blink and AnalogRead into one sketch with two separate Tasks. Both Tasks perform their duties, managed by the FreeRTOS scheduler. This sketch can be found in the Examples Folder of the Arduino IDE.

If you’re interested in low power or battery applications, it is easy to use FreeRTOS to support the AVR ATmega power reduction modes.




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s