Sending CAN using Arduino Nano and MCP2515 with coryfowler's MCP_CAN_lib

Hello Guys, first post here and basically my first Arduino Project.

I wanted to try and send or receive CAN-Signals with an Arduino and an MCP2515. I decided to use this library . And tried to send simple CAN-Signals with the MCP2515.

However... Even though I have seen it working on other Arduino's and even tried copying the exact example given by the Author of the API. The Serial Monitor always reads "Entering Configuration Mode Failure..." followed by a custom Error Message.

Regarding the Sketch:

  • Speed has been adjusted but my CAN-Sniffing Tool never receives anything on that speed, even though the example keeps printing "Message Sent Successfully"
  • No Idea what the canClock does but neither 16MHz or 8Mhz does the trick
  • Arduino has Power
  • MCP2515 has a single RED LED lighted up with a label next to it being "POW". So yeah, that one has power as well but maybe it's supposed to blink any different?

Regarding the Hardware:

  • [MCP2515 -> Arduino] VCC -> +5V; GND -> GND; CS -> PIN10 (Tried others without success, changing that line in the example as well, obviously.)
  • Arduino Nano with ATmega328P (Old Bootloader) and configured as that inside the Arduino IDE as well
  • I am injecting the CAN into an OBD2-Breakout-Box and sniffing the Signals with that. The Breakout-Box has led's that light up if there are signals going through CAN and those do not light up. Even though "Message Sent Successfully!" continues being printed to the Serial Monitor.
  • Tried other MCP2515-Modules as well with the same result.

An Example from the Serial Monitor: 18:35:25.599 -> Entering Configuration Mode Failure... 18:35:25.599 -> Error Initializing MCP2515... 18:35:25.599 -> Error Sending Message... 18:35:26.626 -> Error Sending Message... 18:35:27.612 -> Message Sent Successfully! 18:35:28.597 -> Message Sent Successfully! 18:35:29.620 -> Message Sent Successfully! xx:xx:xx.xxx -> Message Sent Successfully! (Continues until I stop it)

I have tried a different library with the same result.

TheLexoPlexx: Hello Guys, first post here and basically my first Arduino Project.

Welcome! I would say you picked an "advanced level" project for your first.

TheLexoPlexx: - No Idea what the canClock does but neither 16MHz or 8Mhz does the trick

The library loosely supports 8, 16 and 20 MHz crystal frequencies. There should be a metal cased device mounted near the MCP2515 IC on your CAN hardware, it should have the frequency labeled on it in some manner. The library needs this information so if can configure the baudrate settings correctly.

TheLexoPlexx: - MCP2515 has a single RED LED lighted up with a label next to it being "POW". So yeah, that one has power as well but maybe it's supposed to blink any different?

Speaking of, you never mentioned what specific hardware you are using outside of the Arduino Nano.

TheLexoPlexx: An Example from the Serial Monitor: 18:35:25.599 -> Entering Configuration Mode Failure... 18:35:25.599 -> Error Initializing MCP2515... [...]

Both of these errors suggest to me that there is a wiring issue or otherwise the ATmega328 is not able to communicate with the MCP2515. Configuration would still succeed if the crystal frequency is incorrect, by the way.

TheLexoPlexx: I have tried a different library with the same result.

This would confirm that you have a hardware issue.

coryjfowler: The library loosely supports 8, 16 and 20 MHz crystal frequencies. There should be a metal cased device mounted near the MCP2515 IC on your CAN hardware, it should have the frequency labeled on it in some manner. The library needs this information so if can configure the baudrate settings correctly.

Oh indeed, found that and it is 8 MHz.

coryjfowler: Speaking of, you never mentioned what specific hardware you are using outside of the Arduino Nano.

Only the Arduino Nano and an MCP2515. Power Supply for the Arduino is done via USB and the MCP2515 therefore also receives it's energy from the Arduino... Speaking of... does that even work?

coryjfowler: Both of these errors suggest to me that there is a wiring issue or otherwise the ATmega328 is not able to communicate with the MCP2515.

I wired the MCP2515 and the Nano like suggested over here: http://forum.arduino.cc/index.php?topic=476862.0

Ater setting the Baudrate to 8 and the mode to MCP_LOOPBACK, I get "Entering Configuration Mode Successful".

However... Neither my OBD2-Breakout-Box-LED lights up and my CAN Sniffing Tool does nothing as well. I plugged the CAN_H and CAN_L wires from the MCP2515 directly into the Breakout Box. So the OBD-2-Adapter now has the following Inputs: 4: GND 6: CANH 14: CANL 16: Bat+ (12V)

#EDIT: There seemed to be one or more faulty cables. I replaced them and Initialization works fine now.

However: CAN_OK does not seem to be okay because it results into an "Error Sending Message...". The Serial Monitor prints "Success" if I change the Mode to MCP_LOOPBACK instead of Normal but my Sniffer does not read anything in either cases.

More #EDIT: Again: Different Library with same result. Initialization works and tells me Packet Sending would work but nothing arrives.

###FINAL EDIT### I didn't have a terminator between CAN High and CAN Low. That fixed the Problem.