# Arduino UAVCAN Library

**URL:** <https://forum.opencyphal.org/t/arduino-uavcan-library/905>\
**Category:** Applications & Usage\
**Created:** [August 6, 2020, 12:31pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905 "2020-08-06T12:31:27Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [August 6, 2020, 12:31pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/1 "2020-08-06T12:31:27Z")

</div>

Hello,

As those of you which keep tabs on the [Viper Quadcopter](https://forum.opencyphal.org/t/viper-quadcopter/816) topic probably already know I’ve been working on [libcanard](https://github.com/UAVCAN/libcanard)-based Arduino library allowing the usage of the UAVCAN protocol via the Arduino platform. I’m happy to say this work has reached a stage where it can be presented to the wider public: [107-Arduino-UAVCAN](https://github.com/107-systems/107-Arduino-UAVCAN). It’s currently only available via direct download from github but will be available shortly via the [Library Manager](https://www.arduino.cc/en/guide/libraries).

A first idea on how to use the library can be gained from taking a look at the [README](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/README.md) of the repository. Examples demonstrating publishing and subscribing as well as service client/service server are available [here](https://github.com/107-systems/107-Arduino-UAVCAN/tree/master/examples). Taking a look at the [test code](https://github.com/107-systems/107-Arduino-UAVCAN/tree/master/extras/test/src) compiled and executed upon every push to the repository gives further insight into the libraries usage and design philosophy.

Currently one message type ([`uavcan/node/Heartbeat.1.0`](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/src/types/uavcan/node/Heartbeat.1.0.h)) and one service type ([`/uavcan/node/ExecuteCommand.1.0`](https://github.com/107-systems/107-Arduino-UAVCAN/blob/master/src/types/uavcan/node/ExecuteCommand.1.0.h)) are available within the library although it should be fairly easy to add other types (and maybe this process can even be automated in some way? - that’s smth I’ve not looked at all yet).

Please keep in mind that this is an Arduino library and as such has been designed with **simplicity in mind**. Therefore certain choices where made that limit the power the programmer has compared to directly using `libcanard` without any abstraction layers. Nonetheless it should provide a smooth first start into the usage of UAVCAN without having to go through all the steps necessary with bringing any embedded project off the ground.

Edit: It’s [now](https://github.com/arduino/Arduino/issues/10573) also available via Arduino IDE Library Manager.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [August 13, 2020, 8:30am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/2 "2020-08-13T08:30:37Z")

</div>

Hello 👋  
I’m looking at [https://github.com/UAVCAN/public\_regulated\_data\_types/blob/master/uavcan/node/430.GetInfo.1.0.uavcan#L41](https://github.com/UAVCAN/public_regulated_data_types/blob/master/uavcan/node/430.GetInfo.1.0.uavcan#L41)

```auto
uint64[<=1] software_image_crc

```

and I can’t help but wonder how an optional `uint64_t` would be serialised. Will it be prepended by an implicit length field that either says `0` or `8`?

E.g. software\_image\_crc being encoded →

```auto
uint8_t | len | 8
uint64_t | software_image_crc_val | 0xDEADBEEFCAFE1337
/* Next entry ... */

```

or software\_image\_crc being NOT encoded →

```auto
uint8_t | len | 0
/* Next entry ... */

```

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 13, 2020, 10:53am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/3 "2020-08-13T10:53:39Z")

</div>

> [@aentinger](#):
>
> Will it be prepended by an implicit length field that either says `0` or `8` ?

0 or 1 (section 3.7.4.2 Variable-length array types)

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [August 14, 2020, 4:30am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/4 "2020-08-14T04:30:16Z")

</div>

Good morning @pavel.kirienko ☕

Thank you for getting back to me. Now that you write it it’s obvious to me that a optional data field is just a special array case, that is an array with a length of zero. I was led astray by the fact that it’s not advertised as an array type but rather as a optional field that’s either there or not.

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [August 14, 2020, 3:21pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/5 "2020-08-14T15:21:07Z")

</div>

> [@aentinger](#):
>
> it’s not advertised as an array type

But but, it is though: `uint64[<=1]` – that’s an array type.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [September 16, 2020, 5:22am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/6 "2020-09-16T05:22:55Z")

</div>

[Version 1.0.2](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.0.2) has just been released. Major changes are the replacement of the self-coded serialisation/deserialisation logic by the one generated via `nnvg` as well as support for **uavcan/node/Version.1.0** and **uavcan/node/ID.1.0**.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [October 2, 2020, 5:57am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/7 "2020-10-02T05:57:10Z")

</div>

[Version 1.0.3](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.0.3) has just been released. The API has changed so that the library is now directly fed with `CanardFrame` typed CAN frames. This change is precedented by the release of [107-Arduino-MCP2515:v1.2.0](https://github.com/107-systems/107-Arduino-MCP2515/releases/tag/1.2.0) which allows to directly send/receive CAN frames via MCP2515 and Arduino enabled boards.

---

<div class="post-metadata">

**Author:** ![vivienJ](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/vivienj/32/1217_2.png) [@vivienJ](https://forum.opencyphal.org/u/vivienJ)\
**Post date:** [November 13, 2020, 3:27pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/8 "2020-11-13T15:27:49Z")

</div>

Hello, thank you for this work it’s very useful. I have an simple question why does this work only for samd and mbed arduinoCore and not for classic Arduino Uno or nano ? CPU architecture, not powerfull enough, easier like that ?

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [November 13, 2020, 4:04pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/9 "2020-11-13T16:04:16Z")

</div>

Thank you ☀ It’s possible that the AVR based Arduino’s could run 107-Arduino-UAVCAN when considering raw computing and memory requirements. However, C++11 and STL support leaves much to be desired for on the AVR platform and while it should be possible to compile for AVR pulling in 3rd party libraries providing STL I wouldn’t want to bet on the performance.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [November 17, 2020, 7:54am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/10 "2020-11-17T07:54:58Z")

</div>

Version [1.1.0](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.1.0) has just been released 🚀

The most important change is that the library now supports [UAVCAN v1.0-beta](https://uavcan.org/specification/UAVCAN_Specification_v1.0-beta.pdf).

Thanks to @pavel.kirienko for not despairing over my numerous questions and continuous prodding on various issues 😉

---

<div class="post-metadata">

**Author:** ![vivienJ](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/vivienj/32/1217_2.png) [@vivienJ](https://forum.opencyphal.org/u/vivienJ)\
**Post date:** [November 25, 2020, 4:47pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/11 "2020-11-25T16:47:25Z")

</div>

Hello, I can’t seem to make your new example to work (UAVCAN-GNSS-Node). The UAVCAN-Heartbeat-Publish does not work for me either.

I use an Arduino nano 33 iot with a MCP2515 card ([link](https://www.amazon.com/Comidox-MCP2515-Receiver-Controller-Development/dp/B07J9KZ4L4/ref=sr_1_2?dchild=1&keywords=MCP2515&qid=1606319620&sr=8-2)). I can’t see the heartbeat node neither on QgroundControl (Pixhawk4 with PX4 v1.11) nor on UAVCAN GUI Tool (bluePill) but the Zubax GNSS node works on both.

Configuration tested:

- Pixhawk→ZubaxGNSS→MPC2515(with 120ohm resistor) + Arduino\_33\_iot

- UAVCAN\_GUI\_Tool (bluePill) → MPC2515(with 120ohm resistor) + Arduino\_33\_iot

- Pixhawk → ZubaxGNSS → UAVCAN\_GUI\_Tool (bluePill)

- Pixhawk → ZubaxGNSS → UAVCAN\_GUI\_Tool (bluePill) and the MPC2515(without 120ohm resistor) +Arduino\_33\_iot between GNSS and bluepill

With all these configurations Pixhawk, GNSS and UAVCAN\_GUI\_tool work fine but not one display the heartbeat node.

The pinout between arduino and MPC2515 :

> **[Pinout-NANO33IoT\_latest.pdf](https://content.arduino.cc/assets/Pinout-NANO33IoT_latest.pdf)**
>
> 233.20 KB

arduino : MPC2515  
D11 : SI  
D12 : SO  
D13 : SCK  
D3 : CS  
D7 : INT  
and off course VCC and GND

Did I make a mistake in this configuration?

---

<div class="post-metadata">

**Author:** ![pavel.kirienko](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/pavel.kirienko/32/9_2.png) [@pavel.kirienko](https://forum.opencyphal.org/u/pavel.kirienko)\
**Post date:** [November 25, 2020, 4:58pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/12 "2020-11-25T16:58:28Z")

</div>

This is because all of the other equipment you mentioned here runs UAVCAN v0. There is work underway to release preliminary UAVCAN v1 support (MVP) in PX4 in the very near future (I suspect it’s about a week away, but @TSC21 knows best). For now, please use the PyUAVCAN CLI for testing.

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [November 25, 2020, 5:33pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/13 "2020-11-25T17:33:39Z")

</div>

Hi 👋

The pin-out looks very much correct, you can try and run [MCP2515-Loopback](https://github.com/107-systems/107-Arduino-MCP2515/blob/master/examples/MCP2515-Loopback/MCP2515-Loopback.ino) on your Nano 33 IoT and check if you see the following output on your serial (timestamp may differ):

```auto
[4232231] ID 1 DATA[0] 
[4242479] ID 2 DATA[4] CA FE CA FE 
[4252705] ID 3 DATA[8] CA FE CA FE CA FE CA FE 
[4262682] ID 4 DATA[4] 21 0 0 EC 
[4272643] ID 7FF DATA[0] 
[4282847] ID(EXT) 80000000 DATA[0] 
[4292947] ID(EXT) 9FFFFFFF DATA[0] 

```

Other than that I’ve got to confirm @pavel.kirienko’s assesment, that is that UAVCAN V1 is currently not supported my any tools except `pyuavcan cli`. In order to clarify this and safe future early adopters the trouble I’ve augmented the repositories README with a [warning](https://github.com/107-systems/UAVCAN-GNSS-Node/commit/2ce8849dc433b7d2fe65ecca4f9896b65122e245).

---

<div class="post-metadata">

**Author:** ![TSC21](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/tsc21/32/499_2.png) [@TSC21](https://forum.opencyphal.org/u/TSC21)\
**Post date:** [November 26, 2020, 9:32am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/14 "2020-11-26T09:32:23Z")

</div>

@pavel.kirienko it is not a week away. There’s an identified need of properly define the network services.

---

<div class="post-metadata">

**Author:** ![vivienJ](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/vivienj/32/1217_2.png) [@vivienJ](https://forum.opencyphal.org/u/vivienJ)\
**Post date:** [November 26, 2020, 5:02pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/15 "2020-11-26T17:02:49Z")

</div>

OK, MCP2515-Loopback is a good debugging tool, I found that the Arduino pin-out was not good, the nano\_33\_iot can’t use D7 with attachInterrupt() function. I changed it to the D9.

I hope we will be able to use it with PX4 soon.

Thanks to all 3 for your answers

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [December 3, 2020, 8:16am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/16 "2020-12-03T08:16:32Z")

</div>

For general information: I’ve created a separate [github project](https://github.com/orgs/107-systems/projects/4) in order to untangle the **UAVCAN on Arduino** effort from the Viper MAV project (so far only [Viper MAV](https://github.com/orgs/107-systems/projects/3) was pursued and tracked within the [107-systems](https://github.com/107-systems) github org).

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [January 25, 2021, 7:20am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/17 "2021-01-25T07:20:37Z")

</div>

Version [1.2.0](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.2.0) has just been released 🚀

There are loads of minor consolidating changes, however the most important change is that the library does now support [ESP32](https://github.com/espressif/arduino-esp32).

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [March 16, 2021, 6:05am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/18 "2021-03-16T06:05:30Z")

</div>

I’ve just released version [1.3.0](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.3.0) 🚀

Nearly all UAVCAN DSDL types currently specified within [UAVCAN/public\_regulated\_data\_types](https://github.com/UAVCAN/public_regulated_data_types) are supported. The only ones missing are [public\_regulated\_data\_types/uavcan/si](https://github.com/UAVCAN/public_regulated_data_types/tree/master/uavcan/si) (also see [#98](https://github.com/107-systems/107-Arduino-UAVCAN/issues/98)).

Aside from this one, there are a couple of easy to tackle issues available: [#92](https://github.com/107-systems/107-Arduino-UAVCAN/issues/92) and [#99](https://github.com/107-systems/107-Arduino-UAVCAN/issues/99). Any help would be greatly appreciated 💖

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [April 14, 2021, 1:15pm UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/19 "2021-04-14T13:15:01Z")

</div>

[107-Arduino-UAVCAN:v1.3.1](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.3.1), the Arduino library for [UAVCAN](https://uavcan.org/) has been released. Support for ESP32 has been fixed (didn’t compile, due to erroneous macro expansion).

---

<div class="post-metadata">

**Author:** ![aentinger](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/aentinger/32/1428_2.png) [@aentinger](https://forum.opencyphal.org/u/aentinger)\
**Post date:** [November 9, 2021, 5:21am UTC](https://forum.opencyphal.org/t/arduino-uavcan-library/905/20 "2021-11-09T05:21:59Z")

</div>

[107-Arduino-UAVCAN:v1.4.0](https://github.com/107-systems/107-Arduino-UAVCAN/releases/tag/1.4.0) has just been released. Contains all DSDL types as per [public\_regulated\_data\_types@0a773b9](https://github.com/UAVCAN/public_regulated_data_types/tree/0a773b93ce5c94e1d2791b180058cb9897fab7e1) and does support the community contributed Raspberry Pi RP2040 core [arduino-pico](https://github.com/earlephilhower/arduino-pico). This means the library can be run on any of the RP2040 based boards provided by this core.

@pavel.kirienko I see that [public\_regulated\_data\_types#125](https://github.com/UAVCAN/public_regulated_data_types/pull/125) eliminated /reg/drone. Please advise on whether or not to update the DSDL types within 107-Arduino-UAVCAN. I’d rather avoid reinstating reg/drone within a couple of months, so I’d prefer to keep them for now as is.

[Next page](https://forum.opencyphal.org/t/arduino-uavcan-library/905.md?page=2)
