Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Akhil3996 opened this issue May 24, 2024 · 0 comments
Open

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

Akhil3996 opened this issue May 24, 2024 · 0 comments

Comments

@Akhil3996
Copy link

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

}
}
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:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant