CAN bus filtering specified data

Working on a project using UNO + NiRen mcp2515 shield.
Its my first CAN experience, so it took some time to make it work, and finally i got data using CoryJFowler library. Good thing i have Canhacker so that helped me alot with checking and searching values im interested in.
Standard ID: 0x608 DLC: 8 Data: 0x7C 0x42 0xFC 0x6D 0x70 0x00 0x00 0x00
Thats the line im interested but main thing is to separate first data bytes (same as a DLC: 1) 0x7C.
Thats a temp value, so need print it to terminal withought all others. Im novice and looks hard to manage program code.

Using Cory’s receive example i almost did all i want with lack of knowledge.
It takes first data bytes to terminal once id:608 packed is received and then value stuck even it changes realtime i always see the 1st received value (doesnt update). Another thing my filter not very correct and it loads CPU.

Code im using:

// CAN Receive Example

#include <mcp_can.h>
#include <SPI.h>

long unsigned int rxId;
unsigned char len = 0;
unsigned char rxBuf[8];
char msgString[128];                        // Array to store serial string
long unsigned int T=0;

#define CAN0_INT 2                              // Set INT to pin 2
MCP_CAN CAN0(10);                               // Set CS to pin 10

void setup()
  // Initialize MCP2515 running at 16MHz with a baudrate of 500kb/s and the masks and filters disabled.
  if(CAN0.begin(MCP_ANY, CAN_500KBPS, MCP_8MHZ) == CAN_OK)
  CAN0.setMode(MCP_NORMAL);                     // Set operation mode to normal so the MCP2515 sends acks to received data.

  pinMode(CAN0_INT, INPUT);                            // Configuring pin for /INT input


void loop()
  if(!digitalRead(CAN0_INT))                         // If CAN0_INT pin is low, read receive buffer
    CAN0.readMsgBuf(&rxId, &len, rxBuf);      // Read data: len = data length, buf = data byte(s)

    if(rxId  == 0x608){   
       for(byte i = 0; i<len; i){
      //  sprintf(msgString, " %.2X", rxBuf[i]);


Thanks in advance

Try changing

for(byte i = 0; i<len; i){


for(byte i = 0; i<len; i++){

for a start.

Its possible you are reading the bus too often but I dont know enough about the CAN_INT0 signal to be sure- it may be that you only need to read a message when the pin changes state, not whenever its LOW.

in Cory's example it's i++, so when i leave it as is: 94 28 212 69 72 4294967256 4294967256 4294967256 94 28 212 69 72 4294967256 4294967256 4294967256

94 is correct temperature all other is single bytes goes threw T=(rxBuf*-40);*

If you only want the first byte then no need for the loop. Change

for(byte i = 0; i<len; i){
      //  sprintf(msgString, " %.2X", rxBuf[i]);

to just print out the first byte.


Thanks for mr. rw950431 Working correctly, with live updating readed out value