CAN shield with multiple CAN devices

Using the shield on Arduino uno to receive datas from 2 CAN devices sending datas at 100Hz.
Using poll mode (not interruption) and reading at 500Hz on arduino (delay 2ms).

Sometime receiving datas (normal frame, 2 IDs, 8 bytes) is blocked due to error
Error given from checkerror function : return 5 and err value : 21

This behavior seems random and functions checkerrors, checkClearRxStatus and checkClearTxStatus didn’t help.

What is this error?
How to correct it?

Thank you.

Error code 5 returned from the checkerror function typically indicates a bus error.
Error value 21 (0x15 in hexadecimal) can be related to various issues on the CAN bus, such as bit errors, form errors, acknowledgement errors, or CRC errors.
Check if your CAN bus is properly terminated with 120-ohm resistors at both ends of the bus. Improper termination can cause reflections and signal integrity issues leading to communication errors.

Hi there,
Use a shorter Cable.
GL :slight_smile: PJ

and as liaifat85 said check your termination values when using more than two devices.

Thank you both for your answers.
I can’t use shorter cable due to the component setup. Moreover, cables aren’t very long ( ~3m).

The thing that is bugging me is that most of time it’s working. But sometimes (cold start) it didn’t run for hours than without any action it works like a charm until power supply cut.

The communication errors couldn’t be checked or cleared thank to the library?


Hi there,
Ok that’s good info, I would look to the Power Supply for it then, and Perhaps adding a CAP (+Vcc) on it.
It seems possible that it’s noise in the environment, any CRC’s in the comms? Is it retransmitting or repeating commands? Sounds like the start up power draw is maybe not right.
GL :slight_smile: PJ