Good evening everyone,
I'm currently working on a project that involves connecting an MCP2515 and an Arduino UNO to talk to my Renault car's OBD2 interface.
Here's how my setup looks right now, with the MCP2515 pins on the left and the corresponding Arduino pins on the right:
INT -> D2
SCK -> D13
SI -> D11
SO -> D12
CS -> D10
VCC -> 5V Arduino
GND -> GND Arduino
I've been reading through some forums where people had trouble because they didn't use the ground (GND) of the car correctly.
This post about Fiat cars caught my eye: Reaading OBD canbus on Fiat?
Following their advice, I connected the SIGNAL GND
and CHASSIS GND
to the GND of the Arduino. Specifically, I connected pins 4 and 5 from the OBD connector together and linked them to the Arduino's GND.
Here's a diagram showing the pins for Renault's OBD:
This is the code I'm using:
#include <SPI.h>
#include <mcp2515.h>
struct can_frame canMsg;
MCP2515 mcp2515(10);
void setup() {
Serial.begin(115200);
mcp2515.reset();
mcp2515.setBitrate(CAN_500KBPS,MCP_8MHZ);
mcp2515.setNormalMode();
Serial.println("------- CAN Read ----------");
Serial.println("ID DLC DATA");
}
void loop() {
if (mcp2515.readMessage(&canMsg) == MCP2515::ERROR_OK) {
Serial.print(canMsg.can_id, HEX); // print ID
Serial.print(" ");
Serial.print(canMsg.can_dlc, HEX); // print DLC
Serial.print(" ");
for (int i = 0; i<canMsg.can_dlc; i++) { // print the data
Serial.print(canMsg.data[i],HEX);
Serial.print(" ");
}
Serial.println();
}
}
I made sure to change this line mcp2515.setBitrate(CAN_500KBPS,MCP_8MHZ);
to match my MCP2515's 8MHz quartz, like the library's instructions said:
You can also set oscillator frequency for module when setting bitrate: mcp2515.setBitrate(CAN_500KBPS, MCP_8MHZ);
But despite all this, nothing seems to be working.
I even tried sending CAN bus messages with the MCP2515 to check if it was the issue, but my oscilloscope readings indicate that the connection between the Arduino and MCP2515 is okay, and the MCP2515 itself is working because I can see changes on the screen of the oscilloscope.
I've tried different speeds using mcp2515.setBitrate
, different libraries, various tutorials, and even tested with and without the 120 ohms jumper, but nothing has worked so far.
For the 120 ohms jumper I used the one on the board :
If anyone as a suggestion it would be very helpful
Thanks !