Get started with Mbed on Arduino (Part 1)

Arduino has recently been releasing a large number of boards geared towards IOT applications such as the MKR family, the new Nano family, the Portenta H7 etc. Out of these, the Nano family has a very special feature, that is the integration of ARM’s Mbed OS, a powerful but lightweight, open-source Real Time Operating system built for 32-bit ARM Cortex microcontrollers.

In this article, I will be demonstrating how to start writing programs using the Mbed library on supported Arduino boards with the Arduino IDE. Let’s get started!

Bootloader vs RTOS

Before we begin, it is important to understand some of the key differences between a bootloader (used by 8-bit Arduinos such as the UNO, Mega, Micro etc.) and a Real Time Operating Systems.

A bootloader is a simple program which serves one singular purpose, that is to allow your program to be uploaded to and run on the target device. A diagram can be used to better understand this-

When your Arduino is powered on, the bootloader, if present, is the first program to start running. The program you would have previously uploaded to the Arduino is stored beyond the bootloader in the ROM and can not start running immediately. The bootloader then relinquishes all control to your program. It is then the program’s responsibility to manage system resources. This approach implies that multiple programs cannot run simultaneously.

All the Arduino boards such as the UNO, MEGA, Micro, Pro etc. use bootloaders as they use the smaller 8-Bit AVR chips running at lower frequencies.

An Operating System, on the other hand is a more sophisticated program which is responsible for allowing other programs to run in a systematic way.

Unlike the bootloader, an OS continues running in the background and provides a layer of abstraction over the core hardware resources for your program/programs by acting as a middleman. It can also time-slice, allowing multiple programs to run at the same time, giving the illusion of multi-tasking.

Operating systems often require slightly more powerful and complicated microcontrollers for any meaningful advantages to show up and as a result are not used in the previously mentioned Arduinos. They are, however, used in the newer ARM Cortex based Arduinos, which is what we will be using today.

Boards supporting Mbed core

As of now, the only boards which support Mbed OS integration are the Arduino Nano 33 BLE and Arduino Nano 33 BLE Sense. However, in the future, there are more boards to come and this list will be updated as they do.

Getting the Mbed library

Now that the you know about the supported Arduinos, it is finally time to gets started with the Mbed Library using the Arduino IDE. For these examples, I will be using the Arduino Nano 33 BLE.

To start, you will first have to make sure that all the necessary header files and dependencies are in their appropriate locations, without which the Arduino IDE will not be able to make any sense of the Mbed language. Start by making sure you have the latest version of the Arduino IDE installed (which is 1.8.12 as of writing this article). The latest version of the Arduino IDE can be found here.

Arduino IDE 1.8.12 with highlight

Then, make sure you have the latest version of the nrf528x boards from the boards manager. Even if you have previously installed and configured the Nano 33 BLE, it is important to update to the latest version as this is the easiest way to get the Mbed API working with your IDE. If you have not already configured the Nano 33 BLE or BLE sense, then click here.

Board manager under tools
Mbed Core

You should now be able to include the Mbed header file in your sketch and be able to compile it without any issues, as shown below.

And that’s it! You have set up everything required to use an RTOS with your Arduino. In the next blog, I will be going over writing your first sketch and using a few basic Mbed functions along with a simple multithreaded program. Click here to go right to it.



    1. Can you describe the exact error you are getting? If you only include the header but don’t use any functions, do you still get the error? What version of the IDE are you using? Did you include it using double quotes (#include “mbed.h”) or angle brackets (#include )?


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 )

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