Blog Home

Why we chose to build the Arduino Nano 33 BLE core on Mbed OS

Martino FacchinJuly 31st, 2019

This post is from Martino Facchin, who is in charge of the firmware development team at Arduino. Hopefully this is the first of a series of posts describing the inner workings of what we do.

The new, shiny and tiny Nano 33 BLE and Nano 33 BLE Sense are on their way to becoming a serious threat to any hacker’s summer vacation. (I’d recommend spending a couple of days at the lake or beach anyway despite the board’s awesomeness!)

Quoting Sir Isaac Newton (who walked the same streets of Cambridge, UK that the Arm engineers use to get to work everyday), starting from scratch is not always a clever idea. Tens of thousands of man-hours have been spent since the beginning of computer science to reinvent the wheel, sometimes with great results, other times just bringing more fragmentation and confusion.

Since we didn’t have an official Arduino core for the Nordic nRF52840 Cortex-M4 microcontroller, which the Nano 33 BLE and Nano BLE Sense are based upon, we took a look at the various alternatives:

  • Using Nordic softdevice infrastructure
  • Writing a core from scratch
  • Using Mbed OS as a foundation

Option one looks juicy but clashes with a cornerstone of Arduino: open-source software. In fact, softdevice’s closed source approach limits the user’s freedom.

Option two would take a lot of burden on our shoulders for a single board, making the core not very reusable.

So, we went to option three: basing the core on Mbed OS foundation, sharing its drivers and libraries.

As many of you may know, Mbed is a fully preemptive RTOS (real-time operating system), meaning you can run multiple “programs” (more specifically, threads) at the same time, much like what happens in your notebook or smartphone. At Arduino, we have been looking for an RTOS to use on our more advanced boards for a long time but we never found something we liked until we started working with the Mbed OS. Programming an RTOS is usually quite complicated (every university grade course on operating systems will be full of frightening terms like ‘mutex’ and ‘starvation’), but you don’t have to worry if you just want to use it as an Arduino; setup() and loop() are in their usual place, and nobody will mess with your program while it’s running.

But if you want to do MORE, all Mbed infrastructure is there, hidden under the mbed:: namespace. As a side effect of reusing its drivers, we can now support every Mbed board in Arduino with minimal to no effort. Plus, the structure of the core allows any Mbed developer to use Arduino functions and libraries, simply by prepending arduino:: before the actual function call.

Mbed also supports tickless mode; in this way, every time you write delay() in your code, the board will try to go in low power modes, knowing exactly when to wake up for the next scheduled event (or any external interrupt). We are able to achieve an impressive 4.5uA of lower consumption while running a plain old Blink on the Nano 33 BLE (a minimal hardware modification is needed to obtain this value but another blog post is coming). As for Bluetooth® support, you can start creating your Bluetooth® Low Energy (BLE) devices today using the wonderful https://github.com/arduino-libraries/ArduinoBLE but we support plain Cordio APIs as well, in case you need features not yet available in Arduino BLE.

And of course, it’s all open-source! 

If you just want to make awesome projects with its plethora of onboard sensors, fire up your Arduino IDE, open the board manager and search for Nano 33 BLE; one click and you are ready to go! 

If you want to hack the core, add another Mbed board or merely take a look, your next entry point is the GitHub repo. Don’t be shy if you find a bug or have a suggestion; we love our community, and will try to be as responsive as possible. 

5 Responses to “Why we chose to build the Arduino Nano 33 BLE core on Mbed OS”

  1. sensorsiot Says:

    I also tried to connect my Nano IOT to your platform. Unfortunately, I got the error message:
    “We weren’t able to configure the Crypto Chip. Timeout reached before we could configure your board.”
    I tried it several times.

  2. vacech Says:

    After playing with Arduino Nano 33 BLE Sense board in Arduino IDE 1.8.9 for a short time I would like to comment on “…all Mbed infrastructure is there, hidden under the mbed:: namespace.”:

    What I have found out so far is that different parts of the Mbed infrastructure reside in their own (top level) namespaces (mbed, rtos, events, etc.):

    rtos::Thread my_thread; // neither mbed::Thread nor mbed::rtos::Thread

    No need to include anything in the IDE after I installed the Nano 33 BLE board in Board Manager and selected the board for the sketch.

    The namespaces of different parts of Mbed can be found in the header files at the GitHub repository for ArduinoCore-nRF528x-mbedos (see https://github.com/arduino/ArduinoCore-nRF528x-mbedos/tree/master/cores/arduino/mbed)

  3. charly371 Says:

    Since the board is compatible with MBED OS thanks to your work…. I wonder if there is a way to use this board with MBED OS directly (and bypass the Arduino core) ? I would like to try to go deeper and use native MBED libs and thus may not need Arduino code and prefer to use MBED studio.

  4. beaug45 Says:

    “We are able to achieve an impressive 4.5uA of lower consumption while running a plain old Blink on the Nano 33 BLE (a minimal hardware modification is needed to obtain this value but another blog post is coming).”

    Has this ^ been posted yet? I assume the ” minimal hardware modification” is cutting the 3.3V jumper?

  5. gambafrolla Says:

    “We are able to achieve an impressive 4.5uA of lower consumption while running a plain old Blink on the Nano 33 BLE (a minimal hardware modification is needed to obtain this value but another blog post is coming).”

    I’m curious too in lowpower techniques. Is there a tutorial/article/post out there?

Leave a Reply

You must be logged in with your Arduino account to post a comment.