Go Down

Topic: CAN BUS J1708 (Read 846 times) previous topic - next topic


Good Evening my friends,
   few days ago I have bought a CAN BUS Shield from Elecfreaks because I would try to read my boat engine values... One question is flying inside my head: how to know every sensor address?!? Because from serial i can read only HEX values!

Some of you got the same issue? :)

Thank you all!!!!



Can you post a copy of your serial output?
Can you post a copy of your code?

Thanks.. Tom.. :)
Everything runs on smoke, let the smoke out, it stops running....


Hi Tom,
   thank you for your reply. When I connect two wires (CAN L and CAN H) from engine to CAN-BUS Sparkfun shield the serial monitor returns me:

Code: [Select]

CAN-Bus Demo
[b]Can't init CAN[/b]
Please choose a menu option.
4.Coolant Temperature
5.O2 Voltage
6.MAF Sensor

I've just tried different sketches but all give me "Can't init CAN"... :smiley-confuse:


Can you post the code you are using please?

Tom... :)
Everything runs on smoke, let the smoke out, it stops running....


Followeing the code... Just changed the CANSPEED from 500 to 250 and 125... nothing changed.

Code: [Select]
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
#include <Canbus.h>
char UserInput;
int data;
char buffer[456];  //Data will be temporarily stored to this buffer before being written to the file

//********************************Setup Loop*********************************//

void setup(){
Serial.println("CAN-Bus Demo");

if(Canbus.init(CANSPEED_500))  /* Initialise MCP2515 CAN controller at the  specified speed */
Serial.println("CAN Init ok");
  } else
    Serial.println("Can't init CAN");


Serial.println("Please choose a menu option.");
Serial.println("4.Coolant Temperature");
Serial.println("5.O2 Voltage");
Serial.println("6.MAF Sensor");


//********************************Main Loop*********************************//

void loop(){

   UserInput = Serial.read();

if (UserInput=='1'){
 data=Canbus.ecu_req(VEHICLE_SPEED, buffer);
 Serial.print("Vehicle Speed: ");
 Serial.println(" km/hr ");
else if (UserInput=='2'){
 data= Canbus.ecu_req(ENGINE_RPM, buffer);
 Serial.print("Engine RPM: ");
 Serial.println(" rpm ");

else if (UserInput=='3'){
 data= Canbus.ecu_req(THROTTLE, buffer);
 Serial.print("Throttle: ");
 Serial.println(" %% ");

else if (UserInput=='4'){
 data =Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);
 Serial.print("Engine Coolant Temp: ");
 Serial.println(" degC");

else if (UserInput=='5'){
 data=Canbus.ecu_req(O2_VOLTAGE, buffer);
 Serial.print("O2 Voltage: ");
 Serial.println(" V");

else if (UserInput=='6'){
 data=Canbus.ecu_req(MAF_SENSOR, buffer);
 Serial.print("MAF Sensor: ");
 Serial.println(" g/s");

  Serial.println("Not a valid input.");
  Serial.println("Please enter a valid option.");



Good Evening,
  I've just changed the code using the CAN-BUS Shield Receive Data sketch:

Code: [Select]

// demo: CAN-BUS Shield, receive data with check mode
// send data coming to fast, such as less than 10ms, you can use this way
// loovee, 2014-6-13

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

// the cs pin of the version after v1.1 is default to D9
// v0.9b and v1.0 is default D10
const int SPI_CS_PIN = 10;

MCP_CAN CAN(SPI_CS_PIN);                                    // Set CS pin

void setup()

    while (CAN_OK != CAN.begin(CAN_500KBPS))              // init can bus : baudrate = 500k
        Serial.println("CAN BUS Shield init fail");
        Serial.println(" Init CAN BUS Shield again");
    Serial.println("CAN BUS Shield init ok!");

void loop()
    unsigned char len = 0;
    unsigned char buf[8];

    if(CAN_MSGAVAIL == CAN.checkReceive())            // check if data coming
        CAN.readMsgBuf(&len, buf);    // read data,  len: data length, buf: data buf

        unsigned int canId = CAN.getCanId();
        Serial.print("Get data from ID: ");
        Serial.println(canId, HEX);

        for(int i = 0; i<len; i++)    // print the data
            Serial.print(buf[i], HEX);


The only thing that I can read from the Serial monitor is:

CAN BUS Shield init ok!

I've got some debugging printing CAN_MSGAVAIL and CAN.checkReceive() values returning respectively 3 and 4.


There is something weird with the title of your post because AFAICT J1708 is based on RS-485. J1708 is not a CAN bus, nor is it compatible with a CAN bus.


Jan 16, 2018, 03:08 am Last Edit: Jan 16, 2018, 03:13 am by TomGeorge
Your display is telling you that the UNO and the shield are communicating, but it doesn't mean the CANBUS is communicating.
Check that you have Can High and Can Low correctly configured.
Have you tried changing the CAN baudrate to another CANBUS speed?

Check this forum;


To quote;

How to recognise if CAN bus is j1939 or j1708 using Picoscope.

First off, J1708 is not a CAN bus, nor is it compatible with a CAN bus. Perhaps you simply meant "vehicle bus", which both J1708 and CAN are (and J1939 is only one of many CAN protocols that can appear on a CAN bus).

Andrew is correct when he says that J1939 is faster, but there are more speeds than simply 250k and 500k. For example, 125k is very common in automobiles now. And J1939 can go down as low as 10kbit/sec (and as high as 1 MBit/sec).

J1708, OTOH, is based on RS-485. It's a simple multi-master UART-type transport layer, that uses balanced lines over UTP (unshielded, twisted pair) cabling. It allows up to 20 devices to share that serial link. And not only is it limited to one data-rate (9600 baud), but it "looks like" normal serial data as well. 10-bit "characters", with one Start bit, 8-data bits, and 1 Stop-bit. Each "message" will be between 3 and 21 characters. As a result of that structure, it should be very easy to tell the difference by examining the bus signals with your PicoScope. If the smallest pulse-width is 104 usec, then it's J1708. J1939 will always be less than that, and usually, a LOT less than that.

And you should be able to use the UART decoder in Pico to examine the data stream. It won't tell you that the first byte is the MID, the 2nd is a PID, or the last byte is a Checksum, but you will be able to see the messages. And having the bytes decoded should be all that you need, if you have a J1587 protocol document to interpret the packet structure.
Tom.... :)
Everything runs on smoke, let the smoke out, it stops running....

Go Up