Hi, Guys!
I have an ELM327 type OBD II interface, and an Arduino MEGA 2560 board. I'd like to display my car's fuel level value (percent).
I've found following rows inside ELM327.cpp:
byte Elm327::fuelLevel(byte &level){
byte status;
byte values[1];
status=getBytes("01","41","2F",values,1);
if (status != ELM_SUCCESS){
return status;
}
level= (100 * values[0])/255;
return ELM_SUCCESS;
}
// PID 2F Fuel level in %
Can You help me, how do I use this function in an .ino file as reading fuel level value?
Thanks: rcph
Please provide a link to where you got the ELM327 library
system
3
Can You help me, how do I use this function in an .ino file as reading fuel level value?
Create an instance of the ELM327 class, unless that method is static.
ELM327 someInstanceName(whatever values you need to supply);
Then, in loop():
byte fuelPercent = 0;
someInstanceName.fuelLevel(fuelPercent);
// do whatever you want to do with fuelPercent
PaulS:
Create an instance of the ELM327 class, unless that method is static.
ELM327 someInstanceName(whatever values you need to supply);
Then, in loop():
byte fuelPercent = 0;
someInstanceName.fuelLevel(fuelPercent);
// do whatever you want to do with fuelPercent
Maybe better:
if (someInstanceName.fuelLevel(fuelPercent) == ELM_SUCCESS)
{
// Do something with fuelPercent
}
Hi, Everybody!
Thank You very much YOur help!
rcph