autowp / arduino-mcp2515

Arduino MCP2515 CAN interface library
MIT License
795 stars 279 forks source link

Receiving Data Only at ID 70 Using MCP2515 with Arduino #110

Open Akhil3996 opened 6 months ago

Akhil3996 commented 6 months ago

I am using the MCP2515 CAN module to receive data from a BMS battery bank using Arduino. However, I am only receiving data with the CAN ID 70. Below is the code I am using:

include

include

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();      

} } Environment: WhatsApp Image 2024-05-24 at 3 01 06 PM

MCP2515 Library: autowp-mcp2515 Microcontroller: Arduino IDE: Arduino IDE CAN Bus Bitrate: 500kbps Oscillator Frequency: 8MHz Observed Behavior: I am only receiving data with the CAN ID 70. The data received looks like this: