1 of 46

Arduino to RTOS—A Pilgrim’s Progress

TJ VanToll & Zak Fields

Developer Relations

Blues Notecard 30mm x 35mm

2 of 46

TJ VanToll

Principal Developer Advocate

@tjvantoll

Zak Fields

Staff Experience Engineer

@zfields

3 of 46

Arduino to RTOS—A Pilgrim’s Progress

4 of 46

5 of 46

6 of 46

6

7 of 46

“Each lesson supports 3 device choices - Arduino, or a single-board computer, either a physical device (a Raspberry Pi 4) or a virtual single-board computer running on your PC or Mac.”

7

- IoT for Beginners by Microsoft

8 of 46

8

9 of 46

9

10 of 46

10

Myths

  • #1: Platforms like Arduino and Raspberry Pi are only for beginners.
  • #2: RTOS platforms are impossibly complex and only for “real” engineers building “real” projects.

11 of 46

12 of 46

12

What you’ll learn

  • Using an RTOS is possible, and the best path forward for many IoT Projects.
  • When an RTOS is a good fit, and when it’s overkill.
  • The pros and cons of Zephyr in action.

13 of 46

14 of 46

Easy for developers and affordable for all.

15 of 46

15

Notecard

  • Low-power system-on-module
  • Global cellular/GPS or Wi-Fi
  • 500MB cell data + 10 years service
  • JSON-based API
  • NB-IoT, LTE-M, LTE Cat-1
  • Python, Go, Arduino, C/C++, Zephyr

16 of 46

“Device-to-Cloud Data Pump”

🔒

17 of 46

18 of 46

*Actual wiring may vary

19 of 46

19

20 of 46

21 of 46

22 of 46

23 of 46

24 of 46

24

Myths

  • #1: Platforms like Arduino and Raspberry Pi are only for beginners.
  • #2: RTOS platforms are impossibly complex and only for “real” engineers building “real” projects.

25 of 46

Zak Fields

Staff Experience Engineer

@zfields

26 of 46

Arduino:Quick Recap

.

.

.

.

.

.

.

.

26

27 of 46

Arduino:Quick Recap

Fast and Easy

.

.

.

.

.

.

27

28 of 46

Arduino:Quick Recap

Fast and Easy

Powerful

💪

.

.

.

.

28

29 of 46

Arduino:Quick Recap

Fast and Easy

Powerful

💪

Broad Support

⚙️

.

.

29

30 of 46

Arduino:Quick Recap

Fast and Easy

Powerful

💪

Broad Support

⚙️

Community

🧑‍👨‍🔧

👩‍🔬👨🏿‍🚀

30

31 of 46

Arduino:�The Dark Side

.

.

.

.

.

.

31

32 of 46

Arduino:�The Dark Side

IDE 1.x - no debugging

IDE 2.x - only supports Arduino boards

VS Code Extension

Platform.io

Disjoint Debugging Experience

.

.

.

.

32

33 of 46

Arduino:�The Dark Side

IDE 1.x - no debugging

IDE 2.x - only supports Arduino boards

VS Code Extension

Platform.io

Multiple authors with varying level of skill.

Each library has a unique license.

No guarantee of portability.

Disjoint Debugging Experience

Library System:

Powerful but Inconsistent

.

.

33

34 of 46

Arduino:�The Dark Side

IDE 1.x - no debugging

IDE 2.x - only supports Arduino boards

VS Code Extension

Platform.io

Multiple authors with varying level of skill.

Each library has a unique license.

No guarantee of portability.

Arduino API is small.

Testing is difficult.

Each BSP has bespoke implementations of threading, radios, etc.

Disjoint Debugging Experience

Library System:

Powerful but Inconsistent

Complex Code is Not  Portable/Maintainable

34

35 of 46

For the win[d]...

36 of 46

Native Threading/Timer Support��Twister Testing Framework��Support for Debugging��Native Sensor Libraries

37 of 46

int main (void) {

  // put your setup code here, to run once:

  while (1) {

    // put your main code here, to run repeatedly:

  }

  return 0;�}

void setup (void) {

  // put your setup code here, to run once:

}

void loop (void) {

  // put your main code here, to run repeatedly:

}

Zephyr: Basic Structure

38 of 46

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led0),gpios);

int main (void) {

  gpio_pin_configure_dt(&led,GPIO_OUTPUT_ACTIVE);

  while (1) {

    gpio_pin_toggle(&led);

    k_msleep(250);

  }

  return 0;�}

void setup (void) {

  pinMode(LED_BUILTIN,OUTPUT);

}

void loop (void) {

  digitalWrite(LED_BUILTIN,HIGH);

  delay(250);

  digitalWrite(LED_BUILTIN,LOW);

  delay(250);

}

Zephyr: Blinky 🤔

39 of 46

Zephyr uses devicetree to describe:

  • the hardware available on its Supported Boards
  • that hardware’s initial configuration

Zephyr: Devicetree

So, what does that mean for you?

40 of 46

41 of 46

Zephyr: Getting Started

Easy?�  ¯\_(ツ)_/¯

42 of 46

Zephyr: Getting Started

+

=

Easy.

   😎

https://blues.dev/zephyr

https://github.com/blues/note-zephyr.git

+

43 of 46

VS Code: Revisit Demo

44 of 46

44

👈 Emulate the Arduino Runtime

Talk to the BME280

the Zephyr way... 👉

45 of 46

45

46 of 46

  • 🧑‍💻 blues.dev for Blues resources

Thanks! (Time for Q&A)