The Arduino ecosystem includes open-source hardware and software developed and sold by Italian company Arduino. The overall platform contains an integrated development environment (IDE) called Arduino IDE, which users can use to write, compile, and upload code to a development board (usually equipped with an Atmel AVR microcontroller).
A term that comes up often when discussing operating systems (OS) for Arduinos is “real time”. Essentially, a real-time operating system (RTOS) has been designed with time guarantees in mind.
To meet these time guarantees, there are two types of scheduling used by an OS to switch between tasks: cooperative and preemptive. A cooperative OS requires special function calls to allow context switching, usually in specially-implemented sleep functions, while a preemptive OS usually has timer-based interrupts that can context switch a running task at any time.
In this article, we’ve compiled the best Arduino OS options out there to help you determine which one fits your needs. But first, let’s review what you may need to consider while browsing the choices.
One of the first things to consider is whether you’re better off with a preemptive or cooperative OS. As with everything in life, there are always trade-offs with design decisions.
Preemptive OSs are great because they will always be fair with time scheduling. This means that if you want a thread to run every 10 ms, in normal circumstances, the OS should be able to guarantee that that happens. However, running a preemptive OS also means more code complexity, as locks need to be used for sharing resources.
Cooperative OSs are simpler in nature because they only context switch when prompted by certain calls, such as delay or sleep methods. However, this makes them inherently unfair in prioritizing tasks, as if you have a while loop in a task that never yields, then other tasks will never run.
Aside from preemptive or cooperative, there are a few other few basic factors we considered when curating this list:
FreeRTOS is a very popular and open-source RTOS that supports either preemptive or cooperative scheduling, depending on how it’s configured. It supports a wide range of microcontrollers in the Arduino family such as the ATmega328, ATmega32u4, ATmega1284p, and ATmega2560.
The popularity of FreeRTOS means getting support and finding examples will be very easy and the level of documentation available is excellent. FreeRTOS also offers many additional features such as dynamic memory management, task communication (queues), and other useful primitives.
Zephyr is an open-source project developed by the Linux Foundation. It offers a scalable, modular RTOS with a small footprint and low power consumption that can use either cooperative or preemptive scheduling. The range of tools offered is impeccable, and the active developments as well as contributions promise improvements to come.
Being one of the popular operating systems for microcontrollers, there’s an active community and technical support is easily available. The site itself also offers in-depth documentation and samples to help you along the way. The list of supported boards boasts more than 450 members including popular architectures such as ARM, ARM64, SAMD, and Esp32.
Similar in principle to Simba, Apache NuttX is an embedded RTOS that fulfills the POSIX and ANSI standards. The developers put emphasis on standards compliance and a small footprint, particularly suitable for deeply embedded environments. The OS is scalable from 8-bit to 64-bit architecture microcontrollers.
A key feature to mention is the wide-reaching support that includes USB, Ethernet, Wi-Fi, 6LoWPAN, graphic LCD, SD Card, FAT (File Allocation Table) file systems, CAN bus, RS485, and more, all built-in with the OS. With detailed documentation and an active support community, getting used to the OS may be an easier task than most.
Designed specifically for IoT (Internet of Things) devices but having gained a lot of development and support over time, Riot is a free and open-source priority-based scheduler with multithreading enabled. With this purpose in mind, an emphasis was placed on user-friendliness, security, connectivity, and code quality.
Riot supports most low-power IoT devices, microcontroller architectures (32-bit, 16-bit, 8-bit), and external devices. It’s a popular tool so you can easily find tutorials on Hackster and YouTube, as well as participate in the active community forum.
HeliOS is a cooperative scheduled OS that’s been designed around ease of use. By opting for cooperative scheduling, HeliOS should be easier than some other OSs to write safe code for.
HeliOS supports AVR-, ARM-, and SAMD-based microcontrollers. It’s still in active development but boasts some of the extra features seen in FreeRTOS such as memory management, task messaging (queues), and timers.
Simba is an embedded programming platform, which sets it apart from the other choices in this piece because it supports more than just task management. The level of documentation is excellent, as is the number of platforms it supports.
Simba also boasts support for device drivers for common peripherals such as SPI and I2C, plus file systems, networking, and logging. It also supports either cooperative or preemptive threads, depending on how it’s configured. The GitHub for Simba indicates it’s very popular, meaning getting support will be easier.
Finally, TaskManagerIO is a cooperative scheduler that supports a wide range of development boards, including Arduinos. It’s not a full RTOS, but a scheduler that can run on top of the other options on this list for simply defined multitasking. Its compatibility across a range of boards and operating systems makes it a versatile choice for anyone needing a cooperative scheduler.
The documentation is comprehensive, and the fact that it is a cooperative scheduler instead of preemptive means that it’s going to be easier for most beginners to write safe code without the usage of locks. The library seems somewhat popular on Github with issues being responded to reasonably quickly.
CoopThreads is a cooperative scheduler that was designed to be lightweight so that it’ll run on 8-bit microcontrollers (unlike a fully-fledged RTOS). It supports a wide range of Arduinos, including AVR-, Esp32-, and Esp8266-based microcontrollers.
While the library is light on documentation compared to some of the following OSs, it does have several examples that should help users get familiar with CoopThreads.
License: The text of "Arduino OS: The Best Operating Systems" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.