CAN Bus Prototyping With Arduino Uno - Arduino CAN Sketches
This post is part of a series about Controller Area Network (CAN Bus) Prototyping With the Arduino Uno.
The implementation of either one of the introduced CAN Bus Shields and the corresponding CAN Bus sketches went surprisingly smooth when paired with the right library software.
I found several source codes for accessing the MCP2515 CAN controller, but most of them didn’t even pass the initial quality control phase (I read the code first before I use it). One of the quality criteria was the support for 29-bit CAN message identifiers (CAN 2.0B Compatibility), which is mandatory when it comes to implementing, for instance, the SAE J1939 vehicle network protocol. Some software samples I found were just literally “samples” and they left ample room for guessing games.
I was most pleased by the MCP2515 Library by Cory Fowler,
which can be found at:
This library is compatible with any shield or CAN interface that uses the MCP2515 CAN protocol controller.
In order to test and verify the proper transmission and reception of CAN messages, I used the ADFweb CAN-to-USB gateway with its Windows interface.
Note: In order to test a CAN Bus application, you need at least two CAN Bus nodes to establish a network communication. The second node can be another Arduino with CAN Bus shield or (if the budget allows) another CAN device with CAN Bus data monitoring capabilities.