Problem receiving CAN-bus with Arduino UNO, CAN-BUS Shield and PE3 calculator

Hi everyone,

I am a first year Student in an engeneer school in france, I am completly new on this forum and i would like to trade a bit of your wisdom and patience with my foolishness and poor english…

I am currently trying to get informations from a calculator PE3, which use the SAE J1939 protocol to transmit it’s canbus, in order to get speed, rpm and other informations on the engine and the car I am working on. I have managed to get the canbus but my problems come from the fact that those informations don’t change over time, even when the car is speeding up or slowing down.
I am certain the calculator does work because we have a software that can read the data correctly by plugging the calculator to a PC.
Here is my code:

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

int cmp_tab(float tab1,float tab2,int taille);  //pour comparer 2 tableaux

unsigned char Flag_Recv = 0;
unsigned char len = 0;
unsigned char buf[8];
char str[20];
int w = 0;
unsigned char rpm [8];
unsigned char BvlteCT [8];
unsigned char vitesse[8];
float RPM;

void setup()


    if(CAN_OK == CAN.begin(CAN_250KBPS))                   // init can bus : baudrate = 250k
        CAN.init_Filt(0,1,1);                        //actually i don't really know why i'm doing this but it doesn't work without this line
        Serial.println("\nCAN BUS Shield init ok");
        Serial.println("\nCAN BUS Shield init fail");
        Serial.println("\nInit CAN BUS Shield again");
        goto START_INIT;
    attachInterrupt(0, MCP2515_ISR, FALLING); // start interrupt

void MCP2515_ISR()
     Flag_Recv = 1;

void loop()
      if(Flag_Recv)                   // check if get data
        Flag_Recv = 0;
          INT32U a=CAN.getCanId();       //get the bus ID in order to see what data i'm receiving
          CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf
            case 218099784:            //rpm et tps
            Serial.println("\nrpm et tps: ");
            for(int i = 0; i<len; i++)    // print the data
                Serial.print(rpm[i]);Serial.print("\t");    //getting print and recorded the data i've received, depending on the ID
            if (RPM>=32767)
            Serial.println("\nles rpm:");
            case 218100808:
            Serial.println("\nvitesse: ");
            for(int i = 0; i<len; i++)
                Serial.print(vitesse[i]);Serial.print("\t ");
            case 218101064:
            Serial.println("\nBttry cool temp: ");
            for(int i = 0; i<len; i++)

Basically what it does is simple:
-check if some data has arrived
-get the ID of the bus
-check which ID it is
-store the data regarding the ID
-print the canbus

here is the canbus protocol of the calculator:

My skills in programing and english are a bit limited so I have to ask you to have simple answers please.
I am in a bit of a hurry though because I have to finish this before next thursday and i really don’t know how to do it…
I have search in the deep and dark parts of internet and I haven’t found the answer to my problem, even on forums.
I thank you already for your usefull answers :slight_smile:

Could someone answer my question please, I'm really trying to do it but I really don't understand why it doesn't work...

Take a look at my library, it will help out with J1939 messages.

Hi, Even I'm using PE3 ECU and Sparkfun CAN shield, I'm unable to even initialize communication with the ECU. Please help me out