Arduino to ODrive Communication using CAN interface


I just started building communication between an arduino and ODrive using CAN interface. However, I don’t see any response for my CAN message for velocity control at ODrive.

Can someone please help me with this matter ?

Device : Arduino + MCP2515 CAN Bus Module
To set the velocity set point to 2 turns/s
Axis ID = 0x01
Command ID = 0x00D

Arduino Code:

#include <SPI.h>
#include <mcp_can.h>

const int spiCSPin = 53;
int ledHIGH = 1;
int ledLOW = 0;


void setup()

while (CAN_OK != CAN.begin(CAN_1000KBPS))
    Serial.println("CAN BUS init Failed");
Serial.println("CAN BUS Shield Init OK!");


// ID for ODrive
int canID = (0x001 << 5) + 0x00D;
// velocity set point
int setV = 2;
// CAN message
unsigned char stmp[6] = {setV ,(setV>>8), (setV>>16), (setV>>24), 0, 0};

void loop()
CAN.sendMsgBuf(canID, 0, 6, stmp);

unsigned char len = 0;
unsigned char buf[8];

if(CAN_MSGAVAIL == CAN.checkReceive())
CAN.readMsgBuf(&len, buf);

unsigned long canId = CAN.getCanId();
Serial.print("Data from ID: 0x");
Serial.println(canId, HEX);

for(int i = 0; i<len; i++)
  // print the data
  Serial.print(buf[i]); Serial.print("\t");


Do I also need to add another termination resistor (120 ohms) to CAN_H CAN_L line ?

Thank you.

Hey buddy,

How has the progress on the Arduino-CAN front? I’ve had some battles with it but got through ok.

Are you receiving the heartbeats or can you send any communication via CAN?

Do I also need to add another termination resistor (120 ohms) to CAN_H CAN_L line ?
It needs to be terminated at both ends. The little switch on the Odrive & the Arduino. I’m using the Arduino MKR 1010 CAN shield which has it included.

Thanks @PaulM for your response.

It worked. The issue was with baud rates. When I change the baud rate of Arduino to double the ODrive’s baud rate, it started working. :man_facepalming:

1 Like

That is because the crystal oscillator on the Arduino board is probably 8Mhz instead of 16Mhz… you’ll want to check, it probably says 8000 or something on it.

Ohh alright, I got it. I started building the CAN communication with my STM32F4 discovery board, so that I have more control over defining the clock frequencies in peripherals. I’ll let you know how it goes. But I’m pretty sure, I’ll need more support as this is my first experience in CAN communication and I’m from mechanical engineering background. :worried: :worried:

No worries. Ask away. I had some problems with the CAN bus & arduino (MKR 1010 wifi) but have it up and working.

Hi bro,
How was your progress on the STM32F4 CAN bus interface with odrive ?