Arduino Mega Canbus shield

Hello friends,

I am trying to create a dash board for my ford fiesta. Im using an arduino mega with a \sparkfun canbus shield.

I have used the example sketch to get the can data such as engine temperature, rpm etc. I have noticed I can only display on PID at a time.

Does anyone know how to display more than one PID on the Serial monitor for example. When I try to display more than one PID, the can bus PIDs are displayed all together

Eg:

I would call engine rpm and temperature and would get the following on the serial monitor,

rpm = 1000
rpm = 1000
rpm = 1000
rpm = 1000
temp = 60
temp = 60
temp = 60
temp = 60
rpm = 1000
rpm = 1000
rpm = 1000
rpm = 1000

It switches between the two PIds.

Even though i am calling different ecu requests, the buffer that is printed prints all the information instead of isolating the requests.

Can any one assist.

Here is the code:

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


void setup(){ 
Serial.begin(9600); 
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"); 
}  
 delay(1000);  



} 


void loop(){ 


Canbus.ecu_req(ENGINE_RPM, buffer); 
 Serial.print("Engine RPM: "); 
 Serial.println(buffer); 
 delay(500); 

 Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer); 
 Serial.print("Engine Coolant Temp: "); 
 Serial.println(buffer); 
 delay(500);

}

Hi, Welcome to the forum.

Please read the first post in any forum entitled how to use this forum. http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code. It will be formatted in a scrolling window that makes it easier to read.

Thanks.. Tom. :)

Hi Tom, thanks very much.

Appologies it is my first attempt :)

Jeffreykruger:
Hi Tom, thanks very much.

Appologies it is my first attempt :slight_smile:

Is this a road going vehicle ?

Yes, fully standard road car