Skip to content

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

Open
@Akhil3996

Description

@Akhil3996

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions