Hi i'm using the sparkfun CANbus shield to read some EOBD parameters of some cars.
I will need the values of stuff like RPM, throttle position,etc to be read constantly so I can eventually add a second arduino to manipulate the car based on my readings. I've only started out this week on Arduino and finally got some correct readings. However with the code i'm using (below) mainly from the libraries. It writes the values in the wrong positions. (see example).
#include <Canbus.h>
#include <defaults.h>
#include <global.h>
#include <mcp2515.h>
#include <mcp2515_defs.h>
int EngineTemp;
int EngineRPM;
int VehicleSpeed;
char buffer[500];
void setup()
{
Serial.begin(9600);
//Initialise MCP2515 CAN controller at the specified speed
if(Canbus.init(CANSPEED_500))
Serial.println("CAN Init ok");
else
Serial.println("Can't Init CAN");
delay(1000);
}
void loop() {
EngineTemp = Canbus.ecu_req(ENGINE_COOLANT_TEMP, buffer);
Serial.print("Engine Coolant Temp: ");
Serial.println(buffer);
delay(1000);
EngineRPM = Canbus.ecu_req(ENGINE_RPM, buffer);
Serial.print("RPM: ");
Serial.println(buffer);
delay(1000);
}
(example)
12:27:37.100 -> RPM: 38 degC
12:27:38.106 -> Engine Coolant Temp: 1742 rpm
12:27:39.117 -> RPM: 38 degC
12:27:40.127 -> Engine Coolant Temp: 1306 rpm
.
Any idea why this is? I can swith the Serial.print RPM to engine coolant but that's not the way it should be.
Thanks in advance!