CANBUS Shield V1.2 can not receive data from battery

Hey all, newbie here. I have bought an Uno and a CANBUS Shield V1.2 tried several codes but couldn't recevie data from a battery bms. Actually I can receive with a USB CAN tool. I want just one 8bit message which is like 00 00 00 00 00 00 01 42 and has an ID like 1E3 .

Can anyone help me about this?

1 Like

Hi, @zippobooo
Welcome to the forum.

Please read the post at the start of any forum , entitled "How to use this Forum".

This will help with advice on how to present your code and problems.

What BMS?
Are you receiving any data?
Do you have the CanBus speed set correctly?

Tom... :smiley: :+1: :coffee: :australia:

1 Like

Thanks for your advise @TomGeorge ,

What BMS?
I don't know the model or brand of the Battery Management System on the battery.

Are you receiving any data?
I install 5 different libraries and tried the receive and receive check samples of those libraries. And nothing shows up.

Do you have the CanBus speed set correctly?
Battery have 250kb/s bit rate and 9600 baud rate.

While using the USB CANbox tool, it is asking me to literally same things on sample codes. And I am striving like 3 weeks to write correct bunch of codes. Also I have checked all the topics related to my issue, finally decide to write if anyone help.

1 Like

Hi,
So you don't get any data on the IDE monitor screen?

You can check the monitor link by serial printing something in the void setup() part of your code.
Have you Googled;

arduino can bus BMS

Tom... :smiley: :+1: :coffee: :australia:

1 Like

What settings did you apply with this tool?

please post one of the 'many' codes you tried AND how you have wired up the CAN bus shield to tap the BMS CAN bus.

After @TomGeorge advice me to search arduino can bus BMS I found and electric vehicle forum and they have shared different type of codes. I run one of them and it works! Thanks Tom again.

I will add and we can say it is done. I found what I want to get but there is another issue which is all the hex numbers show up consecutively with a 't' bracket.

.....1Bt1E30000000000000142t1F512A......

I am gonna try to solve it.

@sherzaad as I told before set the bit rate (250kbps), baud rate (9600) on USB tool.

//Thanks Anton Viktorov

#include <SPI.h>
#include "mcp_can.h"
#include "can-232.h"
#include "SoftwareSerial.h"

#define DEBUG_MODE

void setup() {
	  Serial.begin(9600); // default COM baud rate is 115200. 

        // Can232::init  (RATE, CLOCK)
        // Rates: CAN_10KBPS, CAN_20KBPS, CAN_50KBPS, CAN_100KBPS, CAN_125KBPS, CAN_250KBPS, CAN_500KBPS, CAN_500KBPS, CAN_1000KBPS, CAN_83K3BPS
        //        Default is CAN_83K3BPS
        // Clock: MCP_16MHz or MCP_8MHz. 
        //        Default is MCP_16MHz. Please note, not all CAN speeds supported. check big switch in mcp_can.cpp
        // defaults can be changed in mcp_can.h

//        Can232::init();             // rate and clock = LW232_DEFAULT_CAN_RATE and LW232_DEFAULT_CLOCK_FREQ
//        Can232::init(CAN_125KBPS);  // rate = 125, clock = LW232_DEFAULT_CLOCK_FREQ
    Can232::init(CAN_250KBPS, MCP_16MHz); // set default rate you need here and clock frequency of CAN shield. Typically it is 16MHz, but on some MCP2515 + TJA1050 it is 8Mhz


    // optional custom packet filter to reduce number of messages comingh through to canhacker
    // Can232::setFilter(myCustomAddressFilter); 
}

INT8U myCustomAddressFilter(INT32U addr) {
    INT8U ret = LW232_FILTER_SKIP; //LW232_FILTER_PROCESS or LW232_FILTER_SKIP
    switch(addr) 
        case 0x1E3:  
    //    case 0x2C0: // pedals
    //    case 0x3d0: // sound vol, treb..
    // ret = LW232_FILTER_PROCESS;
    //    case 0x000: // ?
    //    case 0x003: //shifter
    //    case 0x015: // dor open close affects this as well
    //    case 0x02c: // ???
            ret = 0;
    //        break;
    //    case 0x002:
    //    case 0x1a7: //fuel cons or some other
    //      ret = 1;
    //      break;
    //     default: 
    //       ret = 0;
    }
delay(5000);
  return ret;
}

void loop() {
    Can232::loop();
}

void serialEvent() {
    Can232::serialEvent();
}

These codes work for me. Now I am seeking if anyone help me about sorting the serial port monitor and give me just this address like;

ID: 1E3
Value: 0000000000000142

once in 10 secs.