Need help with Arduino_FreeRTOS_Library?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

599 Stars 173 Forks MIT License 261 Commits 1 Opened issues


A FreeRTOS Library for all Arduino AVR Devices (Uno, Leonardo, Mega, etc)

Services available


Need anything else?

Contributors list

# 73,448
200 commits
# 173,392
13 commits
# 233,240
5 commits
# 221,828
1 commit

This is a fork of Richard Barry's freeRTOS, optimised for the Arduino AVR devices.

It has been created to provide access to FreeRTOS capabilities, with full compatibility to the Arduino environment. It does this by keeping hands off almost everything, and only touching the minimum of hardware to be successful.


Usage & Further Reading

Read the short blog post on Arduino FreeRTOS to get started. And there is another much older post on using FreeRTOS with AVR, which may be useful to read too. There are some further posts I've written on Hackster.IO, but they're essentially the same content.

The canonical source for information is the FreeRTOS Web Site. Within this site, the Getting Started page is very useful. This is the source for FreeRTOS usage (as distinct from installing and using this Arduino Library).

My other AVRfreeRTOS Sourceforge Repository or AVRfreeRTOS Github has plenty of examples, ranging from blink through to a synthesiser.

This library was the genesis of generalised support for the ATmega platform within FreeRTOS.

Over the past few years freeRTOS development has become increasingly 32-bit orientated, with little change or improvement for the 8-bit world. As such I'm treating this 1st January 2022 10.4.6 snapshot as my LTS release.


FreeRTOS has a multitude of configuration options, which can be specified from within the FreeRTOSConfig.h file. To keep commonality with all of the Arduino hardware options, some sensible defaults have been selected.

The AVR Watchdog Timer is used to generate 15ms time slices, but Tasks that finish before their allocated time will hand execution back to the Scheduler. This does not affect the use of any of the normal Timer functions in Arduino.

Time slices can be selected from 15ms up to 500ms. Slower time slicing can allow the Arduino MCU to sleep for longer, without the complexity of a Tickless idle.

Watchdog period options: *


Note that Timer resolution is affected by integer math division and the time slice selected. Trying to measure 50ms, using a 120ms time slice for example, won't work.

The 8-bit AVR Timer0 has been added as an option for the experienced user. Please examine the source code to figure out how to use it.

Stack for the

function has been set at 192 bytes. This can be configured by adjusting the
parameter. If you have stack overflow issues, just increase it. Users should prefer to allocate larger structures, arrays, or buffers using
, rather than defining them locally on the stack.

Memory for the heap is allocated by the normal

function, wrapped by
. This option has been selected because it is automatically adjusted to use the capabilities of each device. Other heap allocation schemes are supported by FreeRTOS, and they can used with additional configuration.



  • Stack Overflow: If any stack (for the
    or) for any Task overflows, there will be a slow LED blink, with 4 second cycle.
  • Heap Overflow: If any Task tries to allocate memory and that allocation fails, there will be a fast LED blink, with 100 millisecond cycle.


Testing with the Software Serial library shows some incompatibilities at low baud rates (9600), due to the extended time this library disables the global interrupt. Use the hardware USARTs.


  • ATmega328 @ 16MHz : Arduino UNO, Arduino Duemilanove, Arduino Diecimila, etc.
  • ATmega328 @ 16MHz : Adafruit Pro Trinket 5V, Adafruit Metro 328, Adafruit Metro Mini
  • ATmega328 @ 16MHz : Seeed Studio Stalker
  • ATmega328 @ 16MHz : Freetronics Eleven
  • ATmega328 @ 12MHz : Adafruit Pro Trinket 3V
  • ATmega32u4 @ 16MHz : Arduino Leonardo, Arduino Micro, Arduino Yun, Teensy 2.0
  • ATmega32u4 @ 8MHz : Adafruit Flora, Bluefruit Micro
  • ATmega1284p @ 16MHz: Sanguino, WickedDevice WildFire
  • ATmega1284p @ 24.576MHz : Seeed Studio Goldilocks, Seeed Studio Goldilocks Analogue
  • ATmega2560 @ 16MHz : Arduino Mega, Arduino ADK
  • ATmega2560 @ 16MHz : Seeed Studio ADK

The new megaAVR 0-Series devices (eg. ATmega4809) are not fully compatible with this library. Their Timer configuration is substantially different from previous devices, and forms part of a new avr8x architecture. It may be a while until avr-libc is updated to include support for megaAVR devices, but when that happens further work will be added here.

Files & Configuration

  • Arduino_FreeRTOS.h
    : Must always be
    first. It references other configuration files, and sets defaults where necessary.
  • FreeRTOSConfig.h
    : Contains a multitude of API and environment configurations.
  • FreeRTOSVariant.h
    : Contains the AVR specific configurations for this port of freeRTOS.
  • heap_3.c
    : Contains the heap allocation scheme based on
    . Other schemes are available, but depend on user configuration for specific MCU choice.


Arduino FreeRTOS is available in the PlatformIO library manager for use in a PlatformIO project.

Watchdog period is configurable using build-flags:

build_flags =

Code of conduct

See the Code of conduct.

Contributors ✨

All Contributors <!-- ALL-CONTRIBUTORS-BADGE:END -->

Thanks goes to these wonderful people (emoji key):

Phillip Stevens


Hector Espert










This project follows the all-contributors specification. Contributions of any kind welcome!

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.