I’m excited to share DroneCAN_ESP32, a lightweight Arduino/PlatformIO library that brings full DroneCAN protocol support to ESP32 microcontrollers.
Key Features
-
Complete DRONECAN Stack — Built on Libcanard, a well-established DRONECAN implementation
-
Flexible Transfer Types — Broadcast messages, service requests, and responses
-
Complete Standard Message Types — Ready-to-use definitions for BatteryInfo, NodeStatus, GNSS, ESC, LightsCommand, and more
-
Callback-based Architecture — Clean receive hooks and accept filters for custom filtering logic
Architecture
The library integrates two open-source components:
-
Libcanard — Core DRONECAN protocol handling (transfers, CRC, deduplication)
-
ACAN_ESP32 — ESP32 CAN hardware driver
This means you get a complete protocol stack from application down to the CAN transceiver, with no extra dependencies.
Quick Start
#include <DroneCAN_ESP32.h>
DroneCAN_ESP32 dronecan;
void onReceive(CanardInstance* ins, CanardRxTransfer* transfer) {
Serial.printf("Received data_type=%u\n", transfer->data_type_id);
}
void setup() {
Serial.begin(115200);
dronecan.setReceiveCallback(onReceive);
dronecan.begin(1000000, 42); // 1Mbps, Node ID 42
}
void loop() {
dronecan.update(); // Process CAN frames regularly
}
Supported Message Types
The library includes pre-generated headers for common UAVCAN messages:
| Category | Examples |
|---|---|
| Power | BatteryInfo, CircuitStatus, PrimaryPowerSupplyStatus |
| GNSS | Fix, RTCMStream, ECEFPositionVelocity |
| Node Management | GetNodeInfo, NodeStatus, RestartNode |
| Actuators | Command, RawCommand, Status |
| ESC | RPMCommand, Status, StatusExtended |
| Debug | LogMessage, KeyValue, LogLevel |
Installation
The library is published to the Arduino Library Manager. Search for DroneCAN_ESP32 in the Library Manager, or install manually by copying this repository to your libraries/ folder.
Repository: DroneCAN_ESP32
Feel free to ask questions or open issues on GitHub. Happy CANning!